summaryrefslogtreecommitdiff
path: root/Utilib/src/ALVDLS.f
diff options
context:
space:
mode:
authorstainer_t <thomas.stainer@oecd-nea.org>2025-09-08 13:48:49 +0200
committerstainer_t <thomas.stainer@oecd-nea.org>2025-09-08 13:48:49 +0200
commit7dfcc480ba1e19bd3232349fc733caef94034292 (patch)
tree03ee104eb8846d5cc1a981d267687a729185d3f3 /Utilib/src/ALVDLS.f
Initial commit from Polytechnique Montreal
Diffstat (limited to 'Utilib/src/ALVDLS.f')
-rw-r--r--Utilib/src/ALVDLS.f143
1 files changed, 143 insertions, 0 deletions
diff --git a/Utilib/src/ALVDLS.f b/Utilib/src/ALVDLS.f
new file mode 100644
index 0000000..3c35a72
--- /dev/null
+++ b/Utilib/src/ALVDLS.f
@@ -0,0 +1,143 @@
+*DECK ALVDLS
+ SUBROUTINE ALVDLS (LTSW,MU1,ASS,F,ISEG,LON,NBL,LBL)
+*
+*-----------------------------------------------------------------------
+*
+*Purpose:
+* solution of a symmetric linear system where the coefficient matrix
+* have been previously factorized as LDL(T). Supervectorial version.
+*
+*Copyright:
+* Copyright (C) 1992 Ecole Polytechnique de Montreal
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public
+* License as published by the Free Software Foundation; either
+* version 2.1 of the License, or (at your option) any later version
+*
+*Author(s): A. Hebert
+*
+*Parameters: input
+* LTSW maximum bandwidth. =2 for tridiagonal systems.
+* MU1 position of each diagonal element in vector ass.
+* DIMENSION MU1(L4) where L4=SUM(LBL(I))
+* ASS LDL(T) factors of the coefficient matrix in compressed
+* diagonal storage mode. DIMENSION ASS(ISEG,MU1(L4))
+* F right-hand side of the linear system. DIMENSION F(ISEG,L4)
+* ISEG number of elements in a vector register.
+* LON number of groups of linear systems.
+* NBL number of linear systems in each group. DIMENSION NBL(LON)
+* LBL number of unknowns in each group. DIMENSION LBL(LON)
+*
+*Parameters: output
+* F solution of the linear system. DIMENSION F(ISEG,L4)
+*
+*-----------------------------------------------------------------------
+*
+ INTEG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