CalculiX  2.13
A Free Software Three-Dimensional Structural Finite Element Program
dslugm.f File Reference

Go to the source code of this file.

Functions/Subroutines

subroutine dslugm (N, B, X, NELT, IA, JA, A, ISYM, NSAVE, ITOL, TOL, ITMAX, ITER, ERR, IERR, IUNIT, RWORK, LENW, IWORK, LENIW)
 
subroutine dslui (N, B, X, NELT, IA, JA, A, ISYM, RWORK, IWORK)
 
subroutine dslui2 (N, B, X, IL, JL, L, DINV, IU, JU, U)
 
subroutine dsmv (N, X, Y, NELT, IA, JA, A, ISYM)
 
subroutine dchkw (NAME, LOCIW, LENIW, LOCW, LENW, IERR, ITER, ERR)
 
subroutine ds2y (N, NELT, IA, JA, A, ISYM)
 
subroutine dsilus (N, NELT, IA, JA, A, ISYM, NL, IL, JL, L, DINV, NU, IU, JU, U, NROW, NCOL)
 
subroutine qs2i1d (IA, JA, A, N, KFLAG)
 

Function/Subroutine Documentation

◆ dchkw()

subroutine dchkw ( character, dimension(*)  NAME,
integer  LOCIW,
integer  LENIW,
integer  LOCW,
integer  LENW,
integer  IERR,
integer  ITER,
double precision  ERR 
)
913 C***BEGIN PROLOGUE DCHKW
914 C***SUBSIDIARY
915 C***PURPOSE SLAP WORK/IWORK Array Bounds Checker.
916 C This routine checks the work array lengths and interfaces
917 C to the SLATEC error handler if a problem is found.
918 C***LIBRARY SLATEC (SLAP)
919 C***CATEGORY R2
920 C***TYPE DOUBLE PRECISION (SCHKW-S, DCHKW-D)
921 C***KEYWORDS ERROR CHECKING, SLAP, WORKSPACE CHECKING
922 C***AUTHOR Seager, Mark K., (LLNL)
923 C Lawrence Livermore National Laboratory
924 C PO BOX 808, L-60
925 C Livermore, CA 94550 (510) 423-3141
926 C seager@llnl.gov
927 C***DESCRIPTION
928 C
929 C *Usage:
930 C CHARACTER*(*) NAME
931 C INTEGER LOCIW, LENIW, LOCW, LENW, IERR, ITER
932 C DOUBLE PRECISION ERR
933 C
934 C CALL DCHKW( NAME, LOCIW, LENIW, LOCW, LENW, IERR, ITER, ERR )
935 C
936 C *Arguments:
937 C NAME :IN Character*(*).
938 C Name of the calling routine. This is used in the output
939 C message, if an error is detected.
940 C LOCIW :IN Integer.
941 C Location of the first free element in the integer workspace
942 C array.
943 C LENIW :IN Integer.
944 C Length of the integer workspace array.
945 C LOCW :IN Integer.
946 C Location of the first free element in the double precision
947 C workspace array.
948 C LENRW :IN Integer.
949 C Length of the double precision workspace array.
950 C IERR :OUT Integer.
951 C Return error flag.
952 C IERR = 0 => All went well.
953 C IERR = 1 => Insufficient storage allocated for
954 C WORK or IWORK.
955 C ITER :OUT Integer.
956 C Set to zero on return.
957 C ERR :OUT Double Precision.
958 C Set to the smallest positive magnitude if all went well.
959 C Set to a very large number if an error is detected.
960 C
961 C***REFERENCES (NONE)
962 C***ROUTINES CALLED D1MACH, XERMSG
963 C***REVISION HISTORY (YYMMDD)
964 C 880225 DATE WRITTEN
965 C 881213 Previous REVISION DATE
966 C 890915 Made changes requested at July 1989 CML Meeting. (MKS)
967 C 890922 Numerous changes to prologue to make closer to SLATEC
968 C standard. (FNF)
969 C 890929 Numerous changes to reduce SP/DP differences. (FNF)
970 C 900805 Changed XERRWV calls to calls to XERMSG. (RWC)
971 C 910411 Prologue converted to Version 4.0 format. (BAB)
972 C 910502 Corrected XERMSG calls to satisfy Section 6.2.2 of ANSI
973 C X3.9-1978. (FNF)
974 C 910506 Made subsidiary. (FNF)
975 C 920511 Added complete declaration section. (WRB)
976 C 921015 Added code to initialize ITER and ERR when IERR=0. (FNF)
977 C***END PROLOGUE DCHKW
978 C .. Scalar Arguments ..
979  DOUBLE PRECISION err
980  INTEGER ierr, iter, leniw, lenw, lociw, locw
981  CHARACTER name*(*)
982 C .. Local Scalars ..
983  CHARACTER xern1*8, xern2*8, xernam*8
984 C .. External Functions ..
985  DOUBLE PRECISION d1mach
986  EXTERNAL d1mach
987 C .. External Subroutines ..
988  EXTERNAL xermsg
989 C***FIRST EXECUTABLE STATEMENT DCHKW
990 C
991 C Check the Integer workspace situation.
992 C
993  ierr = 0
994  iter = 0
995  err = d1mach(1)
996  IF( lociw.GT.leniw ) THEN
997  ierr = 1
998  err = d1mach(2)
999  xernam = name
1000  WRITE (xern1, '(I8)') lociw
1001  WRITE (xern2, '(I8)') leniw
1002  CALL xermsg ('SLATEC', 'DCHKW',
1003  $ 'In ' // xernam // ', INTEGER work array too short. ' //
1004  $ 'IWORK needs ' // xern1 // '; have allocated ' // xern2,
1005  $ 1, 1)
1006  ENDIF
1007 C
1008 C Check the Double Precision workspace situation.
1009  IF( locw.GT.lenw ) THEN
1010  ierr = 1
1011  err = d1mach(2)
1012  xernam = name
1013  WRITE (xern1, '(I8)') locw
1014  WRITE (xern2, '(I8)') lenw
1015  CALL xermsg ('SLATEC', 'DCHKW',
1016  $ 'In ' // xernam // ', DOUBLE PRECISION work array too ' //
1017  $ 'short. RWORK needs ' // xern1 // '; have allocated ' //
1018  $ xern2, 1, 1)
1019  ENDIF
1020  RETURN
1021 C------------- LAST LINE OF DCHKW FOLLOWS ----------------------------
double precision function d1mach(I)
Definition: ddeabm.f:2012
subroutine xermsg(LIBRAR, SUBROU, MESSG, NERR, LEVEL)
Definition: ddeabm.f:1265

◆ ds2y()

subroutine ds2y ( integer  N,
integer  NELT,
integer, dimension(nelt)  IA,
integer, dimension(nelt)  JA,
double precision, dimension(nelt)  A,
integer  ISYM 
)
1025 C***BEGIN PROLOGUE DS2Y
1026 C***PURPOSE SLAP Triad to SLAP Column Format Converter.
1027 C Routine to convert from the SLAP Triad to SLAP Column
1028 C format.
1029 C***LIBRARY SLATEC (SLAP)
1030 C***CATEGORY D1B9
1031 C***TYPE DOUBLE PRECISION (SS2Y-S, DS2Y-D)
1032 C***KEYWORDS LINEAR SYSTEM, SLAP SPARSE
1033 C***AUTHOR Seager, Mark K., (LLNL)
1034 C Lawrence Livermore National Laboratory
1035 C PO BOX 808, L-60
1036 C Livermore, CA 94550 (510) 423-3141
1037 C seager@llnl.gov
1038 C***DESCRIPTION
1039 C
1040 C *Usage:
1041 C INTEGER N, NELT, IA(NELT), JA(NELT), ISYM
1042 C DOUBLE PRECISION A(NELT)
1043 C
1044 C CALL DS2Y( N, NELT, IA, JA, A, ISYM )
1045 C
1046 C *Arguments:
1047 C N :IN Integer
1048 C Order of the Matrix.
1049 C NELT :IN Integer.
1050 C Number of non-zeros stored in A.
1051 C IA :INOUT Integer IA(NELT).
1052 C JA :INOUT Integer JA(NELT).
1053 C A :INOUT Double Precision A(NELT).
1054 C These arrays should hold the matrix A in either the SLAP
1055 C Triad format or the SLAP Column format. See "Description",
1056 C below. If the SLAP Triad format is used, this format is
1057 C translated to the SLAP Column format by this routine.
1058 C ISYM :IN Integer.
1059 C Flag to indicate symmetric storage format.
1060 C If ISYM=0, all non-zero entries of the matrix are stored.
1061 C If ISYM=1, the matrix is symmetric, and only the lower
1062 C triangle of the matrix is stored.
1063 C
1064 C *Description:
1065 C The Sparse Linear Algebra Package (SLAP) utilizes two matrix
1066 C data structures: 1) the SLAP Triad format or 2) the SLAP
1067 C Column format. The user can hand this routine either of the
1068 C of these data structures. If the SLAP Triad format is give
1069 C as input then this routine transforms it into SLAP Column
1070 C format. The way this routine tells which format is given as
1071 C input is to look at JA(N+1). If JA(N+1) = NELT+1 then we
1072 C have the SLAP Column format. If that equality does not hold
1073 C then it is assumed that the IA, JA, A arrays contain the
1074 C SLAP Triad format.
1075 C
1076 C =================== S L A P Triad format ===================
1077 C This routine requires that the matrix A be stored in the
1078 C SLAP Triad format. In this format only the non-zeros are
1079 C stored. They may appear in *ANY* order. The user supplies
1080 C three arrays of length NELT, where NELT is the number of
1081 C non-zeros in the matrix: (IA(NELT), JA(NELT), A(NELT)). For
1082 C each non-zero the user puts the row and column index of that
1083 C matrix element in the IA and JA arrays. The value of the
1084 C non-zero matrix element is placed in the corresponding
1085 C location of the A array. This is an extremely easy data
1086 C structure to generate. On the other hand it is not too
1087 C efficient on vector computers for the iterative solution of
1088 C linear systems. Hence, SLAP changes this input data
1089 C structure to the SLAP Column format for the iteration (but
1090 C does not change it back).
1091 C
1092 C Here is an example of the SLAP Triad storage format for a
1093 C 5x5 Matrix. Recall that the entries may appear in any order.
1094 C
1095 C 5x5 Matrix SLAP Triad format for 5x5 matrix on left.
1096 C 1 2 3 4 5 6 7 8 9 10 11
1097 C |11 12 0 0 15| A: 51 12 11 33 15 53 55 22 35 44 21
1098 C |21 22 0 0 0| IA: 5 1 1 3 1 5 5 2 3 4 2
1099 C | 0 0 33 0 35| JA: 1 2 1 3 5 3 5 2 5 4 1
1100 C | 0 0 0 44 0|
1101 C |51 0 53 0 55|
1102 C
1103 C =================== S L A P Column format ==================
1104 C
1105 C This routine requires that the matrix A be stored in the
1106 C SLAP Column format. In this format the non-zeros are stored
1107 C counting down columns (except for the diagonal entry, which
1108 C must appear first in each "column") and are stored in the
1109 C double precision array A. In other words, for each column
1110 C in the matrix put the diagonal entry in A. Then put in the
1111 C other non-zero elements going down the column (except the
1112 C diagonal) in order. The IA array holds the row index for
1113 C each non-zero. The JA array holds the offsets into the IA,
1114 C A arrays for the beginning of each column. That is,
1115 C IA(JA(ICOL)), A(JA(ICOL)) points to the beginning of the
1116 C ICOL-th column in IA and A. IA(JA(ICOL+1)-1),
1117 C A(JA(ICOL+1)-1) points to the end of the ICOL-th column.
1118 C Note that we always have JA(N+1) = NELT+1, where N is the
1119 C number of columns in the matrix and NELT is the number of
1120 C non-zeros in the matrix.
1121 C
1122 C Here is an example of the SLAP Column storage format for a
1123 C 5x5 Matrix (in the A and IA arrays '|' denotes the end of a
1124 C column):
1125 C
1126 C 5x5 Matrix SLAP Column format for 5x5 matrix on left.
1127 C 1 2 3 4 5 6 7 8 9 10 11
1128 C |11 12 0 0 15| A: 11 21 51 | 22 12 | 33 53 | 44 | 55 15 35
1129 C |21 22 0 0 0| IA: 1 2 5 | 2 1 | 3 5 | 4 | 5 1 3
1130 C | 0 0 33 0 35| JA: 1 4 6 8 9 12
1131 C | 0 0 0 44 0|
1132 C |51 0 53 0 55|
1133 C
1134 C***REFERENCES (NONE)
1135 C***ROUTINES CALLED QS2I1D
1136 C***REVISION HISTORY (YYMMDD)
1137 C 871119 DATE WRITTEN
1138 C 881213 Previous REVISION DATE
1139 C 890915 Made changes requested at July 1989 CML Meeting. (MKS)
1140 C 890922 Numerous changes to prologue to make closer to SLATEC
1141 C standard. (FNF)
1142 C 890929 Numerous changes to reduce SP/DP differences. (FNF)
1143 C 910411 Prologue converted to Version 4.0 format. (BAB)
1144 C 910502 Corrected C***FIRST EXECUTABLE STATEMENT line. (FNF)
1145 C 920511 Added complete declaration section. (WRB)
1146 C 930701 Updated CATEGORY section. (FNF, WRB)
1147 C***END PROLOGUE DS2Y
1148 C .. Scalar Arguments ..
1149  INTEGER isym, n, nelt
1150 C .. Array Arguments ..
1151  DOUBLE PRECISION a(nelt)
1152  INTEGER ia(nelt), ja(nelt)
1153 C .. Local Scalars ..
1154  DOUBLE PRECISION temp
1155  INTEGER i, ibgn, icol, iend, itemp, j
1156 C .. External Subroutines ..
1157  EXTERNAL qs2i1d
1158 C***FIRST EXECUTABLE STATEMENT DS2Y
1159 C
1160 C Check to see if the (IA,JA,A) arrays are in SLAP Column
1161 C format. If it's not then transform from SLAP Triad.
1162 C
1163  IF( ja(n+1).EQ.nelt+1 ) RETURN
1164 C
1165 C Sort into ascending order by COLUMN (on the ja array).
1166 C This will line up the columns.
1167 C
1168  CALL qs2i1d( ja, ia, a, nelt, 1 )
1169 C
1170 C Loop over each column to see where the column indices change
1171 C in the column index array ja. This marks the beginning of the
1172 C next column.
1173 C
1174 CVD$R NOVECTOR
1175  ja(1) = 1
1176  DO 20 icol = 1, n-1
1177  DO 10 j = ja(icol)+1, nelt
1178  IF( ja(j).NE.icol ) THEN
1179  ja(icol+1) = j
1180  GOTO 20
1181  ENDIF
1182  10 CONTINUE
1183  20 CONTINUE
1184  ja(n+1) = nelt+1
1185 C
1186 C Mark the n+2 element so that future calls to a SLAP routine
1187 C utilizing the YSMP-Column storage format will be able to tell.
1188 C
1189  ja(n+2) = 0
1190 C
1191 C Now loop through the IA array making sure that the diagonal
1192 C matrix element appears first in the column. Then sort the
1193 C rest of the column in ascending order.
1194 C
1195  DO 70 icol = 1, n
1196  ibgn = ja(icol)
1197  iend = ja(icol+1)-1
1198  DO 30 i = ibgn, iend
1199  IF( ia(i).EQ.icol ) THEN
1200 C
1201 C Swap the diagonal element with the first element in the
1202 C column.
1203 C
1204  itemp = ia(i)
1205  ia(i) = ia(ibgn)
1206  ia(ibgn) = itemp
1207  temp = a(i)
1208  a(i) = a(ibgn)
1209  a(ibgn) = temp
1210  GOTO 40
1211  ENDIF
1212  30 CONTINUE
1213  40 ibgn = ibgn + 1
1214  IF( ibgn.LT.iend ) THEN
1215  DO 60 i = ibgn, iend
1216  DO 50 j = i+1, iend
1217  IF( ia(i).GT.ia(j) ) THEN
1218  itemp = ia(i)
1219  ia(i) = ia(j)
1220  ia(j) = itemp
1221  temp = a(i)
1222  a(i) = a(j)
1223  a(j) = temp
1224  ENDIF
1225  50 CONTINUE
1226  60 CONTINUE
1227  ENDIF
1228  70 CONTINUE
1229  RETURN
1230 C------------- LAST LINE OF DS2Y FOLLOWS ----------------------------
subroutine qs2i1d(IA, JA, A, N, KFLAG)
Definition: dslugm.f:1595

◆ dsilus()

subroutine dsilus ( integer  N,
integer  NELT,
integer, dimension(nelt)  IA,
integer, dimension(nelt)  JA,
double precision, dimension(nelt)  A,
integer  ISYM,
integer  NL,
integer, dimension(nl)  IL,
integer, dimension(nl)  JL,
double precision, dimension(nl)  L,
double precision, dimension(n)  DINV,
integer  NU,
integer, dimension(nu)  IU,
integer, dimension(nu)  JU,
double precision, dimension(nu)  U,
integer, dimension(n)  NROW,
integer, dimension(n)  NCOL 
)
1235 C***BEGIN PROLOGUE DSILUS
1236 C***PURPOSE Incomplete LU Decomposition Preconditioner SLAP Set Up.
1237 C Routine to generate the incomplete LDU decomposition of a
1238 C matrix. The unit lower triangular factor L is stored by
1239 C rows and the unit upper triangular factor U is stored by
1240 C columns. The inverse of the diagonal matrix D is stored.
1241 C No fill in is allowed.
1242 C***LIBRARY SLATEC (SLAP)
1243 C***CATEGORY D2E
1244 C***TYPE DOUBLE PRECISION (SSILUS-S, DSILUS-D)
1245 C***KEYWORDS INCOMPLETE LU FACTORIZATION, ITERATIVE PRECONDITION,
1246 C NON-SYMMETRIC LINEAR SYSTEM, SLAP, SPARSE
1247 C***AUTHOR Greenbaum, Anne, (Courant Institute)
1248 C Seager, Mark K., (LLNL)
1249 C Lawrence Livermore National Laboratory
1250 C PO BOX 808, L-60
1251 C Livermore, CA 94550 (510) 423-3141
1252 C seager@llnl.gov
1253 C***DESCRIPTION
1254 C
1255 C *Usage:
1256 C INTEGER N, NELT, IA(NELT), JA(NELT), ISYM
1257 C INTEGER NL, IL(NL), JL(NL), NU, IU(NU), JU(NU)
1258 C INTEGER NROW(N), NCOL(N)
1259 C DOUBLE PRECISION A(NELT), L(NL), DINV(N), U(NU)
1260 C
1261 C CALL DSILUS( N, NELT, IA, JA, A, ISYM, NL, IL, JL, L,
1262 C $ DINV, NU, IU, JU, U, NROW, NCOL )
1263 C
1264 C *Arguments:
1265 C N :IN Integer
1266 C Order of the Matrix.
1267 C NELT :IN Integer.
1268 C Number of elements in arrays IA, JA, and A.
1269 C IA :IN Integer IA(NELT).
1270 C JA :IN Integer JA(NELT).
1271 C A :IN Double Precision A(NELT).
1272 C These arrays should hold the matrix A in the SLAP Column
1273 C format. See "Description", below.
1274 C ISYM :IN Integer.
1275 C Flag to indicate symmetric storage format.
1276 C If ISYM=0, all non-zero entries of the matrix are stored.
1277 C If ISYM=1, the matrix is symmetric, and only the lower
1278 C triangle of the matrix is stored.
1279 C NL :OUT Integer.
1280 C Number of non-zeros in the L array.
1281 C IL :OUT Integer IL(NL).
1282 C JL :OUT Integer JL(NL).
1283 C L :OUT Double Precision L(NL).
1284 C IL, JL, L contain the unit lower triangular factor of the
1285 C incomplete decomposition of some matrix stored in SLAP
1286 C Row format. The Diagonal of ones *IS* stored. See
1287 C "DESCRIPTION", below for more details about the SLAP format.
1288 C NU :OUT Integer.
1289 C Number of non-zeros in the U array.
1290 C IU :OUT Integer IU(NU).
1291 C JU :OUT Integer JU(NU).
1292 C U :OUT Double Precision U(NU).
1293 C IU, JU, U contain the unit upper triangular factor of the
1294 C incomplete decomposition of some matrix stored in SLAP
1295 C Column format. The Diagonal of ones *IS* stored. See
1296 C "Description", below for more details about the SLAP
1297 C format.
1298 C NROW :WORK Integer NROW(N).
1299 C NROW(I) is the number of non-zero elements in the I-th row
1300 C of L.
1301 C NCOL :WORK Integer NCOL(N).
1302 C NCOL(I) is the number of non-zero elements in the I-th
1303 C column of U.
1304 C
1305 C *Description
1306 C IL, JL, L should contain the unit lower triangular factor of
1307 C the incomplete decomposition of the A matrix stored in SLAP
1308 C Row format. IU, JU, U should contain the unit upper factor
1309 C of the incomplete decomposition of the A matrix stored in
1310 C SLAP Column format This ILU factorization can be computed by
1311 C the DSILUS routine. The diagonals (which are all one's) are
1312 C stored.
1313 C
1314 C =================== S L A P Column format ==================
1315 C
1316 C This routine requires that the matrix A be stored in the
1317 C SLAP Column format. In this format the non-zeros are stored
1318 C counting down columns (except for the diagonal entry, which
1319 C must appear first in each "column") and are stored in the
1320 C double precision array A. In other words, for each column
1321 C in the matrix put the diagonal entry in A. Then put in the
1322 C other non-zero elements going down the column (except the
1323 C diagonal) in order. The IA array holds the row index for
1324 C each non-zero. The JA array holds the offsets into the IA,
1325 C A arrays for the beginning of each column. That is,
1326 C IA(JA(ICOL)), A(JA(ICOL)) points to the beginning of the
1327 C ICOL-th column in IA and A. IA(JA(ICOL+1)-1),
1328 C A(JA(ICOL+1)-1) points to the end of the ICOL-th column.
1329 C Note that we always have JA(N+1) = NELT+1, where N is the
1330 C number of columns in the matrix and NELT is the number of
1331 C non-zeros in the matrix.
1332 C
1333 C Here is an example of the SLAP Column storage format for a
1334 C 5x5 Matrix (in the A and IA arrays '|' denotes the end of a
1335 C column):
1336 C
1337 C 5x5 Matrix SLAP Column format for 5x5 matrix on left.
1338 C 1 2 3 4 5 6 7 8 9 10 11
1339 C |11 12 0 0 15| A: 11 21 51 | 22 12 | 33 53 | 44 | 55 15 35
1340 C |21 22 0 0 0| IA: 1 2 5 | 2 1 | 3 5 | 4 | 5 1 3
1341 C | 0 0 33 0 35| JA: 1 4 6 8 9 12
1342 C | 0 0 0 44 0|
1343 C |51 0 53 0 55|
1344 C
1345 C ==================== S L A P Row format ====================
1346 C
1347 C This routine requires that the matrix A be stored in the
1348 C SLAP Row format. In this format the non-zeros are stored
1349 C counting across rows (except for the diagonal entry, which
1350 C must appear first in each "row") and are stored in the
1351 C double precision array A. In other words, for each row in
1352 C the matrix put the diagonal entry in A. Then put in the
1353 C other non-zero elements going across the row (except the
1354 C diagonal) in order. The JA array holds the column index for
1355 C each non-zero. The IA array holds the offsets into the JA,
1356 C A arrays for the beginning of each row. That is,
1357 C JA(IA(IROW)),A(IA(IROW)) are the first elements of the IROW-
1358 C th row in JA and A, and JA(IA(IROW+1)-1), A(IA(IROW+1)-1)
1359 C are the last elements of the IROW-th row. Note that we
1360 C always have IA(N+1) = NELT+1, where N is the number of rows
1361 C in the matrix and NELT is the number of non-zeros in the
1362 C matrix.
1363 C
1364 C Here is an example of the SLAP Row storage format for a 5x5
1365 C Matrix (in the A and JA arrays '|' denotes the end of a row):
1366 C
1367 C 5x5 Matrix SLAP Row format for 5x5 matrix on left.
1368 C 1 2 3 4 5 6 7 8 9 10 11
1369 C |11 12 0 0 15| A: 11 12 15 | 22 21 | 33 35 | 44 | 55 51 53
1370 C |21 22 0 0 0| JA: 1 2 5 | 2 1 | 3 5 | 4 | 5 1 3
1371 C | 0 0 33 0 35| IA: 1 4 6 8 9 12
1372 C | 0 0 0 44 0|
1373 C |51 0 53 0 55|
1374 C
1375 C***SEE ALSO SILUR
1376 C***REFERENCES 1. Gene Golub and Charles Van Loan, Matrix Computations,
1377 C Johns Hopkins University Press, Baltimore, Maryland,
1378 C 1983.
1379 C***ROUTINES CALLED (NONE)
1380 C***REVISION HISTORY (YYMMDD)
1381 C 890404 DATE WRITTEN
1382 C 890404 Previous REVISION DATE
1383 C 890915 Made changes requested at July 1989 CML Meeting. (MKS)
1384 C 890922 Numerous changes to prologue to make closer to SLATEC
1385 C standard. (FNF)
1386 C 890929 Numerous changes to reduce SP/DP differences. (FNF)
1387 C 910411 Prologue converted to Version 4.0 format. (BAB)
1388 C 920511 Added complete declaration section. (WRB)
1389 C 920929 Corrected format of reference. (FNF)
1390 C 930701 Updated CATEGORY section. (FNF, WRB)
1391 C***END PROLOGUE DSILUS
1392 C .. Scalar Arguments ..
1393  INTEGER isym, n, nelt, nl, nu
1394 C .. Array Arguments ..
1395  DOUBLE PRECISION a(nelt), dinv(n), l(nl), u(nu)
1396  INTEGER ia(nelt), il(nl), iu(nu), ja(nelt), jl(nl), ju(nu),
1397  + ncol(n), nrow(n)
1398 C .. Local Scalars ..
1399  DOUBLE PRECISION temp
1400  INTEGER i, ibgn, icol, iend, indx, indx1, indx2, indxc1, indxc2,
1401  + indxr1, indxr2, irow, itemp, j, jbgn, jend, jtemp, k, kc,
1402  + kr
1403 C***FIRST EXECUTABLE STATEMENT DSILUS
1404 C
1405 C Count number of elements in each row of the lower triangle.
1406 C
1407  DO 10 i=1,n
1408  nrow(i) = 0
1409  ncol(i) = 0
1410  10 CONTINUE
1411 CVD$R NOCONCUR
1412 CVD$R NOVECTOR
1413  DO 30 icol = 1, n
1414  jbgn = ja(icol)+1
1415  jend = ja(icol+1)-1
1416  IF( jbgn.LE.jend ) THEN
1417  DO 20 j = jbgn, jend
1418  IF( ia(j).LT.icol ) THEN
1419  ncol(icol) = ncol(icol) + 1
1420  ELSE
1421  nrow(ia(j)) = nrow(ia(j)) + 1
1422  IF( isym.NE.0 ) ncol(ia(j)) = ncol(ia(j)) + 1
1423  ENDIF
1424  20 CONTINUE
1425  ENDIF
1426  30 CONTINUE
1427  ju(1) = 1
1428  il(1) = 1
1429  DO 40 icol = 1, n
1430  il(icol+1) = il(icol) + nrow(icol)
1431  ju(icol+1) = ju(icol) + ncol(icol)
1432  nrow(icol) = il(icol)
1433  ncol(icol) = ju(icol)
1434  40 CONTINUE
1435 C
1436 C Copy the matrix A into the L and U structures.
1437  DO 60 icol = 1, n
1438  dinv(icol) = a(ja(icol))
1439  jbgn = ja(icol)+1
1440  jend = ja(icol+1)-1
1441  IF( jbgn.LE.jend ) THEN
1442  DO 50 j = jbgn, jend
1443  irow = ia(j)
1444  IF( irow.LT.icol ) THEN
1445 C Part of the upper triangle.
1446  iu(ncol(icol)) = irow
1447  u(ncol(icol)) = a(j)
1448  ncol(icol) = ncol(icol) + 1
1449  ELSE
1450 C Part of the lower triangle (stored by row).
1451  jl(nrow(irow)) = icol
1452  l(nrow(irow)) = a(j)
1453  nrow(irow) = nrow(irow) + 1
1454  IF( isym.NE.0 ) THEN
1455 C Symmetric...Copy lower triangle into upper triangle as well.
1456  iu(ncol(irow)) = icol
1457  u(ncol(irow)) = a(j)
1458  ncol(irow) = ncol(irow) + 1
1459  ENDIF
1460  ENDIF
1461  50 CONTINUE
1462  ENDIF
1463  60 CONTINUE
1464 C
1465 C Sort the rows of L and the columns of U.
1466  DO 110 k = 2, n
1467  jbgn = ju(k)
1468  jend = ju(k+1)-1
1469  IF( jbgn.LT.jend ) THEN
1470  DO 80 j = jbgn, jend-1
1471  DO 70 i = j+1, jend
1472  IF( iu(j).GT.iu(i) ) THEN
1473  itemp = iu(j)
1474  iu(j) = iu(i)
1475  iu(i) = itemp
1476  temp = u(j)
1477  u(j) = u(i)
1478  u(i) = temp
1479  ENDIF
1480  70 CONTINUE
1481  80 CONTINUE
1482  ENDIF
1483  ibgn = il(k)
1484  iend = il(k+1)-1
1485  IF( ibgn.LT.iend ) THEN
1486  DO 100 i = ibgn, iend-1
1487  DO 90 j = i+1, iend
1488  IF( jl(i).GT.jl(j) ) THEN
1489  jtemp = ju(i)
1490  ju(i) = ju(j)
1491  ju(j) = jtemp
1492  temp = l(i)
1493  l(i) = l(j)
1494  l(j) = temp
1495  ENDIF
1496  90 CONTINUE
1497  100 CONTINUE
1498  ENDIF
1499  110 CONTINUE
1500 C
1501 C Perform the incomplete LDU decomposition.
1502  DO 300 i=2,n
1503 C
1504 C I-th row of L
1505  indx1 = il(i)
1506  indx2 = il(i+1) - 1
1507  IF(indx1 .GT. indx2) GO TO 200
1508  DO 190 indx=indx1,indx2
1509  IF(indx .EQ. indx1) GO TO 180
1510  indxr1 = indx1
1511  indxr2 = indx - 1
1512  indxc1 = ju(jl(indx))
1513  indxc2 = ju(jl(indx)+1) - 1
1514  IF(indxc1 .GT. indxc2) GO TO 180
1515  160 kr = jl(indxr1)
1516  170 kc = iu(indxc1)
1517  IF(kr .GT. kc) THEN
1518  indxc1 = indxc1 + 1
1519  IF(indxc1 .LE. indxc2) GO TO 170
1520  ELSEIF(kr .LT. kc) THEN
1521  indxr1 = indxr1 + 1
1522  IF(indxr1 .LE. indxr2) GO TO 160
1523  ELSEIF(kr .EQ. kc) THEN
1524  l(indx) = l(indx) - l(indxr1)*dinv(kc)*u(indxc1)
1525  indxr1 = indxr1 + 1
1526  indxc1 = indxc1 + 1
1527  IF(indxr1 .LE. indxr2 .AND. indxc1 .LE. indxc2) GO TO 160
1528  ENDIF
1529  180 l(indx) = l(indx)/dinv(jl(indx))
1530  190 CONTINUE
1531 C
1532 C I-th column of U
1533  200 indx1 = ju(i)
1534  indx2 = ju(i+1) - 1
1535  IF(indx1 .GT. indx2) GO TO 260
1536  DO 250 indx=indx1,indx2
1537  IF(indx .EQ. indx1) GO TO 240
1538  indxc1 = indx1
1539  indxc2 = indx - 1
1540  indxr1 = il(iu(indx))
1541  indxr2 = il(iu(indx)+1) - 1
1542  IF(indxr1 .GT. indxr2) GO TO 240
1543  210 kr = jl(indxr1)
1544  220 kc = iu(indxc1)
1545  IF(kr .GT. kc) THEN
1546  indxc1 = indxc1 + 1
1547  IF(indxc1 .LE. indxc2) GO TO 220
1548  ELSEIF(kr .LT. kc) THEN
1549  indxr1 = indxr1 + 1
1550  IF(indxr1 .LE. indxr2) GO TO 210
1551  ELSEIF(kr .EQ. kc) THEN
1552  u(indx) = u(indx) - l(indxr1)*dinv(kc)*u(indxc1)
1553  indxr1 = indxr1 + 1
1554  indxc1 = indxc1 + 1
1555  IF(indxr1 .LE. indxr2 .AND. indxc1 .LE. indxc2) GO TO 210
1556  ENDIF
1557  240 u(indx) = u(indx)/dinv(iu(indx))
1558  250 CONTINUE
1559 C
1560 C I-th diagonal element
1561  260 indxr1 = il(i)
1562  indxr2 = il(i+1) - 1
1563  IF(indxr1 .GT. indxr2) GO TO 300
1564  indxc1 = ju(i)
1565  indxc2 = ju(i+1) - 1
1566  IF(indxc1 .GT. indxc2) GO TO 300
1567  270 kr = jl(indxr1)
1568  280 kc = iu(indxc1)
1569  IF(kr .GT. kc) THEN
1570  indxc1 = indxc1 + 1
1571  IF(indxc1 .LE. indxc2) GO TO 280
1572  ELSEIF(kr .LT. kc) THEN
1573  indxr1 = indxr1 + 1
1574  IF(indxr1 .LE. indxr2) GO TO 270
1575  ELSEIF(kr .EQ. kc) THEN
1576  dinv(i) = dinv(i) - l(indxr1)*dinv(kc)*u(indxc1)
1577  indxr1 = indxr1 + 1
1578  indxc1 = indxc1 + 1
1579  IF(indxr1 .LE. indxr2 .AND. indxc1 .LE. indxc2) GO TO 270
1580  ENDIF
1581 C
1582  300 CONTINUE
1583 C
1584 C Replace diagonal elements by their inverses.
1585 CVD$ VECTOR
1586  DO 430 i=1,n
1587  dinv(i) = 1.0d0/dinv(i)
1588  430 CONTINUE
1589 C
1590  RETURN
1591 C------------- LAST LINE OF DSILUS FOLLOWS ----------------------------

◆ dslugm()

subroutine dslugm ( integer  N,
double precision, dimension(n)  B,
double precision, dimension(n)  X,
integer  NELT,
integer, dimension(nelt)  IA,
integer, dimension(nelt)  JA,
double precision, dimension(nelt)  A,
integer  ISYM,
integer  NSAVE,
integer  ITOL,
double precision  TOL,
integer  ITMAX,
integer  ITER,
double precision  ERR,
integer  IERR,
integer  IUNIT,
double precision, dimension(lenw)  RWORK,
integer  LENW,
integer, dimension(leniw)  IWORK,
integer  LENIW 
)
4 C***BEGIN PROLOGUE DSLUGM
5 C***PURPOSE Incomplete LU GMRES iterative sparse Ax=b solver.
6 C This routine uses the generalized minimum residual
7 C (GMRES) method with incomplete LU factorization for
8 C preconditioning to solve possibly non-symmetric linear
9 C systems of the form: Ax = b.
10 C***LIBRARY SLATEC (SLAP)
11 C***CATEGORY D2A4, D2B4
12 C***TYPE DOUBLE PRECISION (SSLUGM-S, DSLUGM-D)
13 C***KEYWORDS GENERALIZED MINIMUM RESIDUAL, ITERATIVE PRECONDITION,
14 C NON-SYMMETRIC LINEAR SYSTEM, SLAP, SPARSE
15 C***AUTHOR Brown, Peter, (LLNL), pnbrown@llnl.gov
16 C Hindmarsh, Alan, (LLNL), alanh@llnl.gov
17 C Seager, Mark K., (LLNL), seager@llnl.gov
18 C Lawrence Livermore National Laboratory
19 C PO Box 808, L-60
20 C Livermore, CA 94550 (510) 423-3141
21 C***DESCRIPTION
22 C
23 C *Usage:
24 C INTEGER N, NELT, IA(NELT), JA(NELT), ISYM, NSAVE, ITOL
25 C INTEGER ITMAX, ITER, IERR, IUNIT, LENW, IWORK(LENIW), LENIW
26 C DOUBLE PRECISION B(N), X(N), A(NELT), TOL, ERR, RWORK(LENW)
27 C
28 C CALL DSLUGM(N, B, X, NELT, IA, JA, A, ISYM, NSAVE,
29 C $ ITOL, TOL, ITMAX, ITER, ERR, IERR, IUNIT,
30 C $ RWORK, LENW, IWORK, LENIW)
31 C
32 C *Arguments:
33 C N :IN Integer.
34 C Order of the Matrix.
35 C B :IN Double Precision B(N).
36 C Right-hand side vector.
37 C X :INOUT Double Precision X(N).
38 C On input X is your initial guess for solution vector.
39 C On output X is the final approximate solution.
40 C NELT :IN Integer.
41 C Number of Non-Zeros stored in A.
42 C IA :IN Integer IA(NELT).
43 C JA :IN Integer JA(NELT).
44 C A :IN Double Precision A(NELT).
45 C These arrays should hold the matrix A in either the SLAP
46 C Triad format or the SLAP Column format. See "Description",
47 C below. If the SLAP Triad format is chosen it is changed
48 C internally to the SLAP Column format.
49 C ISYM :IN Integer.
50 C Flag to indicate symmetric storage format.
51 C If ISYM=0, all non-zero entries of the matrix are stored.
52 C If ISYM=1, the matrix is symmetric, and only the upper
53 C or lower triangle of the matrix is stored.
54 C NSAVE :IN Integer.
55 C Number of direction vectors to save and orthogonalize against.
56 C Must be greater than 1.
57 C ITOL :IN Integer.
58 C Flag to indicate the type of convergence criterion used.
59 C ITOL=0 Means the iteration stops when the test described
60 C below on the residual RL is satisfied. This is
61 C the "Natural Stopping Criteria" for this routine.
62 C Other values of ITOL cause extra, otherwise
63 C unnecessary, computation per iteration and are
64 C therefore much less efficient. See ISDGMR (the
65 C stop test routine) for more information.
66 C ITOL=1 Means the iteration stops when the first test
67 C described below on the residual RL is satisfied,
68 C and there is either right or no preconditioning
69 C being used.
70 C ITOL=2 Implies that the user is using left
71 C preconditioning, and the second stopping criterion
72 C below is used.
73 C ITOL=3 Means the iteration stops when the third test
74 C described below on Minv*Residual is satisfied, and
75 C there is either left or no preconditioning begin
76 C used.
77 C ITOL=11 is often useful for checking and comparing
78 C different routines. For this case, the user must
79 C supply the "exact" solution or a very accurate
80 C approximation (one with an error much less than
81 C TOL) through a common block,
82 C COMMON /DSLBLK/ SOLN( )
83 C If ITOL=11, iteration stops when the 2-norm of the
84 C difference between the iterative approximation and
85 C the user-supplied solution divided by the 2-norm
86 C of the user-supplied solution is less than TOL.
87 C Note that this requires the user to set up the
88 C "COMMON /DSLBLK/ SOLN(LENGTH)" in the calling
89 C routine. The routine with this declaration should
90 C be loaded before the stop test so that the correct
91 C length is used by the loader. This procedure is
92 C not standard Fortran and may not work correctly on
93 C your system (although it has worked on every
94 C system the authors have tried). If ITOL is not 11
95 C then this common block is indeed standard Fortran.
96 C TOL :INOUT Double Precision.
97 C Convergence criterion, as described below. If TOL is set
98 C to zero on input, then a default value of 500*(the smallest
99 C positive magnitude, machine epsilon) is used.
100 C ITMAX :IN Integer.
101 C Maximum number of iterations. This routine uses the default
102 C of NRMAX = ITMAX/NSAVE to determine the when each restart
103 C should occur. See the description of NRMAX and MAXL in
104 C DGMRES for a full and frightfully interesting discussion of
105 C this topic.
106 C ITER :OUT Integer.
107 C Number of iterations required to reach convergence, or
108 C ITMAX+1 if convergence criterion could not be achieved in
109 C ITMAX iterations.
110 C ERR :OUT Double Precision.
111 C Error estimate of error in final approximate solution, as
112 C defined by ITOL. Letting norm() denote the Euclidean
113 C norm, ERR is defined as follows...
114 C If ITOL=0, then ERR = norm(SB*(B-A*X(L)))/norm(SB*B),
115 C for right or no preconditioning, and
116 C ERR = norm(SB*(M-inverse)*(B-A*X(L)))/
117 C norm(SB*(M-inverse)*B),
118 C for left preconditioning.
119 C If ITOL=1, then ERR = norm(SB*(B-A*X(L)))/norm(SB*B),
120 C since right or no preconditioning
121 C being used.
122 C If ITOL=2, then ERR = norm(SB*(M-inverse)*(B-A*X(L)))/
123 C norm(SB*(M-inverse)*B),
124 C since left preconditioning is being
125 C used.
126 C If ITOL=3, then ERR = Max |(Minv*(B-A*X(L)))(i)/x(i)|
127 C i=1,n
128 C If ITOL=11, then ERR = norm(SB*(X(L)-SOLN))/norm(SB*SOLN).
129 C IERR :OUT Integer.
130 C Return error flag.
131 C IERR = 0 => All went well.
132 C IERR = 1 => Insufficient storage allocated for
133 C RGWK or IGWK.
134 C IERR = 2 => Routine DPIGMR failed to reduce the norm
135 C of the current residual on its last call,
136 C and so the iteration has stalled. In
137 C this case, X equals the last computed
138 C approximation. The user must either
139 C increase MAXL, or choose a different
140 C initial guess.
141 C IERR =-1 => Insufficient length for RGWK array.
142 C IGWK(6) contains the required minimum
143 C length of the RGWK array.
144 C IERR =-2 => Inconsistent ITOL and JPRE values.
145 C For IERR <= 2, RGWK(1) = RHOL, which is the norm on the
146 C left-hand-side of the relevant stopping test defined
147 C below associated with the residual for the current
148 C approximation X(L).
149 C IUNIT :IN Integer.
150 C Unit number on which to write the error at each iteration,
151 C if this is desired for monitoring convergence. If unit
152 C number is 0, no writing will occur.
153 C RWORK :WORK Double Precision RWORK(LENW).
154 C Double Precision array of size LENW.
155 C LENW :IN Integer.
156 C Length of the double precision workspace, RWORK.
157 C LENW >= 1 + N*(NSAVE+7) + NSAVE*(NSAVE+3)+NL+NU.
158 C Here NL is the number of non-zeros in the lower triangle of
159 C the matrix (including the diagonal) and NU is the number of
160 C non-zeros in the upper triangle of the matrix (including the
161 C diagonal).
162 C For the recommended values, RWORK has size at least
163 C 131 + 17*N + NL + NU.
164 C IWORK :INOUT Integer IWORK(LENIW).
165 C Used to hold pointers into the RWORK array.
166 C Upon return the following locations of IWORK hold information
167 C which may be of use to the user:
168 C IWORK(9) Amount of Integer workspace actually used.
169 C IWORK(10) Amount of Double Precision workspace actually used.
170 C LENIW :IN Integer.
171 C Length of the integer workspace, IWORK.
172 C LENIW >= NL+NU+4*N+32.
173 C
174 C *Description:
175 C DSLUGM solves a linear system A*X = B rewritten in the form:
176 C
177 C (SB*A*(M-inverse)*(SX-inverse))*(SX*M*X) = SB*B,
178 C
179 C with right preconditioning, or
180 C
181 C (SB*(M-inverse)*A*(SX-inverse))*(SX*X) = SB*(M-inverse)*B,
182 C
183 C with left preconditioning, where A is an n-by-n double precision
184 C matrix, X and B are N-vectors, SB and SX are diagonal scaling
185 C matrices, and M is the Incomplete LU factorization of A. It
186 C uses preconditioned Krylov subpace methods based on the
187 C generalized minimum residual method (GMRES). This routine
188 C is a driver routine which assumes a SLAP matrix data
189 C structure and sets up the necessary information to do
190 C diagonal preconditioning and calls the main GMRES routine
191 C DGMRES for the solution of the linear system. DGMRES
192 C optionally performs either the full orthogonalization
193 C version of the GMRES algorithm or an incomplete variant of
194 C it. Both versions use restarting of the linear iteration by
195 C default, although the user can disable this feature.
196 C
197 C The GMRES algorithm generates a sequence of approximations
198 C X(L) to the true solution of the above linear system. The
199 C convergence criteria for stopping the iteration is based on
200 C the size of the scaled norm of the residual R(L) = B -
201 C A*X(L). The actual stopping test is either:
202 C
203 C norm(SB*(B-A*X(L))) .le. TOL*norm(SB*B),
204 C
205 C for right preconditioning, or
206 C
207 C norm(SB*(M-inverse)*(B-A*X(L))) .le.
208 C TOL*norm(SB*(M-inverse)*B),
209 C
210 C for left preconditioning, where norm() denotes the Euclidean
211 C norm, and TOL is a positive scalar less than one input by
212 C the user. If TOL equals zero when DSLUGM is called, then a
213 C default value of 500*(the smallest positive magnitude,
214 C machine epsilon) is used. If the scaling arrays SB and SX
215 C are used, then ideally they should be chosen so that the
216 C vectors SX*X(or SX*M*X) and SB*B have all their components
217 C approximately equal to one in magnitude. If one wants to
218 C use the same scaling in X and B, then SB and SX can be the
219 C same array in the calling program.
220 C
221 C The following is a list of the other routines and their
222 C functions used by GMRES:
223 C DGMRES Contains the matrix structure independent driver
224 C routine for GMRES.
225 C DPIGMR Contains the main iteration loop for GMRES.
226 C DORTH Orthogonalizes a new vector against older basis vectors.
227 C DHEQR Computes a QR decomposition of a Hessenberg matrix.
228 C DHELS Solves a Hessenberg least-squares system, using QR
229 C factors.
230 C RLCALC Computes the scaled residual RL.
231 C XLCALC Computes the solution XL.
232 C ISDGMR User-replaceable stopping routine.
233 C
234 C The Sparse Linear Algebra Package (SLAP) utilizes two matrix
235 C data structures: 1) the SLAP Triad format or 2) the SLAP
236 C Column format. The user can hand this routine either of the
237 C of these data structures and SLAP will figure out which on
238 C is being used and act accordingly.
239 C
240 C =================== S L A P Triad format ===================
241 C This routine requires that the matrix A be stored in the
242 C SLAP Triad format. In this format only the non-zeros are
243 C stored. They may appear in *ANY* order. The user supplies
244 C three arrays of length NELT, where NELT is the number of
245 C non-zeros in the matrix: (IA(NELT), JA(NELT), A(NELT)). For
246 C each non-zero the user puts the row and column index of that
247 C matrix element in the IA and JA arrays. The value of the
248 C non-zero matrix element is placed in the corresponding
249 C location of the A array. This is an extremely easy data
250 C structure to generate. On the other hand it is not too
251 C efficient on vector computers for the iterative solution of
252 C linear systems. Hence, SLAP changes this input data
253 C structure to the SLAP Column format for the iteration (but
254 C does not change it back).
255 C
256 C Here is an example of the SLAP Triad storage format for a
257 C 5x5 Matrix. Recall that the entries may appear in any order.
258 C
259 C 5x5 Matrix SLAP Triad format for 5x5 matrix on left.
260 C 1 2 3 4 5 6 7 8 9 10 11
261 C |11 12 0 0 15| A: 51 12 11 33 15 53 55 22 35 44 21
262 C |21 22 0 0 0| IA: 5 1 1 3 1 5 5 2 3 4 2
263 C | 0 0 33 0 35| JA: 1 2 1 3 5 3 5 2 5 4 1
264 C | 0 0 0 44 0|
265 C |51 0 53 0 55|
266 C
267 C =================== S L A P Column format ==================
268 C
269 C This routine requires that the matrix A be stored in the
270 C SLAP Column format. In this format the non-zeros are stored
271 C counting down columns (except for the diagonal entry, which
272 C must appear first in each "column") and are stored in the
273 C double precision array A. In other words, for each column
274 C in the matrix put the diagonal entry in A. Then put in the
275 C other non-zero elements going down the column (except the
276 C diagonal) in order. The IA array holds the row index for
277 C each non-zero. The JA array holds the offsets into the IA,
278 C A arrays for the beginning of each column. That is,
279 C IA(JA(ICOL)), A(JA(ICOL)) points to the beginning of the
280 C ICOL-th column in IA and A. IA(JA(ICOL+1)-1),
281 C A(JA(ICOL+1)-1) points to the end of the ICOL-th column.
282 C Note that we always have JA(N+1) = NELT+1, where N is the
283 C number of columns in the matrix and NELT is the number of
284 C non-zeros in the matrix.
285 C
286 C Here is an example of the SLAP Column storage format for a
287 C 5x5 Matrix (in the A and IA arrays '|' denotes the end of a
288 C column):
289 C
290 C 5x5 Matrix SLAP Column format for 5x5 matrix on left.
291 C 1 2 3 4 5 6 7 8 9 10 11
292 C |11 12 0 0 15| A: 11 21 51 | 22 12 | 33 53 | 44 | 55 15 35
293 C |21 22 0 0 0| IA: 1 2 5 | 2 1 | 3 5 | 4 | 5 1 3
294 C | 0 0 33 0 35| JA: 1 4 6 8 9 12
295 C | 0 0 0 44 0|
296 C |51 0 53 0 55|
297 C
298 C *Side Effects:
299 C The SLAP Triad format (IA, JA, A) is modified internally to be
300 C the SLAP Column format. See above.
301 C
302 C *Cautions:
303 C This routine will attempt to write to the Fortran logical output
304 C unit IUNIT, if IUNIT .ne. 0. Thus, the user must make sure that
305 C this logical unit is attached to a file or terminal before calling
306 C this routine with a non-zero value for IUNIT. This routine does
307 C not check for the validity of a non-zero IUNIT unit number.
308 C
309 C***REFERENCES 1. Peter N. Brown and A. C. Hindmarsh, Reduced Storage
310 C Matrix Methods in Stiff ODE Systems, Lawrence Liver-
311 C more National Laboratory Report UCRL-95088, Rev. 1,
312 C Livermore, California, June 1987.
313 C***ROUTINES CALLED DCHKW, DGMRES, DS2Y, DSILUS, DSLUI, DSMV
314 C***REVISION HISTORY (YYMMDD)
315 C 890404 DATE WRITTEN
316 C 890404 Previous REVISION DATE
317 C 890915 Made changes requested at July 1989 CML Meeting. (MKS)
318 C 890922 Numerous changes to prologue to make closer to SLATEC
319 C standard. (FNF)
320 C 890929 Numerous changes to reduce SP/DP differences. (FNF)
321 C 910411 Prologue converted to Version 4.0 format. (BAB)
322 C 920407 COMMON BLOCK renamed DSLBLK. (WRB)
323 C 920511 Added complete declaration section. (WRB)
324 C 920929 Corrected format of references. (FNF)
325 C 921019 Corrected NEL to NL. (FNF)
326 C***END PROLOGUE DSLUGM
327 C The following is for optimized compilation on LLNL/LTSS Crays.
328 CLLL. OPTIMIZE
329 C .. Parameters ..
330  INTEGER locrb, locib
331  parameter(locrb=1, locib=11)
332 C .. Scalar Arguments ..
333  DOUBLE PRECISION err, tol
334  INTEGER ierr, isym, iter, itmax, itol, iunit, leniw, lenw, n,
335  + nelt, nsave
336 C .. Array Arguments ..
337  DOUBLE PRECISION a(nelt), b(n), rwork(lenw), x(n)
338  INTEGER ia(nelt), iwork(leniw), ja(nelt)
339 C .. Local Scalars ..
340  INTEGER icol, j, jbgn, jend, locdin, locigw, locil, lociu, lociw,
341  + locjl, locju, locl, locnc, locnr, locrgw, locu, locw,
342  + myitol, nl, nu
343 C .. External Subroutines ..
344  EXTERNAL dchkw, dgmres, ds2y, dsilus, dslui, dsmv
345 C***FIRST EXECUTABLE STATEMENT DSLUGM
346 C
347  ierr = 0
348  err = 0
349  IF( nsave.LE.1 ) THEN
350  ierr = 3
351  RETURN
352  ENDIF
353 C
354 C Change the SLAP input matrix IA, JA, A to SLAP-Column format.
355  CALL ds2y( n, nelt, ia, ja, a, isym )
356 C
357 C Count number of Non-Zero elements preconditioner ILU matrix.
358 C Then set up the work arrays. We assume MAXL=KMP=NSAVE.
359  nl = 0
360  nu = 0
361  DO 20 icol = 1, n
362 C Don't count diagonal.
363  jbgn = ja(icol)+1
364  jend = ja(icol+1)-1
365  IF( jbgn.LE.jend ) THEN
366 CVD$ NOVECTOR
367  DO 10 j = jbgn, jend
368  IF( ia(j).GT.icol ) THEN
369  nl = nl + 1
370  IF( isym.NE.0 ) nu = nu + 1
371  ELSE
372  nu = nu + 1
373  ENDIF
374  10 CONTINUE
375  ENDIF
376  20 CONTINUE
377 C
378  locigw = locib
379  locil = locigw + 20
380  locjl = locil + n+1
381  lociu = locjl + nl
382  locju = lociu + nu
383  locnr = locju + n+1
384  locnc = locnr + n
385  lociw = locnc + n
386 C
387  locl = locrb
388  locdin = locl + nl
389  locu = locdin + n
390  locrgw = locu + nu
391  locw = locrgw + 1+n*(nsave+6)+nsave*(nsave+3)
392 C
393 C Check the workspace allocations.
394  CALL dchkw( 'DSLUGM', lociw, leniw, locw, lenw, ierr, iter, err )
395  IF( ierr.NE.0 ) RETURN
396 C
397  iwork(1) = locil
398  iwork(2) = locjl
399  iwork(3) = lociu
400  iwork(4) = locju
401  iwork(5) = locl
402  iwork(6) = locdin
403  iwork(7) = locu
404  iwork(9) = lociw
405  iwork(10) = locw
406 C
407 C Compute the Incomplete LU decomposition.
408  CALL dsilus( n, nelt, ia, ja, a, isym, nl, iwork(locil),
409  $ iwork(locjl), rwork(locl), rwork(locdin), nu, iwork(lociu),
410  $ iwork(locju), rwork(locu), iwork(locnr), iwork(locnc) )
411 C
412 C Perform the Incomplete LU Preconditioned Generalized Minimum
413 C Residual iteration algorithm. The following DGMRES
414 C defaults are used MAXL = KMP = NSAVE, JSCAL = 0,
415 C JPRE = -1, NRMAX = ITMAX/NSAVE
416  iwork(locigw ) = nsave
417  iwork(locigw+1) = nsave
418  iwork(locigw+2) = 0
419  iwork(locigw+3) = -1
420  iwork(locigw+4) = itmax/nsave
421  myitol = 0
422 C
423  CALL dgmres( n, b, x, nelt, ia, ja, a, isym, dsmv, dslui,
424  $ myitol, tol, itmax, iter, err, ierr, iunit, rwork, rwork,
425  $ rwork(locrgw), lenw-locrgw, iwork(locigw), 20,
426  $ rwork, iwork )
427 C
428  IF( iter.GT.itmax ) ierr = 2
429  RETURN
430 C------------- LAST LINE OF DSLUGM FOLLOWS ----------------------------
subroutine ds2y(N, NELT, IA, JA, A, ISYM)
Definition: dslugm.f:1025
subroutine dslui(N, B, X, NELT, IA, JA, A, ISYM, RWORK, IWORK)
Definition: dslugm.f:434
subroutine dchkw(NAME, LOCIW, LENIW, LOCW, LENW, IERR, ITER, ERR)
Definition: dslugm.f:913
subroutine dsmv(N, X, Y, NELT, IA, JA, A, ISYM)
Definition: dslugm.f:727
subroutine dgmres(N, B, X, NELT, IA, JA, A, ISYM, MATVEC, MSOLVE, ITOL, TOL, ITMAX, ITER, ERR, IERR, IUNIT, SB, SX, RGWK, LRGW, IGWK, LIGW, RWORK, IWORK)
Definition: dgmres.f:8
subroutine dsilus(N, NELT, IA, JA, A, ISYM, NL, IL, JL, L, DINV, NU, IU, JU, U, NROW, NCOL)
Definition: dslugm.f:1235

◆ dslui()

subroutine dslui ( integer  N,
double precision, dimension(n)  B,
double precision, dimension(n)  X,
integer  NELT,
integer, dimension(nelt)  IA,
integer, dimension(nelt)  JA,
double precision, dimension(nelt)  A,
integer  ISYM,
double precision, dimension(*)  RWORK,
integer, dimension(10)  IWORK 
)
434 C***BEGIN PROLOGUE DSLUI
435 C***PURPOSE SLAP MSOLVE for LDU Factorization.
436 C This routine acts as an interface between the SLAP generic
437 C MSOLVE calling convention and the routine that actually
438 C -1
439 C computes (LDU) B = X.
440 C***LIBRARY SLATEC (SLAP)
441 C***CATEGORY D2E
442 C***TYPE DOUBLE PRECISION (SSLUI-S, DSLUI-D)
443 C***KEYWORDS ITERATIVE PRECONDITION, NON-SYMMETRIC LINEAR SYSTEM SOLVE,
444 C SLAP, SPARSE
445 C***AUTHOR Greenbaum, Anne, (Courant Institute)
446 C Seager, Mark K., (LLNL)
447 C Lawrence Livermore National Laboratory
448 C PO BOX 808, L-60
449 C Livermore, CA 94550 (510) 423-3141
450 C seager@llnl.gov
451 C***DESCRIPTION
452 C It is assumed that RWORK and IWORK have initialized with
453 C the information required for DSLUI2:
454 C IWORK(1) = Starting location of IL in IWORK.
455 C IWORK(2) = Starting location of JL in IWORK.
456 C IWORK(3) = Starting location of IU in IWORK.
457 C IWORK(4) = Starting location of JU in IWORK.
458 C IWORK(5) = Starting location of L in RWORK.
459 C IWORK(6) = Starting location of DINV in RWORK.
460 C IWORK(7) = Starting location of U in RWORK.
461 C See the DESCRIPTION of DSLUI2 for details.
462 C***REFERENCES (NONE)
463 C***ROUTINES CALLED DSLUI2
464 C***REVISION HISTORY (YYMMDD)
465 C 871119 DATE WRITTEN
466 C 881213 Previous REVISION DATE
467 C 890915 Made changes requested at July 1989 CML Meeting. (MKS)
468 C 890922 Numerous changes to prologue to make closer to SLATEC
469 C standard. (FNF)
470 C 890929 Numerous changes to reduce SP/DP differences. (FNF)
471 C 910411 Prologue converted to Version 4.0 format. (BAB)
472 C 920511 Added complete declaration section. (WRB)
473 C 921113 Corrected C***CATEGORY line. (FNF)
474 C 930701 Updated CATEGORY section. (FNF, WRB)
475 C***END PROLOGUE DSLUI
476 C .. Scalar Arguments ..
477  INTEGER isym, n, nelt
478 C .. Array Arguments ..
479  DOUBLE PRECISION a(nelt), b(n), rwork(*), x(n)
480  INTEGER ia(nelt), iwork(10), ja(nelt)
481 C .. Local Scalars ..
482  INTEGER locdin, locil, lociu, locjl, locju, locl, locu
483 C .. External Subroutines ..
484  EXTERNAL dslui2
485 C***FIRST EXECUTABLE STATEMENT DSLUI
486 C
487 C Pull out the locations of the arrays holding the ILU
488 C factorization.
489 C
490  locil = iwork(1)
491  locjl = iwork(2)
492  lociu = iwork(3)
493  locju = iwork(4)
494  locl = iwork(5)
495  locdin = iwork(6)
496  locu = iwork(7)
497 C
498 C Solve the system LUx = b
499  CALL dslui2(n, b, x, iwork(locil), iwork(locjl), rwork(locl),
500  $ rwork(locdin), iwork(lociu), iwork(locju), rwork(locu) )
501 C
502  RETURN
503 C------------- LAST LINE OF DSLUI FOLLOWS ----------------------------
subroutine dslui2(N, B, X, IL, JL, L, DINV, IU, JU, U)
Definition: dslugm.f:507

◆ dslui2()

subroutine dslui2 ( integer  N,
double precision, dimension(n)  B,
double precision, dimension(n)  X,
integer, dimension(*)  IL,
integer, dimension(*)  JL,
double precision, dimension(*)  L,
double precision, dimension(n)  DINV,
integer, dimension(*)  IU,
integer, dimension(*)  JU,
double precision, dimension(*)  U 
)
507  use omp_lib
508 C***BEGIN PROLOGUE DSLUI2
509 C***PURPOSE SLAP Backsolve for LDU Factorization.
510 C Routine to solve a system of the form L*D*U X = B,
511 C where L is a unit lower triangular matrix, D is a diagonal
512 C matrix, and U is a unit upper triangular matrix.
513 C***LIBRARY SLATEC (SLAP)
514 C***CATEGORY D2E
515 C***TYPE DOUBLE PRECISION (SSLUI2-S, DSLUI2-D)
516 C***KEYWORDS ITERATIVE PRECONDITION, NON-SYMMETRIC LINEAR SYSTEM SOLVE,
517 C SLAP, SPARSE
518 C***AUTHOR Greenbaum, Anne, (Courant Institute)
519 C Seager, Mark K., (LLNL)
520 C Lawrence Livermore National Laboratory
521 C PO BOX 808, L-60
522 C Livermore, CA 94550 (510) 423-3141
523 C seager@llnl.gov
524 C***DESCRIPTION
525 C
526 C *Usage:
527 C INTEGER N, IL(NL), JL(NL), IU(NU), JU(NU)
528 C DOUBLE PRECISION B(N), X(N), L(NL), DINV(N), U(NU)
529 C
530 C CALL DSLUI2( N, B, X, IL, JL, L, DINV, IU, JU, U )
531 C
532 C *Arguments:
533 C N :IN Integer
534 C Order of the Matrix.
535 C B :IN Double Precision B(N).
536 C Right hand side.
537 C X :OUT Double Precision X(N).
538 C Solution of L*D*U x = b.
539 C IL :IN Integer IL(NL).
540 C JL :IN Integer JL(NL).
541 C L :IN Double Precision L(NL).
542 C IL, JL, L contain the unit lower triangular factor of the
543 C incomplete decomposition of some matrix stored in SLAP Row
544 C format. The diagonal of ones *IS* stored. This structure
545 C can be set up by the DSILUS routine. See the
546 C "Description", below for more details about the SLAP
547 C format. (NL is the number of non-zeros in the L array.)
548 C DINV :IN Double Precision DINV(N).
549 C Inverse of the diagonal matrix D.
550 C IU :IN Integer IU(NU).
551 C JU :IN Integer JU(NU).
552 C U :IN Double Precision U(NU).
553 C IU, JU, U contain the unit upper triangular factor of the
554 C incomplete decomposition of some matrix stored in SLAP
555 C Column format. The diagonal of ones *IS* stored. This
556 C structure can be set up by the DSILUS routine. See the
557 C "Description", below for more details about the SLAP
558 C format. (NU is the number of non-zeros in the U array.)
559 C
560 C *Description:
561 C This routine is supplied with the SLAP package as a routine
562 C to perform the MSOLVE operation in the SIR and SBCG
563 C iteration routines for the drivers DSILUR and DSLUBC. It
564 C must be called via the SLAP MSOLVE calling sequence
565 C convention interface routine DSLUI.
566 C **** THIS ROUTINE ITSELF DOES NOT CONFORM TO THE ****
567 C **** SLAP MSOLVE CALLING CONVENTION ****
568 C
569 C IL, JL, L should contain the unit lower triangular factor of
570 C the incomplete decomposition of the A matrix stored in SLAP
571 C Row format. IU, JU, U should contain the unit upper factor
572 C of the incomplete decomposition of the A matrix stored in
573 C SLAP Column format This ILU factorization can be computed by
574 C the DSILUS routine. The diagonals (which are all one's) are
575 C stored.
576 C
577 C =================== S L A P Column format ==================
578 C
579 C This routine requires that the matrix A be stored in the
580 C SLAP Column format. In this format the non-zeros are stored
581 C counting down columns (except for the diagonal entry, which
582 C must appear first in each "column") and are stored in the
583 C double precision array A. In other words, for each column
584 C in the matrix put the diagonal entry in A. Then put in the
585 C other non-zero elements going down the column (except the
586 C diagonal) in order. The IA array holds the row index for
587 C each non-zero. The JA array holds the offsets into the IA,
588 C A arrays for the beginning of each column. That is,
589 C IA(JA(ICOL)), A(JA(ICOL)) points to the beginning of the
590 C ICOL-th column in IA and A. IA(JA(ICOL+1)-1),
591 C A(JA(ICOL+1)-1) points to the end of the ICOL-th column.
592 C Note that we always have JA(N+1) = NELT+1, where N is the
593 C number of columns in the matrix and NELT is the number of
594 C non-zeros in the matrix.
595 C
596 C Here is an example of the SLAP Column storage format for a
597 C 5x5 Matrix (in the A and IA arrays '|' denotes the end of a
598 C column):
599 C
600 C 5x5 Matrix SLAP Column format for 5x5 matrix on left.
601 C 1 2 3 4 5 6 7 8 9 10 11
602 C |11 12 0 0 15| A: 11 21 51 | 22 12 | 33 53 | 44 | 55 15 35
603 C |21 22 0 0 0| IA: 1 2 5 | 2 1 | 3 5 | 4 | 5 1 3
604 C | 0 0 33 0 35| JA: 1 4 6 8 9 12
605 C | 0 0 0 44 0|
606 C |51 0 53 0 55|
607 C
608 C ==================== S L A P Row format ====================
609 C
610 C This routine requires that the matrix A be stored in the
611 C SLAP Row format. In this format the non-zeros are stored
612 C counting across rows (except for the diagonal entry, which
613 C must appear first in each "row") and are stored in the
614 C double precision array A. In other words, for each row in
615 C the matrix put the diagonal entry in A. Then put in the
616 C other non-zero elements going across the row (except the
617 C diagonal) in order. The JA array holds the column index for
618 C each non-zero. The IA array holds the offsets into the JA,
619 C A arrays for the beginning of each row. That is,
620 C JA(IA(IROW)),A(IA(IROW)) are the first elements of the IROW-
621 C th row in JA and A, and JA(IA(IROW+1)-1), A(IA(IROW+1)-1)
622 C are the last elements of the IROW-th row. Note that we
623 C always have IA(N+1) = NELT+1, where N is the number of rows
624 C in the matrix and NELT is the number of non-zeros in the
625 C matrix.
626 C
627 C Here is an example of the SLAP Row storage format for a 5x5
628 C Matrix (in the A and JA arrays '|' denotes the end of a row):
629 C
630 C 5x5 Matrix SLAP Row format for 5x5 matrix on left.
631 C 1 2 3 4 5 6 7 8 9 10 11
632 C |11 12 0 0 15| A: 11 12 15 | 22 21 | 33 35 | 44 | 55 51 53
633 C |21 22 0 0 0| JA: 1 2 5 | 2 1 | 3 5 | 4 | 5 1 3
634 C | 0 0 33 0 35| IA: 1 4 6 8 9 12
635 C | 0 0 0 44 0|
636 C |51 0 53 0 55|
637 C
638 C With the SLAP format the "inner loops" of this routine
639 C should vectorize on machines with hardware support for
640 C vector gather/scatter operations. Your compiler may require
641 C a compiler directive to convince it that there are no
642 C implicit vector dependencies. Compiler directives for the
643 C Alliant FX/Fortran and CRI CFT/CFT77 compilers are supplied
644 C with the standard SLAP distribution.
645 C
646 C***SEE ALSO DSILUS
647 C***REFERENCES (NONE)
648 C***ROUTINES CALLED (NONE)
649 C***REVISION HISTORY (YYMMDD)
650 C 871119 DATE WRITTEN
651 C 881213 Previous REVISION DATE
652 C 890915 Made changes requested at July 1989 CML Meeting. (MKS)
653 C 890922 Numerous changes to prologue to make closer to SLATEC
654 C standard. (FNF)
655 C 890929 Numerous changes to reduce SP/DP differences. (FNF)
656 C 910411 Prologue converted to Version 4.0 format. (BAB)
657 C 920511 Added complete declaration section. (WRB)
658 C 921113 Corrected C***CATEGORY line. (FNF)
659 C 930701 Updated CATEGORY section. (FNF, WRB)
660 C***END PROLOGUE DSLUI2
661 C .. Scalar Arguments ..
662  INTEGER n
663 C .. Array Arguments ..
664  DOUBLE PRECISION b(n), dinv(n), l(*), u(*), x(n)
665  INTEGER il(*), iu(*), jl(*), ju(*)
666 C .. Local Scalars ..
667  INTEGER i, icol, irow, j, jbgn, jend
668 C***FIRST EXECUTABLE STATEMENT DSLUI2
669 C
670 C Solve L*Y = B, storing result in X, L stored by rows.
671 C
672 c$omp parallel default(none)
673 c$omp& shared(x,b,n)
674 c$omp& private(i)
675 c$omp do
676  DO 10 i = 1, n
677  x(i) = b(i)
678  10 CONTINUE
679 c$omp end do
680 c$omp end parallel
681 c
682  DO 30 irow = 2, n
683  jbgn = il(irow)
684  jend = il(irow+1)-1
685  IF( jbgn.LE.jend ) THEN
686 CLLL. OPTION ASSERT (NOHAZARD)
687 CDIR$ IVDEP
688 CVD$ ASSOC
689 CVD$ NODEPCHK
690  DO 20 j = jbgn, jend
691  x(irow) = x(irow) - l(j)*x(jl(j))
692  20 CONTINUE
693  ENDIF
694  30 CONTINUE
695 c
696 C
697 C Solve D*Z = Y, storing result in X.
698 c$omp parallel default(none)
699 c$omp& shared(n,x,dinv)
700 c$omp& private(i)
701 c$omp do
702  DO 40 i=1,n
703  x(i) = x(i)*dinv(i)
704  40 CONTINUE
705 c$omp end do
706 c$omp end parallel
707 C
708 C Solve U*X = Z, U stored by columns.
709  DO 60 icol = n, 2, -1
710  jbgn = ju(icol)
711  jend = ju(icol+1)-1
712  IF( jbgn.LE.jend ) THEN
713 CLLL. OPTION ASSERT (NOHAZARD)
714 CDIR$ IVDEP
715 CVD$ NODEPCHK
716  DO 50 j = jbgn, jend
717  x(iu(j)) = x(iu(j)) - u(j)*x(icol)
718  50 CONTINUE
719  ENDIF
720  60 CONTINUE
721 C
722  RETURN
723 C------------- LAST LINE OF DSLUI2 FOLLOWS ----------------------------

◆ dsmv()

subroutine dsmv ( integer  N,
double precision, dimension(n)  X,
double precision, dimension(n)  Y,
integer  NELT,
integer, dimension(nelt)  IA,
integer, dimension(nelt)  JA,
double precision, dimension(nelt)  A,
integer  ISYM 
)
727  use omp_lib
728 C***BEGIN PROLOGUE DSMV
729 C***PURPOSE SLAP Column Format Sparse Matrix Vector Product.
730 C Routine to calculate the sparse matrix vector product:
731 C Y = A*X.
732 C***LIBRARY SLATEC (SLAP)
733 C***CATEGORY D1B4
734 C***TYPE DOUBLE PRECISION (SSMV-S, DSMV-D)
735 C***KEYWORDS MATRIX VECTOR MULTIPLY, SLAP, SPARSE
736 C***AUTHOR Greenbaum, Anne, (Courant Institute)
737 C Seager, Mark K., (LLNL)
738 C Lawrence Livermore National Laboratory
739 C PO BOX 808, L-60
740 C Livermore, CA 94550 (510) 423-3141
741 C seager@llnl.gov
742 C***DESCRIPTION
743 C
744 C *Usage:
745 C INTEGER N, NELT, IA(NELT), JA(NELT), ISYM
746 C DOUBLE PRECISION X(N), Y(N), A(NELT)
747 C
748 C CALL DSMV(N, X, Y, NELT, IA, JA, A, ISYM )
749 C
750 C *Arguments:
751 C N :IN Integer.
752 C Order of the Matrix.
753 C X :IN Double Precision X(N).
754 C The vector that should be multiplied by the matrix.
755 C Y :OUT Double Precision Y(N).
756 C The product of the matrix and the vector.
757 C NELT :IN Integer.
758 C Number of Non-Zeros stored in A.
759 C IA :IN Integer IA(NELT).
760 C JA :IN Integer JA(NELT).
761 C A :IN Double Precision A(NELT).
762 C These arrays should hold the matrix A in the SLAP Column
763 C format. See "Description", below.
764 C ISYM :IN Integer.
765 C Flag to indicate symmetric storage format.
766 C If ISYM=0, all non-zero entries of the matrix are stored.
767 C If ISYM=1, the matrix is symmetric, and only the upper
768 C or lower triangle of the matrix is stored.
769 C
770 C *Description
771 C =================== S L A P Column format ==================
772 C This routine requires that the matrix A be stored in the
773 C SLAP Column format. In this format the non-zeros are stored
774 C counting down columns (except for the diagonal entry, which
775 C must appear first in each "column") and are stored in the
776 C double precision array A. In other words, for each column
777 C in the matrix put the diagonal entry in A. Then put in the
778 C other non-zero elements going down the column (except the
779 C diagonal) in order. The IA array holds the row index for
780 C each non-zero. The JA array holds the offsets into the IA,
781 C A arrays for the beginning of each column. That is,
782 C IA(JA(ICOL)), A(JA(ICOL)) points to the beginning of the
783 C ICOL-th column in IA and A. IA(JA(ICOL+1)-1),
784 C A(JA(ICOL+1)-1) points to the end of the ICOL-th column.
785 C Note that we always have JA(N+1) = NELT+1, where N is the
786 C number of columns in the matrix and NELT is the number of
787 C non-zeros in the matrix.
788 C
789 C Here is an example of the SLAP Column storage format for a
790 C 5x5 Matrix (in the A and IA arrays '|' denotes the end of a
791 C column):
792 C
793 C 5x5 Matrix SLAP Column format for 5x5 matrix on left.
794 C 1 2 3 4 5 6 7 8 9 10 11
795 C |11 12 0 0 15| A: 11 21 51 | 22 12 | 33 53 | 44 | 55 15 35
796 C |21 22 0 0 0| IA: 1 2 5 | 2 1 | 3 5 | 4 | 5 1 3
797 C | 0 0 33 0 35| JA: 1 4 6 8 9 12
798 C | 0 0 0 44 0|
799 C |51 0 53 0 55|
800 C
801 C With the SLAP format the "inner loops" of this routine
802 C should vectorize on machines with hardware support for
803 C vector gather/scatter operations. Your compiler may require
804 C a compiler directive to convince it that there are no
805 C implicit vector dependencies. Compiler directives for the
806 C Alliant FX/Fortran and CRI CFT/CFT77 compilers are supplied
807 C with the standard SLAP distribution.
808 C
809 C *Cautions:
810 C This routine assumes that the matrix A is stored in SLAP
811 C Column format. It does not check for this (for speed) and
812 C evil, ugly, ornery and nasty things will happen if the matrix
813 C data structure is, in fact, not SLAP Column. Beware of the
814 C wrong data structure!!!
815 C
816 C***SEE ALSO DSMTV
817 C***REFERENCES (NONE)
818 C***ROUTINES CALLED (NONE)
819 C***REVISION HISTORY (YYMMDD)
820 C 871119 DATE WRITTEN
821 C 881213 Previous REVISION DATE
822 C 890915 Made changes requested at July 1989 CML Meeting. (MKS)
823 C 890922 Numerous changes to prologue to make closer to SLATEC
824 C standard. (FNF)
825 C 890929 Numerous changes to reduce SP/DP differences. (FNF)
826 C 910411 Prologue converted to Version 4.0 format. (BAB)
827 C 920511 Added complete declaration section. (WRB)
828 C 930701 Updated CATEGORY section. (FNF, WRB)
829 C***END PROLOGUE DSMV
830 C .. Scalar Arguments ..
831  INTEGER isym, n, nelt
832 C .. Array Arguments ..
833  DOUBLE PRECISION a(nelt), x(n), y(n)
834  INTEGER ia(nelt), ja(nelt)
835 C .. Local Scalars ..
836  INTEGER i, ibgn, icol, iend, irow, j, jbgn, jend
837 C***FIRST EXECUTABLE STATEMENT DSMV
838  if(isym.ne.1) then
839 C
840 C Zero out the result vector.
841 C
842 c$omp parallel default(none)
843 c$omp& shared(n,y,ja,ia,a,x)
844 c$omp& private(i,icol,ibgn,iend)
845 c$omp do
846  DO 10 i = 1, n
847  y(i) = 0
848  10 CONTINUE
849 c$omp end do
850 C
851 C Multiply by A.
852 C
853 c$omp do
854  DO 30 icol = 1, n
855  ibgn = ja(icol)
856  iend = ja(icol+1)-1
857  DO 20 i = ibgn, iend
858 c$omp atomic
859  y(ia(i)) = y(ia(i)) + a(i)*x(icol)
860  20 CONTINUE
861  30 CONTINUE
862 c$omp end do
863 c$omp end parallel
864 C
865  else
866 C
867 C The matrix is symmetric. Need to get the other half in...
868 C This loops assumes that the diagonal is the first entry in
869 C each column.
870 C
871 C
872 C Zero out the result vector.
873 C
874 c$omp parallel default(none)
875 c$omp& shared(n,y,ja,ia,a,x)
876 c$omp& private(i,j,icol,irow,ibgn,iend,jbgn,jend)
877 c$omp do
878  DO 100 i = 1, n
879  y(i) = 0
880  100 CONTINUE
881 c$omp end do
882 C
883 C Multiply by A.
884 C
885 c$omp do
886  DO 300 icol = 1, n
887  ibgn = ja(icol)
888  iend = ja(icol+1)-1
889  DO 200 i = ibgn, iend
890 c$omp atomic
891  y(ia(i)) = y(ia(i)) + a(i)*x(icol)
892  200 CONTINUE
893  300 CONTINUE
894 c$omp end do
895 C
896 c$omp do
897  DO 50 irow = 1, n
898  jbgn = ja(irow)+1
899  jend = ja(irow+1)-1
900  IF( jbgn.GT.jend ) GOTO 50
901  DO 40 j = jbgn, jend
902  y(irow) = y(irow) + a(j)*x(ia(j))
903  40 CONTINUE
904  50 CONTINUE
905 c$omp end do
906 c$omp end parallel
907  ENDIF
908  RETURN
909 C------------- LAST LINE OF DSMV FOLLOWS ----------------------------

◆ qs2i1d()

subroutine qs2i1d ( integer, dimension(n)  IA,
integer, dimension(n)  JA,
double precision, dimension(n)  A,
integer  N,
integer  KFLAG 
)
1595 C***BEGIN PROLOGUE QS2I1D
1596 C***SUBSIDIARY
1597 C***PURPOSE Sort an integer array, moving an integer and DP array.
1598 C This routine sorts the integer array IA and makes the same
1599 C interchanges in the integer array JA and the double pre-
1600 C cision array A. The array IA may be sorted in increasing
1601 C order or decreasing order. A slightly modified QUICKSORT
1602 C algorithm is used.
1603 C***LIBRARY SLATEC (SLAP)
1604 C***CATEGORY N6A2A
1605 C***TYPE DOUBLE PRECISION (QS2I1R-S, QS2I1D-D)
1606 C***KEYWORDS SINGLETON QUICKSORT, SLAP, SORT, SORTING
1607 C***AUTHOR Jones, R. E., (SNLA)
1608 C Kahaner, D. K., (NBS)
1609 C Seager, M. K., (LLNL) seager@llnl.gov
1610 C Wisniewski, J. A., (SNLA)
1611 C***DESCRIPTION
1612 C Written by Rondall E Jones
1613 C Modified by John A. Wisniewski to use the Singleton QUICKSORT
1614 C algorithm. date 18 November 1976.
1615 C
1616 C Further modified by David K. Kahaner
1617 C National Bureau of Standards
1618 C August, 1981
1619 C
1620 C Even further modification made to bring the code up to the
1621 C Fortran 77 level and make it more readable and to carry
1622 C along one integer array and one double precision array during
1623 C the sort by
1624 C Mark K. Seager
1625 C Lawrence Livermore National Laboratory
1626 C November, 1987
1627 C This routine was adapted from the ISORT routine.
1628 C
1629 C ABSTRACT
1630 C This routine sorts an integer array IA and makes the same
1631 C interchanges in the integer array JA and the double precision
1632 C array A.
1633 C The array IA may be sorted in increasing order or decreasing
1634 C order. A slightly modified quicksort algorithm is used.
1635 C
1636 C DESCRIPTION OF PARAMETERS
1637 C IA - Integer array of values to be sorted.
1638 C JA - Integer array to be carried along.
1639 C A - Double Precision array to be carried along.
1640 C N - Number of values in integer array IA to be sorted.
1641 C KFLAG - Control parameter
1642 C = 1 means sort IA in INCREASING order.
1643 C =-1 means sort IA in DECREASING order.
1644 C
1645 C***SEE ALSO DS2Y
1646 C***REFERENCES R. C. Singleton, Algorithm 347, An Efficient Algorithm
1647 C for Sorting With Minimal Storage, Communications ACM
1648 C 12:3 (1969), pp.185-7.
1649 C***ROUTINES CALLED XERMSG
1650 C***REVISION HISTORY (YYMMDD)
1651 C 761118 DATE WRITTEN
1652 C 890125 Previous REVISION DATE
1653 C 890915 Made changes requested at July 1989 CML Meeting. (MKS)
1654 C 890922 Numerous changes to prologue to make closer to SLATEC
1655 C standard. (FNF)
1656 C 890929 Numerous changes to reduce SP/DP differences. (FNF)
1657 C 900805 Changed XERROR calls to calls to XERMSG. (RWC)
1658 C 910411 Prologue converted to Version 4.0 format. (BAB)
1659 C 910506 Made subsidiary to DS2Y and corrected reference. (FNF)
1660 C 920511 Added complete declaration section. (WRB)
1661 C 920929 Corrected format of reference. (FNF)
1662 C 921012 Corrected all f.p. constants to double precision. (FNF)
1663 C***END PROLOGUE QS2I1D
1664 CVD$R NOVECTOR
1665 CVD$R NOCONCUR
1666 C .. Scalar Arguments ..
1667  INTEGER kflag, n
1668 C .. Array Arguments ..
1669  DOUBLE PRECISION a(n)
1670  INTEGER ia(n), ja(n)
1671 C .. Local Scalars ..
1672  DOUBLE PRECISION r, ta, tta
1673  INTEGER i, iit, ij, it, j, jjt, jt, k, kk, l, m, nn
1674 C .. Local Arrays ..
1675  INTEGER il(21), iu(21)
1676 C .. External Subroutines ..
1677  EXTERNAL xermsg
1678 C .. Intrinsic Functions ..
1679  INTRINSIC abs, int
1680 C***FIRST EXECUTABLE STATEMENT QS2I1D
1681  nn = n
1682  IF (nn.LT.1) THEN
1683  CALL xermsg ('SLATEC', 'QS2I1D',
1684  $ 'The number of values to be sorted was not positive.', 1, 1)
1685  RETURN
1686  ENDIF
1687  IF( n.EQ.1 ) RETURN
1688  kk = abs(kflag)
1689  IF ( kk.NE.1 ) THEN
1690  CALL xermsg ('SLATEC', 'QS2I1D',
1691  $ 'The sort control parameter, K, was not 1 or -1.', 2, 1)
1692  RETURN
1693  ENDIF
1694 C
1695 C Alter array IA to get decreasing order if needed.
1696 C
1697  IF( kflag.LT.1 ) THEN
1698  DO 20 i=1,nn
1699  ia(i) = -ia(i)
1700  20 CONTINUE
1701  ENDIF
1702 C
1703 C Sort IA and carry JA and A along.
1704 C And now...Just a little black magic...
1705  m = 1
1706  i = 1
1707  j = nn
1708  r = .375d0
1709  210 IF( r.LE.0.5898437d0 ) THEN
1710  r = r + 3.90625d-2
1711  ELSE
1712  r = r-.21875d0
1713  ENDIF
1714  225 k = i
1715 C
1716 C Select a central element of the array and save it in location
1717 C it, jt, at.
1718 C
1719  ij = i + int((j-i)*r)
1720  it = ia(ij)
1721  jt = ja(ij)
1722  ta = a(ij)
1723 C
1724 C If first element of array is greater than it, interchange with it.
1725 C
1726  IF( ia(i).GT.it ) THEN
1727  ia(ij) = ia(i)
1728  ia(i) = it
1729  it = ia(ij)
1730  ja(ij) = ja(i)
1731  ja(i) = jt
1732  jt = ja(ij)
1733  a(ij) = a(i)
1734  a(i) = ta
1735  ta = a(ij)
1736  ENDIF
1737  l=j
1738 C
1739 C If last element of array is less than it, swap with it.
1740 C
1741  IF( ia(j).LT.it ) THEN
1742  ia(ij) = ia(j)
1743  ia(j) = it
1744  it = ia(ij)
1745  ja(ij) = ja(j)
1746  ja(j) = jt
1747  jt = ja(ij)
1748  a(ij) = a(j)
1749  a(j) = ta
1750  ta = a(ij)
1751 C
1752 C If first element of array is greater than it, swap with it.
1753 C
1754  IF ( ia(i).GT.it ) THEN
1755  ia(ij) = ia(i)
1756  ia(i) = it
1757  it = ia(ij)
1758  ja(ij) = ja(i)
1759  ja(i) = jt
1760  jt = ja(ij)
1761  a(ij) = a(i)
1762  a(i) = ta
1763  ta = a(ij)
1764  ENDIF
1765  ENDIF
1766 C
1767 C Find an element in the second half of the array which is
1768 C smaller than it.
1769 C
1770  240 l=l-1
1771  IF( ia(l).GT.it ) GO TO 240
1772 C
1773 C Find an element in the first half of the array which is
1774 C greater than it.
1775 C
1776  245 k=k+1
1777  IF( ia(k).LT.it ) GO TO 245
1778 C
1779 C Interchange these elements.
1780 C
1781  IF( k.LE.l ) THEN
1782  iit = ia(l)
1783  ia(l) = ia(k)
1784  ia(k) = iit
1785  jjt = ja(l)
1786  ja(l) = ja(k)
1787  ja(k) = jjt
1788  tta = a(l)
1789  a(l) = a(k)
1790  a(k) = tta
1791  GOTO 240
1792  ENDIF
1793 C
1794 C Save upper and lower subscripts of the array yet to be sorted.
1795 C
1796  IF( l-i.GT.j-k ) THEN
1797  il(m) = i
1798  iu(m) = l
1799  i = k
1800  m = m+1
1801  ELSE
1802  il(m) = k
1803  iu(m) = j
1804  j = l
1805  m = m+1
1806  ENDIF
1807  GO TO 260
1808 C
1809 C Begin again on another portion of the unsorted array.
1810 C
1811  255 m = m-1
1812  IF( m.EQ.0 ) GO TO 300
1813  i = il(m)
1814  j = iu(m)
1815  260 IF( j-i.GE.1 ) GO TO 225
1816  IF( i.EQ.j ) GO TO 255
1817  IF( i.EQ.1 ) GO TO 210
1818  i = i-1
1819  265 i = i+1
1820  IF( i.EQ.j ) GO TO 255
1821  it = ia(i+1)
1822  jt = ja(i+1)
1823  ta = a(i+1)
1824  IF( ia(i).LE.it ) GO TO 265
1825  k=i
1826  270 ia(k+1) = ia(k)
1827  ja(k+1) = ja(k)
1828  a(k+1) = a(k)
1829  k = k-1
1830  IF( it.LT.ia(k) ) GO TO 270
1831  ia(k+1) = it
1832  ja(k+1) = jt
1833  a(k+1) = ta
1834  GO TO 265
1835 C
1836 C Clean up, if necessary.
1837 C
1838  300 IF( kflag.LT.1 ) THEN
1839  DO 310 i=1,nn
1840  ia(i) = -ia(i)
1841  310 CONTINUE
1842  ENDIF
1843  RETURN
1844 C------------- LAST LINE OF QS2I1D FOLLOWS ----------------------------
subroutine xermsg(LIBRAR, SUBROU, MESSG, NERR, LEVEL)
Definition: ddeabm.f:1265
Hosted by OpenAircraft.com, (Michigan UAV, LLC)