Debian Codegraph @

packages/seacas/libraries/mapvarlib/bs.f

raw
1 C Copyright(C) 1999-2020, 2023 National Technology & Engineering Solutions
2 C of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
3 C NTESS, the U.S. Government retains certain rights in this software.
4 C
5 C See packages/seacas/LICENSE for details
6
7 C======================================================================
8 SUBROUTINE BS(N,S,F,L,X)
9
10 C**********************************************************************
11
12 C Subroutine BS does the back substitution for the solution of the
13 C local least squares extrapolation technique for element variables
14 C from their element centroid location to a nodal location.
15 C The least squares solution is started by a Gauss elimination in
16 C subroutine FRGE. The process is started in subroutines EXTQ for
17 C 4-node quads or EXTH for 8-node hexes.
18
19 C Called by EXTH, EXTQ
20
21 C**********************************************************************
22
23 C N INT number of equations - 1 + the number of dimensions
24 C S REAL the coefficient matrix - after forward gauss elimination
25 C F REAL the load vector
26 C L INT dummy array - placeholder for subscripts
27 C X REAL the solution vector - coefficients of the equation
28 C SUM REAL dummy variable - used in the solution scheme
29
30 C**********************************************************************
31
32 C subroutine written in double precision
33
34 DOUBLE PRECISION S(N,N),F(N),X(N),SUM
35 INTEGER L(N)
36
37 DO 3 K = 1,N-1
38 DO 2 I = K+1,N
39 F(L(I)) = F(L(I)) - S(L(I),K) * F(L(K))
40 2 CONTINUE
41 3 CONTINUE
42 X(N) = F(L(N)) / S(L(N),N)
43 DO 5 I = N-1,1,-1
44 SUM = F(L(I))
45 DO 4 J = I+1,N
46 SUM = SUM - S(L(I),J) * X(J)
47 4 CONTINUE
48 X(I) = SUM / S(L(I),I)
49 5 CONTINUE
50 RETURN
51 END