Skip to content

Commit 5387e20

Browse files
committed
Fixed sample programs
1 parent fc34385 commit 5387e20

22 files changed

+638
-238
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ include Make.inc
33

44
all: objs lib
55

6-
objs: amgp cbnd
6+
objs: libdir amgp cbnd
77

8-
lib: libdir objs
8+
lib: objs
99
cd amgprec && $(MAKE) lib
1010
cd cbind && $(MAKE) lib
1111

samples/advanced/pdegen/Makefile

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,27 @@ FINCLUDES=$(FMFLAG). $(FMFLAG)$(AMGMODDIR) $(FMFLAG)$(AMGINCDIR) $(PSBLAS_INCLUD
88

99
LINKOPT=
1010
EXEDIR=./runs
11+
DGEN2D=amg_d_pde2d_base_mod.o amg_d_pde2d_exp_mod.o amg_d_pde2d_gauss_mod.o amg_d_pde2d_box_mod.o
12+
DGEN3D=amg_d_pde3d_base_mod.o amg_d_pde3d_exp_mod.o amg_d_pde3d_gauss_mod.o amg_d_pde3d_box_mod.o
13+
SGEN2D=amg_s_pde2d_base_mod.o amg_s_pde2d_exp_mod.o amg_s_pde2d_gauss_mod.o amg_s_pde2d_box_mod.o
14+
SGEN3D=amg_s_pde3d_base_mod.o amg_s_pde3d_exp_mod.o amg_s_pde3d_gauss_mod.o amg_s_pde3d_box_mod.o
1115

1216
all: amg_s_pde3d amg_d_pde3d amg_s_pde2d amg_d_pde2d
1317

14-
amg_d_pde3d: amg_d_pde3d.o amg_d_genpde_mod.o amg_d_pde3d_base_mod.o amg_d_pde3d_exp_mod.o amg_d_pde3d_gauss_mod.o data_input.o
15-
$(FLINK) $(LINKOPT) amg_d_pde3d.o amg_d_genpde_mod.o amg_d_pde3d_base_mod.o amg_d_pde3d_exp_mod.o amg_d_pde3d_gauss_mod.o data_input.o -o amg_d_pde3d $(AMG_LIBS) $(PSBLAS_LIBS) $(LDLIBS)
18+
amg_d_pde3d: amg_d_pde3d.o amg_d_genpde_mod.o $(DGEN3D) data_input.o
19+
$(FLINK) $(LINKOPT) amg_d_pde3d.o amg_d_genpde_mod.o $(DGEN3D) data_input.o -o amg_d_pde3d $(AMG_LIBS) $(PSBLAS_LIBS) $(LDLIBS)
1620
/bin/mv amg_d_pde3d $(EXEDIR)
1721

18-
amg_s_pde3d: amg_s_pde3d.o amg_s_genpde_mod.o amg_s_pde3d_base_mod.o amg_s_pde3d_exp_mod.o amg_s_pde3d_gauss_mod.o data_input.o
19-
$(FLINK) $(LINKOPT) amg_s_pde3d.o amg_s_genpde_mod.o amg_s_pde3d_base_mod.o amg_s_pde3d_exp_mod.o amg_s_pde3d_gauss_mod.o data_input.o -o amg_s_pde3d $(AMG_LIBS) $(PSBLAS_LIBS) $(LDLIBS)
22+
amg_s_pde3d: amg_s_pde3d.o amg_s_genpde_mod.o $(SGEN3D) data_input.o
23+
$(FLINK) $(LINKOPT) amg_s_pde3d.o amg_s_genpde_mod.o $(SGEN3D) data_input.o -o amg_s_pde3d $(AMG_LIBS) $(PSBLAS_LIBS) $(LDLIBS)
2024
/bin/mv amg_s_pde3d $(EXEDIR)
2125

22-
amg_d_pde2d: amg_d_pde2d.o amg_d_genpde_mod.o amg_d_pde2d_base_mod.o amg_d_pde2d_exp_mod.o amg_d_pde2d_box_mod.o data_input.o
23-
$(FLINK) $(LINKOPT) amg_d_pde2d.o amg_d_genpde_mod.o amg_d_pde2d_base_mod.o amg_d_pde2d_exp_mod.o amg_d_pde2d_box_mod.o data_input.o -o amg_d_pde2d $(AMG_LIBS) $(PSBLAS_LIBS) $(LDLIBS)
26+
amg_d_pde2d: amg_d_pde2d.o amg_d_genpde_mod.o $(DGEN2D) data_input.o
27+
$(FLINK) $(LINKOPT) amg_d_pde2d.o amg_d_genpde_mod.o $(DGEN2D) data_input.o -o amg_d_pde2d $(AMG_LIBS) $(PSBLAS_LIBS) $(LDLIBS)
2428
/bin/mv amg_d_pde2d $(EXEDIR)
2529

26-
amg_s_pde2d: amg_s_pde2d.o amg_s_genpde_mod.o amg_s_pde2d_base_mod.o amg_s_pde2d_exp_mod.o amg_s_pde2d_box_mod.o data_input.o
27-
$(FLINK) $(LINKOPT) amg_s_pde2d.o amg_s_genpde_mod.o amg_s_pde2d_base_mod.o amg_s_pde2d_exp_mod.o amg_s_pde2d_box_mod.o data_input.o -o amg_s_pde2d $(AMG_LIBS) $(PSBLAS_LIBS) $(LDLIBS)
30+
amg_s_pde2d: amg_s_pde2d.o amg_s_genpde_mod.o $(SGEN2D) data_input.o
31+
$(FLINK) $(LINKOPT) amg_s_pde2d.o amg_s_genpde_mod.o $(SGEN2D) data_input.o -o amg_s_pde2d $(AMG_LIBS) $(PSBLAS_LIBS) $(LDLIBS)
2832
/bin/mv amg_s_pde2d $(EXEDIR)
2933

3034
amg_d_pde3d_rebld: amg_d_pde3d_rebld.o data_input.o
@@ -33,10 +37,10 @@ amg_d_pde3d_rebld: amg_d_pde3d_rebld.o data_input.o
3337

3438
amg_d_pde3d.o amg_s_pde3d.o amg_d_pde2d.o amg_s_pde2d.o: data_input.o
3539

36-
amg_d_pde3d.o: amg_d_genpde_mod.o amg_d_pde3d_base_mod.o amg_d_pde3d_exp_mod.o amg_d_pde3d_gauss_mod.o
37-
amg_s_pde3d.o: amg_s_genpde_mod.o amg_s_pde3d_base_mod.o amg_s_pde3d_exp_mod.o amg_s_pde3d_gauss_mod.o
38-
amg_d_pde2d.o: amg_d_genpde_mod.o amg_d_pde2d_base_mod.o amg_d_pde2d_exp_mod.o amg_d_pde2d_box_mod.o
39-
amg_s_pde2d.o: amg_s_genpde_mod.o amg_s_pde2d_base_mod.o amg_s_pde2d_exp_mod.o amg_s_pde2d_box_mod.o
40+
amg_d_pde3d.o: amg_d_genpde_mod.o $(DGEN3D)
41+
amg_s_pde3d.o: amg_s_genpde_mod.o $(SGEN3D)
42+
amg_d_pde2d.o: amg_d_genpde_mod.o $(DGEN2D)
43+
amg_s_pde2d.o: amg_s_genpde_mod.o $(SGEN2D)
4044

4145
check: all
4246
cd runs && ./amg_d_pde2d <amg_pde2d.inp && ./amg_s_pde2d<amg_pde2d.inp

samples/advanced/pdegen/amg_d_pde2d.F90

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ program amg_d_pde2d
7272
use amg_d_pde2d_base_mod
7373
use amg_d_pde2d_exp_mod
7474
use amg_d_pde2d_box_mod
75+
use amg_d_pde2d_gauss_mod
7576
use amg_d_genpde_mod
7677
#if defined(OPENMP)
7778
use omp_lib
@@ -124,56 +125,56 @@ program amg_d_pde2d
124125
integer(psb_ipk_) :: outer_sweeps ! number of outer sweeps: sweeps for 1-level,
125126
! AMG cycles for ML
126127
! general AMG data
127-
character(len=16) :: mlcycle ! AMG cycle type
128+
character(len=32) :: mlcycle ! AMG cycle type
128129
integer(psb_ipk_) :: maxlevs ! maximum number of levels in AMG preconditioner
129130

130131
! AMG aggregation
131-
character(len=16) :: aggr_prol ! aggregation type: SMOOTHED, NONSMOOTHED
132-
character(len=16) :: par_aggr_alg ! parallel aggregation algorithm: DEC, SYMDEC
133-
character(len=16) :: aggr_type ! Type of aggregation SOC1, SOC2, MATCHBOXP
132+
character(len=32) :: aggr_prol ! aggregation type: SMOOTHED, NONSMOOTHED
133+
character(len=32) :: par_aggr_alg ! parallel aggregation algorithm: DEC, SYMDEC
134+
character(len=32) :: aggr_type ! Type of aggregation SOC1, SOC2, MATCHBOXP
134135
integer(psb_ipk_) :: aggr_size ! Requested size of the aggregates for MATCHBOXP
135-
character(len=16) :: aggr_ord ! ordering for aggregation: NATURAL, DEGREE
136-
character(len=16) :: aggr_filter ! filtering: FILTER, NO_FILTER
136+
character(len=32) :: aggr_ord ! ordering for aggregation: NATURAL, DEGREE
137+
character(len=32) :: aggr_filter ! filtering: FILTER, NO_FILTER
137138
real(psb_dpk_) :: mncrratio ! minimum aggregation ratio
138139
real(psb_dpk_), allocatable :: athresv(:) ! smoothed aggregation threshold vector
139140
integer(psb_ipk_) :: thrvsz ! size of threshold vector
140141
real(psb_dpk_) :: athres ! smoothed aggregation threshold
141142
integer(psb_ipk_) :: csizepp ! minimum size of coarsest matrix per process
142143

143144
! AMG smoother or pre-smoother; also 1-lev preconditioner
144-
character(len=16) :: smther ! (pre-)smoother type: BJAC, AS
145+
character(len=32) :: smther ! (pre-)smoother type: BJAC, AS
145146
integer(psb_ipk_) :: jsweeps ! (pre-)smoother / 1-lev prec. sweeps
146147
integer(psb_ipk_) :: novr ! number of overlap layers
147-
character(len=16) :: restr ! restriction over application of AS
148-
character(len=16) :: prol ! prolongation over application of AS
149-
character(len=16) :: solve ! local subsolver type: ILU, MILU, ILUT,
148+
character(len=32) :: restr ! restriction over application of AS
149+
character(len=32) :: prol ! prolongation over application of AS
150+
character(len=32) :: solve ! local subsolver type: ILU, MILU, ILUT,
150151
! UMF, MUMPS, SLU, FWGS, BWGS, JAC
151152
integer(psb_ipk_) :: ssweeps ! inner solver sweeps
152-
character(len=16) :: variant ! AINV variant: LLK, etc
153+
character(len=32) :: variant ! AINV variant: LLK, etc
153154
integer(psb_ipk_) :: fill ! fill-in for incomplete LU factorization
154155
integer(psb_ipk_) :: invfill ! Inverse fill-in for INVK
155156
real(psb_dpk_) :: thr ! threshold for ILUT factorization
156157

157158
! AMG post-smoother; ignored by 1-lev preconditioner
158-
character(len=16) :: smther2 ! post-smoother type: BJAC, AS
159+
character(len=32) :: smther2 ! post-smoother type: BJAC, AS
159160
integer(psb_ipk_) :: jsweeps2 ! post-smoother sweeps
160161
integer(psb_ipk_) :: novr2 ! number of overlap layers
161-
character(len=16) :: restr2 ! restriction over application of AS
162-
character(len=16) :: prol2 ! prolongation over application of AS
163-
character(len=16) :: solve2 ! local subsolver type: ILU, MILU, ILUT,
162+
character(len=32) :: restr2 ! restriction over application of AS
163+
character(len=32) :: prol2 ! prolongation over application of AS
164+
character(len=32) :: solve2 ! local subsolver type: ILU, MILU, ILUT,
164165
! UMF, MUMPS, SLU, FWGS, BWGS, JAC
165166
integer(psb_ipk_) :: ssweeps2 ! inner solver sweeps
166-
character(len=16) :: variant2 ! AINV variant: LLK, etc
167+
character(len=32) :: variant2 ! AINV variant: LLK, etc
167168
integer(psb_ipk_) :: fill2 ! fill-in for incomplete LU factorization
168169
integer(psb_ipk_) :: invfill2 ! Inverse fill-in for INVK
169170
real(psb_dpk_) :: thr2 ! threshold for ILUT factorization
170171

171172
! coarsest-level solver
172-
character(len=16) :: cmat ! coarsest matrix layout: REPL, DIST
173-
character(len=16) :: csolve ! coarsest-lev solver: BJAC, SLUDIST (distr.
173+
character(len=32) :: cmat ! coarsest matrix layout: REPL, DIST
174+
character(len=32) :: csolve ! coarsest-lev solver: BJAC, SLUDIST (distr.
174175
! mat.); UMF, MUMPS, SLU, ILU, ILUT, MILU
175176
! (repl. mat.)
176-
character(len=16) :: csbsolve ! coarsest-lev local subsolver: ILU, ILUT,
177+
character(len=32) :: csbsolve ! coarsest-lev local subsolver: ILU, ILUT,
177178
! MILU, UMF, MUMPS, SLU
178179
integer(psb_ipk_) :: cfill ! fill-in for incomplete LU factorization
179180
real(psb_dpk_) :: cthres ! threshold for ILUT factorization
@@ -241,13 +242,16 @@ program amg_d_pde2d
241242
select case(psb_toupper(trim(pdecoeff)))
242243
case("CONST")
243244
call amg_gen_pde2d(ctxt,idim,a,b,x,desc_a,afmt,&
244-
& a1,a2,b1,b2,c,g,info)
245+
& a1_base,a2_base,b1_base,b2_base,c_base,g_base,info)
245246
case("EXP")
246247
call amg_gen_pde2d(ctxt,idim,a,b,x,desc_a,afmt,&
247248
& a1_exp,a2_exp,b1_exp,b2_exp,c_exp,g_exp,info)
248249
case("BOX")
249250
call amg_gen_pde2d(ctxt,idim,a,b,x,desc_a,afmt,&
250251
& a1_box,a2_box,b1_box,b2_box,c_box,g_box,info)
252+
case("GAUSS")
253+
call amg_gen_pde2d(ctxt,idim,a,b,x,desc_a,afmt,&
254+
& a1_gauss,a2_gauss,b1_gauss,b2_gauss,c_gauss,g_gauss,info)
251255
case default
252256
info=psb_err_from_subroutine_
253257
ch_err='amg_gen_pdecoeff'

samples/advanced/pdegen/amg_d_pde2d_base_mod.f90

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -38,52 +38,52 @@ module amg_d_pde2d_base_mod
3838
use psb_base_mod, only : psb_dpk_, dzero, done
3939
real(psb_dpk_), save, private :: epsilon=done/80
4040
contains
41-
subroutine pde_set_parm(dat)
41+
subroutine pde_set_parm2d_base(dat)
4242
real(psb_dpk_), intent(in) :: dat
4343
epsilon = dat
44-
end subroutine pde_set_parm
44+
end subroutine pde_set_parm2d_base
4545
!
4646
! functions parametrizing the differential equation
4747
!
48-
function b1(x,y)
48+
function b1_base(x,y)
4949
implicit none
50-
real(psb_dpk_) :: b1
50+
real(psb_dpk_) :: b1_base
5151
real(psb_dpk_), intent(in) :: x,y
52-
b1 = dzero/1.414_psb_dpk_
53-
end function b1
54-
function b2(x,y)
52+
b1_base = dzero/1.414_psb_dpk_
53+
end function b1_base
54+
function b2_base(x,y)
5555
implicit none
56-
real(psb_dpk_) :: b2
56+
real(psb_dpk_) :: b2_base
5757
real(psb_dpk_), intent(in) :: x,y
58-
b2 = dzero/1.414_psb_dpk_
59-
end function b2
60-
function c(x,y)
58+
b2_base = dzero/1.414_psb_dpk_
59+
end function b2_base
60+
function c_base(x,y)
6161
implicit none
62-
real(psb_dpk_) :: c
62+
real(psb_dpk_) :: c_base
6363
real(psb_dpk_), intent(in) :: x,y
64-
c = dzero
65-
end function c
66-
function a1(x,y)
64+
c_base = dzero
65+
end function c_base
66+
function a1_base(x,y)
6767
implicit none
68-
real(psb_dpk_) :: a1
68+
real(psb_dpk_) :: a1_base
6969
real(psb_dpk_), intent(in) :: x,y
70-
a1=done*epsilon
71-
end function a1
72-
function a2(x,y)
70+
a1_base=done*epsilon
71+
end function a1_base
72+
function a2_base(x,y)
7373
implicit none
74-
real(psb_dpk_) :: a2
74+
real(psb_dpk_) :: a2_base
7575
real(psb_dpk_), intent(in) :: x,y
76-
a2=done*epsilon
77-
end function a2
78-
function g(x,y)
76+
a2_base=done*epsilon
77+
end function a2_base
78+
function g_base(x,y)
7979
implicit none
80-
real(psb_dpk_) :: g
80+
real(psb_dpk_) :: g_base
8181
real(psb_dpk_), intent(in) :: x,y
82-
g = dzero
82+
g_base = dzero
8383
if (x == done) then
84-
g = done
84+
g_base = done
8585
else if (x == dzero) then
86-
g = done
86+
g_base = done
8787
end if
88-
end function g
88+
end function g_base
8989
end module amg_d_pde2d_base_mod

samples/advanced/pdegen/amg_d_pde2d_box_mod.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ module amg_d_pde2d_box_mod
3838
use psb_base_mod, only : psb_dpk_, dzero, done
3939
real(psb_dpk_), save, private :: epsilon=done/80
4040
contains
41-
subroutine pde_set_parm(dat)
41+
subroutine pde_set_parm2d_box(dat)
4242
real(psb_dpk_), intent(in) :: dat
4343
epsilon = dat
44-
end subroutine pde_set_parm
44+
end subroutine pde_set_parm2d_box
4545
!
4646
! functions parametrizing the differential equation
4747
!

samples/advanced/pdegen/amg_d_pde2d_exp_mod.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ module amg_d_pde2d_exp_mod
3838
use psb_base_mod, only : psb_dpk_, done, dzero
3939
real(psb_dpk_), save, private :: epsilon=done/80
4040
contains
41-
subroutine pde_set_parm(dat)
41+
subroutine pde_set_parm2d_exp(dat)
4242
real(psb_dpk_), intent(in) :: dat
4343
epsilon = dat
44-
end subroutine pde_set_parm
44+
end subroutine pde_set_parm2d_exp
4545
!
4646
! functions parametrizing the differential equation
4747
!
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
!
2+
!
3+
! AMG4PSBLAS version 1.0
4+
! Algebraic Multigrid Package
5+
! based on PSBLAS (Parallel Sparse BLAS version 3.7)
6+
!
7+
! (C) Copyright 2021
8+
!
9+
! Salvatore Filippone
10+
! Pasqua D'Ambra
11+
! Fabio Durastante
12+
!
13+
! Redistribution and use in source and binary forms, with or without
14+
! modification, are permitted provided that the following conditions
15+
! are met:
16+
! 1. Redistributions of source code must retain the above copyright
17+
! notice, this list of conditions and the following disclaimer.
18+
! 2. Redistributions in binary form must reproduce the above copyright
19+
! notice, this list of conditions, and the following disclaimer in the
20+
! documentation and/or other materials provided with the distribution.
21+
! 3. The name of the AMG4PSBLAS group or the names of its contributors may
22+
! not be used to endorse or promote products derived from this
23+
! software without specific written permission.
24+
!
25+
! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26+
! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27+
! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28+
! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AMG4PSBLAS GROUP OR ITS CONTRIBUTORS
29+
! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30+
! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31+
! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32+
! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33+
! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34+
! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35+
! POSSIBILITY OF SUCH DAMAGE.
36+
!
37+
module amg_d_pde2d_gauss_mod
38+
use psb_base_mod, only : psb_dpk_, done, dzero
39+
real(psb_dpk_), save, private :: epsilon=done/80
40+
contains
41+
subroutine pde_set_parm2d_gauss(dat)
42+
real(psb_dpk_), intent(in) :: dat
43+
epsilon = dat
44+
end subroutine pde_set_parm2d_gauss
45+
!
46+
! functions parametrizing the differential equation
47+
!
48+
function b1_gauss(x,y)
49+
implicit none
50+
real(psb_dpk_) :: b1_gauss
51+
real(psb_dpk_), intent(in) :: x,y
52+
b1_gauss=done/sqrt(3.0_psb_dpk_)-2*x*exp(-(x**2+y**2))
53+
end function b1_gauss
54+
function b2_gauss(x,y)
55+
implicit none
56+
real(psb_dpk_) :: b2_gauss
57+
real(psb_dpk_), intent(in) :: x,y
58+
b2_gauss=done/sqrt(3.0_psb_dpk_)-2*y*exp(-(x**2+y**2))
59+
end function b2_gauss
60+
function c_gauss(x,y)
61+
implicit none
62+
real(psb_dpk_) :: c_gauss
63+
real(psb_dpk_), intent(in) :: x,y
64+
c_gauss=dzero
65+
end function c_gauss
66+
function a1_gauss(x,y)
67+
implicit none
68+
real(psb_dpk_) :: a1_gauss
69+
real(psb_dpk_), intent(in) :: x,y
70+
a1_gauss=epsilon*exp(-(x**2+y**2))
71+
end function a1_gauss
72+
function a2_gauss(x,y)
73+
implicit none
74+
real(psb_dpk_) :: a2_gauss
75+
real(psb_dpk_), intent(in) :: x,y
76+
a2_gauss=epsilon*exp(-(x**2+y**2))
77+
end function a2_gauss
78+
function g_gauss(x,y)
79+
implicit none
80+
real(psb_dpk_) :: g_gauss
81+
real(psb_dpk_), intent(in) :: x,y
82+
g_gauss = dzero
83+
if (x == done) then
84+
g_gauss = done
85+
else if (x == dzero) then
86+
g_gauss = done
87+
end if
88+
end function g_gauss
89+
end module amg_d_pde2d_gauss_mod

0 commit comments

Comments
 (0)