313 module procedure d_refsor, r_refsor, i_refsor, c_refsor
320 module procedure sort_index_dp, sort_index_sp, sort_index_i4
350 module procedure d_ctrper, r_ctrper, i_ctrper
371 module procedure d_fndnth, r_fndnth, i_fndnth
391 module procedure d_indmed, r_indmed, i_indmed
413 module procedure d_indnth, r_indnth, i_indnth
430 module procedure d_inspar, r_inspar, i_inspar
446 module procedure d_inssor, r_inssor, i_inssor, c_inssor
460 module procedure d_median, r_median, i_median
474 module procedure d_mrgref, r_mrgref, i_mrgref
488 module procedure d_mrgrnk, r_mrgrnk, i_mrgrnk, c_mrgrnk
505 module procedure d_mulcnt, r_mulcnt, i_mulcnt
519 module procedure d_rapknr, r_rapknr, i_rapknr
539 module procedure d_refpar, r_refpar, i_refpar
554 module procedure d_refsor, r_refsor, i_refsor, c_refsor
573 module procedure d_rinpar, r_rinpar, i_rinpar
595 module procedure d_rnkpar, r_rnkpar, i_rnkpar
612 module procedure d_uniinv, r_uniinv, i_uniinv
615 module procedure d_nearless, r_nearless, i_nearless
639 module procedure d_unipar, r_unipar, i_unipar
656 module procedure d_unirnk, r_unirnk, i_unirnk
671 module procedure d_unista, r_unista, i_unista
688 module procedure d_valmed, r_valmed, i_valmed
702 module procedure d_valnth, r_valnth, i_valnth
705 private :: r_ctrper, i_ctrper, d_ctrper
706 private :: r_fndnth, i_fndnth, d_fndnth
707 private :: r_indmed, i_indmed, d_indmed
708 private :: r_indnth, i_indnth, d_indnth
709 private :: r_inspar, i_inspar, d_inspar
710 private :: r_inssor, i_inssor, d_inssor, c_inssor
711 private :: r_median, i_median, d_median
712 private :: r_mrgref, i_mrgref, d_mrgref
713 private :: r_mrgrnk, i_mrgrnk, d_mrgrnk
714 private :: r_mulcnt, i_mulcnt, d_mulcnt
715 private :: r_nearless, i_nearless, d_nearless,
nearless
716 private :: r_rapknr, i_rapknr, d_rapknr
717 private :: r_refpar, i_refpar, d_refpar
718 private :: r_refsor, i_refsor, d_refsor, c_refsor
719 private :: r_rinpar, i_rinpar, d_rinpar
720 private :: r_rnkpar, i_rnkpar, d_rnkpar
721 private :: r_subsor, i_subsor, d_subsor, c_subsor
722 private :: r_uniinv, i_uniinv, d_uniinv
723 private :: r_unipar, i_unipar, d_unipar
724 private :: r_unirnk, i_unirnk, d_unirnk
725 private :: r_unista, i_unista, d_unista
726 private :: r_valmed, i_valmed, d_valmed
727 private :: r_valnth, i_valnth, d_valnth
728 private :: r_med, i_med, d_med
732 Integer(kind = i4),
Allocatable,
Dimension(:),
Save :: IDONT
738 FUNCTION sort_index_dp(arr)
742 REAL(dp),
DIMENSION(:),
INTENT(IN) :: arr
743 INTEGER(i4),
DIMENSION(size(arr)) :: sort_index_dp
745 call mrgrnk(arr, sort_index_dp)
747 END FUNCTION sort_index_dp
749 FUNCTION sort_index_sp(arr)
753 REAL(sp),
DIMENSION(:),
INTENT(IN) :: arr
754 INTEGER(i4),
DIMENSION(size(arr)) :: sort_index_sp
756 call mrgrnk(arr, sort_index_sp)
758 END FUNCTION sort_index_sp
760 FUNCTION sort_index_i4(arr)
764 integer(i4),
DIMENSION(:),
INTENT(IN) :: arr
765 INTEGER(i4),
DIMENSION(size(arr)) :: sort_index_i4
767 call mrgrnk(arr, sort_index_i4)
769 END FUNCTION sort_index_i4
774 Subroutine d_ctrper (XDONT, PCLS)
788 real(kind =
dp),
Dimension (:),
Intent (InOut) :: xdont
789 Real(kind =
dp),
Intent (In) :: pcls
792 Real(kind =
dp),
Dimension (Size(XDONT)) :: xindt
793 Integer(kind = i4),
Dimension (Size(XDONT)) :: JWRKT
794 Real(kind =
dp) :: pwrk
795 Integer(kind = i4) :: I
796 Real(kind =
dp),
Dimension (Size(XDONT)) :: ii
798 Call random_number (xindt(:))
799 pwrk = min(max(0.0_dp, pcls), 1.0_dp)
800 xindt = real(
Size(xdont),
dp) * xindt
801 forall(i = 1 :
size(xdont)) ii(i) = real(i,
dp)
802 xindt = pwrk * xindt + (1.0_dp - pwrk) * ii
803 Call mrgrnk (xindt, jwrkt)
806 End Subroutine d_ctrper
808 Subroutine r_ctrper (XDONT, PCLS)
822 Real(kind =
sp),
Dimension (:),
Intent (InOut) :: xdont
823 Real(kind =
sp),
Intent (In) :: pcls
826 Real(kind =
sp),
Dimension (Size(XDONT)) :: xindt
827 Integer(kind = i4),
Dimension (Size(XDONT)) :: JWRKT
828 Real(kind =
sp) :: pwrk
829 Integer(kind = i4) :: I
830 Real(kind =
sp),
Dimension (Size(XDONT)) :: ii
832 Call random_number (xindt(:))
833 pwrk = min(max(0.0, pcls), 1.0)
834 xindt = real(
Size(xdont),
sp) * xindt
835 forall(i = 1 :
size(xdont)) ii(i) = real(i,
sp)
836 xindt = pwrk * xindt + (1.0 - pwrk) * ii
837 Call mrgrnk (xindt, jwrkt)
840 End Subroutine r_ctrper
842 Subroutine i_ctrper (XDONT, PCLS)
856 Integer(kind = i4),
Dimension (:),
Intent (InOut) :: XDONT
857 Real(kind =
sp),
Intent (In) :: pcls
860 Real(kind =
sp),
Dimension (Size(XDONT)) :: xindt
861 Integer(kind = i4),
Dimension (Size(XDONT)) :: JWRKT
862 Real(kind =
sp) :: pwrk
863 Integer(kind = i4) :: I
864 Real(kind =
sp),
Dimension (Size(XDONT)) :: ii
866 Call random_number (xindt(:))
867 pwrk = min(max(0.0, pcls), 1.0)
868 xindt = real(
Size(xdont),
sp) * xindt
869 forall(i = 1 :
size(xdont)) ii(i) = real(i,
sp)
870 xindt = pwrk * xindt + (1.0 - pwrk) * ii
874 End Subroutine i_ctrper
876 Function d_fndnth (XDONT, NORD)
Result (FNDNTH)
887 real(Kind =
dp),
Dimension (:),
Intent (In) :: xdont
889 Integer(kind = i4),
Intent (In) :: NORD
891 real(Kind =
dp),
Dimension (NORD) :: xwrkt
892 real(Kind =
dp) :: xwrk, xwrk1
895 Integer(kind = i4) :: ICRS, IDCR, ILOW, NDON
900 Do idcr = icrs - 1, 1, - 1
901 If (xwrk >= xwrkt(idcr))
Exit
902 xwrkt(idcr + 1) = xwrkt(idcr)
904 xwrkt(idcr + 1) = xwrk
909 ilow = 2 * nord - ndon
910 Do icrs = nord + 1, ndon
911 If (xdont(icrs) < xwrk1)
Then
913 Do idcr = nord - 1, max(1, ilow), - 1
914 If (xwrk >= xwrkt(idcr))
Exit
915 xwrkt(idcr + 1) = xwrkt(idcr)
917 xwrkt(idcr + 1) = xwrk
925 End Function d_fndnth
927 Function r_fndnth (XDONT, NORD)
Result (FNDNTH)
938 Real(kind =
sp),
Dimension (:),
Intent (In) :: xdont
940 Integer(kind = i4),
Intent (In) :: NORD
942 Real(kind =
sp),
Dimension (NORD) :: xwrkt
943 Real(kind =
sp) :: xwrk, xwrk1
946 Integer(kind = i4) :: ICRS, IDCR, ILOW, NDON
951 Do idcr = icrs - 1, 1, - 1
952 If (xwrk >= xwrkt(idcr))
Exit
953 xwrkt(idcr + 1) = xwrkt(idcr)
955 xwrkt(idcr + 1) = xwrk
960 ilow = 2 * nord - ndon
961 Do icrs = nord + 1, ndon
962 If (xdont(icrs) < xwrk1)
Then
964 Do idcr = nord - 1, max(1, ilow), - 1
965 If (xwrk >= xwrkt(idcr))
Exit
966 xwrkt(idcr + 1) = xwrkt(idcr)
968 xwrkt(idcr + 1) = xwrk
976 End Function r_fndnth
978 Function i_fndnth (XDONT, NORD)
Result (FNDNTH)
989 Integer(kind = i4),
Dimension (:),
Intent (In) :: XDONT
990 Integer(kind = i4) :: fndnth
991 Integer(kind = i4),
Intent (In) :: NORD
993 Integer(kind = i4),
Dimension (NORD) :: XWRKT
994 Integer(kind = i4) :: XWRK, XWRK1
997 Integer(kind = i4) :: ICRS, IDCR, ILOW, NDON
1002 Do idcr = icrs - 1, 1, - 1
1003 If (xwrk >= xwrkt(idcr))
Exit
1004 xwrkt(idcr + 1) = xwrkt(idcr)
1006 xwrkt(idcr + 1) = xwrk
1011 ilow = 2 * nord - ndon
1012 Do icrs = nord + 1, ndon
1013 If (xdont(icrs) < xwrk1)
Then
1015 Do idcr = nord - 1, max(1, ilow), - 1
1016 If (xwrk >= xwrkt(idcr))
Exit
1017 xwrkt(idcr + 1) = xwrkt(idcr)
1019 xwrkt(idcr + 1) = xwrk
1027 End Function i_fndnth
1029 Subroutine d_indmed (XDONT, INDM)
1032 real(kind =
dp),
Dimension (:),
Intent (In) :: xdont
1033 Integer(kind = i4),
Intent (Out) :: INDM
1035 Integer(kind = i4) :: IDON
1037 Allocate (idont(
SIZE(xdont)))
1038 Do idon = 1,
SIZE(xdont)
1042 Call d_med (xdont, idont, indm)
1045 End Subroutine d_indmed
1047 Recursive Subroutine d_med (XDATT, IDATT, ires_med)
1056 real(kind =
dp),
Dimension (:),
Intent (In) :: xdatt
1057 Integer(kind = i4),
Dimension (:),
Intent (In) :: IDATT
1058 Integer(kind = i4),
Intent (Out) :: ires_med
1061 real(kind =
dp),
Parameter :: xhuge = huge(xdatt)
1062 real(kind =
dp) :: xwrk, xwrk1, xmed7, xmax, xmin
1064 Integer(kind = i4),
Dimension (7 * (((Size (IDATT) + 6) / 7 + 6) / 7)) :: ISTRT, IENDT, IMEDT
1065 Integer(kind = i4),
Dimension (7 * ((Size(IDATT) + 6) / 7)) :: IWRKT
1066 Integer(kind = i4) :: NTRI, NMED, NORD, NEQU, NLEQ, IMED, IDON, IDON1
1067 Integer(kind = i4) :: IDEB, ITMP, IDCR, ICRS, ICRS1, ICRS2, IMAX, IMIN
1068 Integer(kind = i4) :: IWRK, IWRK1, IMED1, IMED7, NDAT
1071 nmed = (ndat + 1) / 2
1081 If (xdatt(iwrkt(1)) < xdatt(iwrkt(idcr)))
Then
1085 iwrkt(idcr) = iwrkt(1)
1088 Do itmp = 1, ndat - 2
1091 xwrk1 = xdatt(iwrk1)
1092 If (xwrk1 < xwrk)
Then
1103 xwrk = xdatt(iwrkt(icrs))
1107 If (xwrk >= xdatt(iwrkt(idcr)))
Exit
1108 iwrkt(idcr + 1) = iwrkt(idcr)
1111 iwrkt(idcr + 1) = iwrk
1116 xwrk1 = xdatt(iwrkt(nmed))
1117 Do icrs = nmed + 1, ndat
1118 xwrk = xdatt(iwrkt(icrs))
1120 If (xwrk < xwrk1)
Then
1123 If (xwrk >= xdatt(iwrkt(idcr)))
Exit
1124 iwrkt(idcr + 1) = iwrkt(idcr)
1127 iwrkt(idcr + 1) = iwrk
1128 xwrk1 = xdatt(iwrkt(nmed))
1131 ires_med = iwrkt(nmed)
1143 xmax = xdatt(iwrkt(imax))
1144 xmin = xdatt(iwrkt(imin))
1145 DO ideb = 1, ndat - 6, 7
1147 If (xdatt(iwrkt(ideb)) < xdatt(iwrkt(idcr)))
Then
1151 iwrkt(idcr) = iwrkt(ideb)
1157 xwrk1 = xdatt(iwrk1)
1158 If (xwrk1 < xwrk)
Then
1165 If (xwrk < xmin)
Then
1169 Do icrs = ideb + 1, ideb + 5
1170 iwrk = iwrkt(icrs + 1)
1173 If (xwrk < xdatt(idon))
Then
1174 iwrkt(icrs + 1) = idon
1176 iwrk1 = iwrkt(idcr - 1)
1177 xwrk1 = xdatt(iwrk1)
1179 If (xwrk >= xwrk1)
Exit
1182 iwrk1 = iwrkt(idcr - 1)
1183 xwrk1 = xdatt(iwrk1)
1188 If (xwrk > xmax)
Then
1197 ideb = 7 * (ndat / 7)
1199 If (ideb < ndat)
Then
1201 Do icrs = ideb + 1, ndat
1202 xwrk1 = xdatt(iwrkt(icrs))
1203 IF (xwrk1 > xmax)
Then
1207 IF (xwrk1 < xmin)
Then
1213 Do icrs = ndat + 1, ideb + 7
1215 If (iwrk1 == imax)
Then
1223 Do icrs = ideb + 2, ideb + 7
1226 Do idcr = icrs - 1, ideb + 1, - 1
1227 If (xwrk >= xdatt(iwrkt(idcr)))
Exit
1228 iwrkt(idcr + 1) = iwrkt(idcr)
1230 iwrkt(idcr + 1) = iwrk
1239 Do idon = 1, ntri, 7
1241 imedt(idon1) = iwrkt(idon + 3)
1246 Call d_med (xdatt, imedt(1 : idon1), imed7)
1247 xmed7 = xdatt(imed7)
1261 Do idon = 1, ntri, 7
1263 If (xdatt(iwrkt(imed)) > xmed7)
Then
1265 If (xdatt(iwrkt(imed)) > xmed7)
Then
1267 Else If (xdatt(iwrkt(imed)) < xmed7)
Then
1270 Else If (xdatt(iwrkt(imed)) < xmed7)
Then
1272 If (xdatt(iwrkt(imed)) > xmed7)
Then
1274 Else If (xdatt(iwrkt(imed)) < xmed7)
Then
1278 If (xdatt(iwrkt(imed)) > xmed7)
Then
1279 nleq = nleq + imed - idon
1280 iendt(idon1) = imed - 1
1282 Else If (xdatt(iwrkt(imed)) < xmed7)
Then
1283 nleq = nleq + imed - idon + 1
1285 istrt(idon1) = imed + 1
1287 nleq = nleq + imed - idon + 1
1289 iendt(idon1) = imed - 1
1290 Do imed1 = imed - 1, idon, -1
1291 If (
eq(xdatt(iwrkt(imed1)), xmed7))
Then
1293 iendt(idon1) = imed1 - 1
1298 istrt(idon1) = imed + 1
1299 Do imed1 = imed + 1, idon + 6
1300 If (
eq(xdatt(iwrkt(imed1)), xmed7))
Then
1303 istrt(idon1) = imed1 + 1
1317 If (nleq - nequ + 1 <= nmed)
Then
1318 If (nleq < nmed)
Then
1320 xwrk1 = xdatt(iwrk1)
1326 Do idon = 1, ntri, 7
1328 If (icrs2 < nord)
Then
1329 Do icrs = istrt(idon1), idon + 6
1330 If (xdatt(iwrkt(icrs)) < xwrk1)
Then
1333 Do idcr = icrs1 - 1, 1, - 1
1334 If (xwrk >= xdatt(iwrkt(idcr)))
Exit
1335 iwrkt(idcr + 1) = iwrkt(idcr)
1337 iwrkt(idcr + 1) = iwrk
1338 iwrk1 = iwrkt(icrs1)
1339 xwrk1 = xdatt(iwrk1)
1341 If (icrs2 < nord)
Then
1342 iwrkt(icrs1) = iwrkt(icrs)
1343 iwrk1 = iwrkt(icrs1)
1344 xwrk1 = xdatt(iwrk1)
1347 icrs1 = min(nord, icrs1 + 1)
1348 icrs2 = min(nord, icrs2 + 1)
1351 Do icrs = istrt(idon1), idon + 6
1352 If (xdatt(iwrkt(icrs)) >= xwrk1)
Exit
1355 Do idcr = icrs1 - 1, 1, - 1
1356 If (xwrk >= xdatt(iwrkt(idcr)))
Exit
1357 iwrkt(idcr + 1) = iwrkt(idcr)
1359 iwrkt(idcr + 1) = iwrk
1360 iwrk1 = iwrkt(icrs1)
1361 xwrk1 = xdatt(iwrk1)
1374 nord = nleq - nequ - nmed + 1
1378 Do idon = 1, ntri, 7
1380 If (icrs2 < nord)
Then
1382 Do icrs = idon, iendt(idon1)
1383 If (xdatt(iwrkt(icrs)) > xwrk1)
Then
1387 Do idcr = icrs1 - 1, 1, - 1
1388 If (xwrk <= xdatt(iwrkt(idcr)))
Exit
1389 iwrkt(idcr + 1) = iwrkt(idcr)
1391 iwrkt(idcr + 1) = iwrk
1392 iwrk1 = iwrkt(icrs1)
1393 xwrk1 = xdatt(iwrk1)
1395 If (icrs2 < nord)
Then
1396 iwrkt(icrs1) = iwrkt(icrs)
1397 iwrk1 = iwrkt(icrs1)
1398 xwrk1 = xdatt(iwrk1)
1401 icrs1 = min(nord, icrs1 + 1)
1402 icrs2 = min(nord, icrs2 + 1)
1405 Do icrs = iendt(idon1), idon, -1
1406 If (xdatt(iwrkt(icrs)) <= xwrk1)
Exit
1410 Do idcr = icrs1 - 1, 1, - 1
1411 If (xwrk <= xdatt(iwrkt(idcr)))
Exit
1412 iwrkt(idcr + 1) = iwrkt(idcr)
1414 iwrkt(idcr + 1) = iwrk
1415 iwrk1 = iwrkt(icrs1)
1416 xwrk1 = xdatt(iwrk1)
1425 END Subroutine d_med
1427 Subroutine r_indmed (XDONT, INDM)
1430 Real(kind =
sp),
Dimension (:),
Intent (In) :: xdont
1431 Integer(kind = i4),
Intent (Out) :: INDM
1433 Integer(kind = i4) :: IDON
1435 Allocate (idont(
SIZE(xdont)))
1436 Do idon = 1,
SIZE(xdont)
1440 Call r_med (xdont, idont, indm)
1443 End Subroutine r_indmed
1445 Recursive Subroutine r_med (XDATT, IDATT, ires_med)
1454 Real(kind =
sp),
Dimension (:),
Intent (In) :: xdatt
1455 Integer(kind = i4),
Dimension (:),
Intent (In) :: IDATT
1456 Integer(kind = i4),
Intent (Out) :: ires_med
1459 Real(kind =
sp),
Parameter :: xhuge = huge(xdatt)
1460 Real(kind =
sp) :: xwrk, xwrk1, xmed7, xmax, xmin
1462 Integer(kind = i4),
Dimension (7 * (((Size (IDATT) + 6) / 7 + 6) / 7)) :: ISTRT, IENDT, IMEDT
1463 Integer(kind = i4),
Dimension (7 * ((Size(IDATT) + 6) / 7)) :: IWRKT
1464 Integer(kind = i4) :: NTRI, NMED, NORD, NEQU, NLEQ, IMED, IDON, IDON1
1465 Integer(kind = i4) :: IDEB, ITMP, IDCR, ICRS, ICRS1, ICRS2, IMAX, IMIN
1466 Integer(kind = i4) :: IWRK, IWRK1, IMED1, IMED7, NDAT
1469 nmed = (ndat + 1) / 2
1479 If (xdatt(iwrkt(1)) < xdatt(iwrkt(idcr)))
Then
1483 iwrkt(idcr) = iwrkt(1)
1486 Do itmp = 1, ndat - 2
1489 xwrk1 = xdatt(iwrk1)
1490 If (xwrk1 < xwrk)
Then
1501 xwrk = xdatt(iwrkt(icrs))
1505 If (xwrk >= xdatt(iwrkt(idcr)))
Exit
1506 iwrkt(idcr + 1) = iwrkt(idcr)
1509 iwrkt(idcr + 1) = iwrk
1514 xwrk1 = xdatt(iwrkt(nmed))
1515 Do icrs = nmed + 1, ndat
1516 xwrk = xdatt(iwrkt(icrs))
1518 If (xwrk < xwrk1)
Then
1521 If (xwrk >= xdatt(iwrkt(idcr)))
Exit
1522 iwrkt(idcr + 1) = iwrkt(idcr)
1525 iwrkt(idcr + 1) = iwrk
1526 xwrk1 = xdatt(iwrkt(nmed))
1529 ires_med = iwrkt(nmed)
1541 xmax = xdatt(iwrkt(imax))
1542 xmin = xdatt(iwrkt(imin))
1543 DO ideb = 1, ndat - 6, 7
1545 If (xdatt(iwrkt(ideb)) < xdatt(iwrkt(idcr)))
Then
1549 iwrkt(idcr) = iwrkt(ideb)
1555 xwrk1 = xdatt(iwrk1)
1556 If (xwrk1 < xwrk)
Then
1563 If (xwrk < xmin)
Then
1567 Do icrs = ideb + 1, ideb + 5
1568 iwrk = iwrkt(icrs + 1)
1571 If (xwrk < xdatt(idon))
Then
1572 iwrkt(icrs + 1) = idon
1574 iwrk1 = iwrkt(idcr - 1)
1575 xwrk1 = xdatt(iwrk1)
1577 If (xwrk >= xwrk1)
Exit
1580 iwrk1 = iwrkt(idcr - 1)
1581 xwrk1 = xdatt(iwrk1)
1586 If (xwrk > xmax)
Then
1595 ideb = 7 * (ndat / 7)
1597 If (ideb < ndat)
Then
1599 Do icrs = ideb + 1, ndat
1600 xwrk1 = xdatt(iwrkt(icrs))
1601 IF (xwrk1 > xmax)
Then
1605 IF (xwrk1 < xmin)
Then
1611 Do icrs = ndat + 1, ideb + 7
1613 If (iwrk1 == imax)
Then
1621 Do icrs = ideb + 2, ideb + 7
1624 Do idcr = icrs - 1, ideb + 1, - 1
1625 If (xwrk >= xdatt(iwrkt(idcr)))
Exit
1626 iwrkt(idcr + 1) = iwrkt(idcr)
1628 iwrkt(idcr + 1) = iwrk
1637 Do idon = 1, ntri, 7
1639 imedt(idon1) = iwrkt(idon + 3)
1644 Call r_med (xdatt, imedt(1 : idon1), imed7)
1645 xmed7 = xdatt(imed7)
1659 Do idon = 1, ntri, 7
1661 If (xdatt(iwrkt(imed)) > xmed7)
Then
1663 If (xdatt(iwrkt(imed)) > xmed7)
Then
1665 Else If (xdatt(iwrkt(imed)) < xmed7)
Then
1668 Else If (xdatt(iwrkt(imed)) < xmed7)
Then
1670 If (xdatt(iwrkt(imed)) > xmed7)
Then
1672 Else If (xdatt(iwrkt(imed)) < xmed7)
Then
1676 If (xdatt(iwrkt(imed)) > xmed7)
Then
1677 nleq = nleq + imed - idon
1678 iendt(idon1) = imed - 1
1680 Else If (xdatt(iwrkt(imed)) < xmed7)
Then
1681 nleq = nleq + imed - idon + 1
1683 istrt(idon1) = imed + 1
1685 nleq = nleq + imed - idon + 1
1687 iendt(idon1) = imed - 1
1688 Do imed1 = imed - 1, idon, -1
1689 If (
eq(xdatt(iwrkt(imed1)), xmed7))
Then
1691 iendt(idon1) = imed1 - 1
1696 istrt(idon1) = imed + 1
1697 Do imed1 = imed + 1, idon + 6
1698 If (
eq(xdatt(iwrkt(imed1)), xmed7))
Then
1701 istrt(idon1) = imed1 + 1
1715 If (nleq - nequ + 1 <= nmed)
Then
1716 If (nleq < nmed)
Then
1718 xwrk1 = xdatt(iwrk1)
1724 Do idon = 1, ntri, 7
1726 If (icrs2 < nord)
Then
1727 Do icrs = istrt(idon1), idon + 6
1728 If (xdatt(iwrkt(icrs)) < xwrk1)
Then
1731 Do idcr = icrs1 - 1, 1, - 1
1732 If (xwrk >= xdatt(iwrkt(idcr)))
Exit
1733 iwrkt(idcr + 1) = iwrkt(idcr)
1735 iwrkt(idcr + 1) = iwrk
1736 iwrk1 = iwrkt(icrs1)
1737 xwrk1 = xdatt(iwrk1)
1739 If (icrs2 < nord)
Then
1740 iwrkt(icrs1) = iwrkt(icrs)
1741 iwrk1 = iwrkt(icrs1)
1742 xwrk1 = xdatt(iwrk1)
1745 icrs1 = min(nord, icrs1 + 1)
1746 icrs2 = min(nord, icrs2 + 1)
1749 Do icrs = istrt(idon1), idon + 6
1750 If (xdatt(iwrkt(icrs)) >= xwrk1)
Exit
1753 Do idcr = icrs1 - 1, 1, - 1
1754 If (xwrk >= xdatt(iwrkt(idcr)))
Exit
1755 iwrkt(idcr + 1) = iwrkt(idcr)
1757 iwrkt(idcr + 1) = iwrk
1758 iwrk1 = iwrkt(icrs1)
1759 xwrk1 = xdatt(iwrk1)
1772 nord = nleq - nequ - nmed + 1
1776 Do idon = 1, ntri, 7
1778 If (icrs2 < nord)
Then
1780 Do icrs = idon, iendt(idon1)
1781 If (xdatt(iwrkt(icrs)) > xwrk1)
Then
1785 Do idcr = icrs1 - 1, 1, - 1
1786 If (xwrk <= xdatt(iwrkt(idcr)))
Exit
1787 iwrkt(idcr + 1) = iwrkt(idcr)
1789 iwrkt(idcr + 1) = iwrk
1790 iwrk1 = iwrkt(icrs1)
1791 xwrk1 = xdatt(iwrk1)
1793 If (icrs2 < nord)
Then
1794 iwrkt(icrs1) = iwrkt(icrs)
1795 iwrk1 = iwrkt(icrs1)
1796 xwrk1 = xdatt(iwrk1)
1799 icrs1 = min(nord, icrs1 + 1)
1800 icrs2 = min(nord, icrs2 + 1)
1803 Do icrs = iendt(idon1), idon, -1
1804 If (xdatt(iwrkt(icrs)) <= xwrk1)
Exit
1808 Do idcr = icrs1 - 1, 1, - 1
1809 If (xwrk <= xdatt(iwrkt(idcr)))
Exit
1810 iwrkt(idcr + 1) = iwrkt(idcr)
1812 iwrkt(idcr + 1) = iwrk
1813 iwrk1 = iwrkt(icrs1)
1814 xwrk1 = xdatt(iwrk1)
1823 END Subroutine r_med
1825 Subroutine i_indmed (XDONT, INDM)
1828 Integer(kind = i4),
Dimension (:),
Intent (In) :: XDONT
1829 Integer(kind = i4),
Intent (Out) :: INDM
1831 Integer(kind = i4) :: IDON
1833 Allocate (idont(
SIZE(xdont)))
1834 Do idon = 1,
SIZE(xdont)
1838 Call i_med(xdont, idont, indm)
1841 End Subroutine i_indmed
1843 Recursive Subroutine i_med (XDATT, IDATT, ires_med)
1852 Integer(kind = i4),
Dimension (:),
Intent (In) :: XDATT
1853 Integer(kind = i4),
Dimension (:),
Intent (In) :: IDATT
1854 Integer(kind = i4),
Intent (Out) :: ires_med
1857 Integer(kind = i4),
Parameter :: XHUGE = huge (xdatt)
1858 Integer(kind = i4) :: XWRK, XWRK1, XMED7, XMAX, XMIN
1860 Integer(kind = i4),
Dimension (7 * (((Size (IDATT) + 6) / 7 + 6) / 7)) :: ISTRT, IENDT, IMEDT
1861 Integer(kind = i4),
Dimension (7 * ((Size(IDATT) + 6) / 7)) :: IWRKT
1862 Integer(kind = i4) :: NTRI, NMED, NORD, NEQU, NLEQ, IMED, IDON, IDON1
1863 Integer(kind = i4) :: IDEB, ITMP, IDCR, ICRS, ICRS1, ICRS2, IMAX, IMIN
1864 Integer(kind = i4) :: IWRK, IWRK1, IMED1, IMED7, NDAT
1867 nmed = (ndat + 1) / 2
1877 If (xdatt(iwrkt(1)) < xdatt(iwrkt(idcr)))
Then
1881 iwrkt(idcr) = iwrkt(1)
1884 Do itmp = 1, ndat - 2
1887 xwrk1 = xdatt(iwrk1)
1888 If (xwrk1 < xwrk)
Then
1899 xwrk = xdatt(iwrkt(icrs))
1903 If (xwrk >= xdatt(iwrkt(idcr)))
Exit
1904 iwrkt(idcr + 1) = iwrkt(idcr)
1907 iwrkt(idcr + 1) = iwrk
1912 xwrk1 = xdatt(iwrkt(nmed))
1913 Do icrs = nmed + 1, ndat
1914 xwrk = xdatt(iwrkt(icrs))
1916 If (xwrk < xwrk1)
Then
1919 If (xwrk >= xdatt(iwrkt(idcr)))
Exit
1920 iwrkt(idcr + 1) = iwrkt(idcr)
1923 iwrkt(idcr + 1) = iwrk
1924 xwrk1 = xdatt(iwrkt(nmed))
1927 ires_med = iwrkt(nmed)
1939 xmax = xdatt(iwrkt(imax))
1940 xmin = xdatt(iwrkt(imin))
1941 DO ideb = 1, ndat - 6, 7
1943 If (xdatt(iwrkt(ideb)) < xdatt(iwrkt(idcr)))
Then
1947 iwrkt(idcr) = iwrkt(ideb)
1953 xwrk1 = xdatt(iwrk1)
1954 If (xwrk1 < xwrk)
Then
1961 If (xwrk < xmin)
Then
1965 Do icrs = ideb + 1, ideb + 5
1966 iwrk = iwrkt(icrs + 1)
1969 If (xwrk < xdatt(idon))
Then
1970 iwrkt(icrs + 1) = idon
1972 iwrk1 = iwrkt(idcr - 1)
1973 xwrk1 = xdatt(iwrk1)
1975 If (xwrk >= xwrk1)
Exit
1978 iwrk1 = iwrkt(idcr - 1)
1979 xwrk1 = xdatt(iwrk1)
1984 If (xwrk > xmax)
Then
1993 ideb = 7 * (ndat / 7)
1995 If (ideb < ndat)
Then
1997 Do icrs = ideb + 1, ndat
1998 xwrk1 = xdatt(iwrkt(icrs))
1999 IF (xwrk1 > xmax)
Then
2003 IF (xwrk1 < xmin)
Then
2009 Do icrs = ndat + 1, ideb + 7
2011 If (iwrk1 == imax)
Then
2019 Do icrs = ideb + 2, ideb + 7
2022 Do idcr = icrs - 1, ideb + 1, - 1
2023 If (xwrk >= xdatt(iwrkt(idcr)))
Exit
2024 iwrkt(idcr + 1) = iwrkt(idcr)
2026 iwrkt(idcr + 1) = iwrk
2035 Do idon = 1, ntri, 7
2037 imedt(idon1) = iwrkt(idon + 3)
2042 Call i_med (xdatt, imedt(1 : idon1), imed7)
2043 xmed7 = xdatt(imed7)
2057 Do idon = 1, ntri, 7
2059 If (xdatt(iwrkt(imed)) > xmed7)
Then
2061 If (xdatt(iwrkt(imed)) > xmed7)
Then
2063 Else If (xdatt(iwrkt(imed)) < xmed7)
Then
2066 Else If (xdatt(iwrkt(imed)) < xmed7)
Then
2068 If (xdatt(iwrkt(imed)) > xmed7)
Then
2070 Else If (xdatt(iwrkt(imed)) < xmed7)
Then
2074 If (xdatt(iwrkt(imed)) > xmed7)
Then
2075 nleq = nleq + imed - idon
2076 iendt(idon1) = imed - 1
2078 Else If (xdatt(iwrkt(imed)) < xmed7)
Then
2079 nleq = nleq + imed - idon + 1
2081 istrt(idon1) = imed + 1
2083 nleq = nleq + imed - idon + 1
2085 iendt(idon1) = imed - 1
2086 Do imed1 = imed - 1, idon, -1
2087 If (xdatt(iwrkt(imed1)) == xmed7)
Then
2089 iendt(idon1) = imed1 - 1
2094 istrt(idon1) = imed + 1
2095 Do imed1 = imed + 1, idon + 6
2096 If (xdatt(iwrkt(imed1)) == xmed7)
Then
2099 istrt(idon1) = imed1 + 1
2113 If (nleq - nequ + 1 <= nmed)
Then
2114 If (nleq < nmed)
Then
2116 xwrk1 = xdatt(iwrk1)
2122 Do idon = 1, ntri, 7
2124 If (icrs2 < nord)
Then
2125 Do icrs = istrt(idon1), idon + 6
2126 If (xdatt(iwrkt(icrs)) < xwrk1)
Then
2129 Do idcr = icrs1 - 1, 1, - 1
2130 If (xwrk >= xdatt(iwrkt(idcr)))
Exit
2131 iwrkt(idcr + 1) = iwrkt(idcr)
2133 iwrkt(idcr + 1) = iwrk
2134 iwrk1 = iwrkt(icrs1)
2135 xwrk1 = xdatt(iwrk1)
2137 If (icrs2 < nord)
Then
2138 iwrkt(icrs1) = iwrkt(icrs)
2139 iwrk1 = iwrkt(icrs1)
2140 xwrk1 = xdatt(iwrk1)
2143 icrs1 = min(nord, icrs1 + 1)
2144 icrs2 = min(nord, icrs2 + 1)
2147 Do icrs = istrt(idon1), idon + 6
2148 If (xdatt(iwrkt(icrs)) >= xwrk1)
Exit
2151 Do idcr = icrs1 - 1, 1, - 1
2152 If (xwrk >= xdatt(iwrkt(idcr)))
Exit
2153 iwrkt(idcr + 1) = iwrkt(idcr)
2155 iwrkt(idcr + 1) = iwrk
2156 iwrk1 = iwrkt(icrs1)
2157 xwrk1 = xdatt(iwrk1)
2170 nord = nleq - nequ - nmed + 1
2174 Do idon = 1, ntri, 7
2176 If (icrs2 < nord)
Then
2178 Do icrs = idon, iendt(idon1)
2179 If (xdatt(iwrkt(icrs)) > xwrk1)
Then
2183 Do idcr = icrs1 - 1, 1, - 1
2184 If (xwrk <= xdatt(iwrkt(idcr)))
Exit
2185 iwrkt(idcr + 1) = iwrkt(idcr)
2187 iwrkt(idcr + 1) = iwrk
2188 iwrk1 = iwrkt(icrs1)
2189 xwrk1 = xdatt(iwrk1)
2191 If (icrs2 < nord)
Then
2192 iwrkt(icrs1) = iwrkt(icrs)
2193 iwrk1 = iwrkt(icrs1)
2194 xwrk1 = xdatt(iwrk1)
2197 icrs1 = min(nord, icrs1 + 1)
2198 icrs2 = min(nord, icrs2 + 1)
2201 Do icrs = iendt(idon1), idon, -1
2202 If (xdatt(iwrkt(icrs)) <= xwrk1)
Exit
2206 Do idcr = icrs1 - 1, 1, - 1
2207 If (xwrk <= xdatt(iwrkt(idcr)))
Exit
2208 iwrkt(idcr + 1) = iwrkt(idcr)
2210 iwrkt(idcr + 1) = iwrk
2211 iwrk1 = iwrkt(icrs1)
2212 xwrk1 = xdatt(iwrk1)
2221 END Subroutine i_med
2223 Function d_indnth (XDONT, NORD)
Result (INDNTH)
2238 real(kind =
dp),
Dimension (:),
Intent (In) :: xdont
2239 Integer(kind = i4) :: INDNTH
2240 Integer(kind = i4),
Intent (In) :: NORD
2242 real(kind =
dp) :: xpiv, xwrk, xwrk1, xmin, xmax
2244 Integer(kind = i4),
Dimension (NORD) :: IRNGT
2245 Integer(kind = i4),
Dimension (SIZE(XDONT)) :: ILOWT, IHIGT
2246 Integer(kind = i4) :: NDON, JHIG, JLOW, IHIG, IWRK, IWRK1, IWRK2, IWRK3
2247 Integer(kind = i4) :: IMIL, IFIN, ICRS, IDCR, ILOW
2248 Integer(kind = i4) :: JLM2, JLM1, JHM2, JHM1, INTH
2256 If (inth == 1)
indnth = 1
2263 If (xdont(2) < xdont(1))
Then
2272 If (inth == 1)
indnth = ilowt(1)
2273 If (inth == 2)
indnth = ihigt(1)
2277 If (xdont(3) < xdont(ihigt(1)))
Then
2279 If (xdont(3) < xdont(ilowt(1)))
Then
2290 If (inth == 1)
indnth = ilowt(1)
2291 If (inth == 2)
indnth = ihigt(1)
2292 If (inth == 3)
indnth = ihigt(2)
2296 If (xdont(ndon) < xdont(ihigt(1)))
Then
2299 If (xdont(ndon) < xdont(ilowt(1)))
Then
2310 If (inth == 1)
indnth = ilowt(1)
2311 If (inth == 2)
indnth = ihigt(1)
2312 If (inth == 3)
indnth = ihigt(2)
2313 If (inth == 4)
indnth = ihigt(3)
2320 xpiv = xdont(ilowt(1)) + real(2 * inth,
dp) / real(ndon + inth,
dp) * &
2321 (xdont(ihigt(3)) - xdont(ilowt(1)))
2322 If (xpiv >= xdont(ihigt(1)))
Then
2323 xpiv = xdont(ilowt(1)) + real(2 * inth,
dp) / real(ndon + inth,
dp) * &
2324 (xdont(ihigt(2)) - xdont(ilowt(1)))
2325 If (xpiv >= xdont(ihigt(1))) &
2326 xpiv = xdont(ilowt(1)) + real(2 * inth,
dp) / real(ndon + inth,
dp) * &
2327 (xdont(ihigt(1)) - xdont(ilowt(1)))
2338 If (xdont(ndon) > xpiv)
Then
2342 If (xdont(icrs) > xpiv)
Then
2343 If (icrs >= ndon)
Exit
2349 If (jlow >= inth)
Exit
2356 If (icrs < ndon - 1)
Then
2359 If (xdont(icrs) <= xpiv)
Then
2362 Else If (icrs >= ndon)
Then
2374 Do icrs = 4, ndon - 1
2375 If (xdont(icrs) > xpiv)
Then
2381 If (jlow >= inth)
Exit
2385 If (icrs < ndon - 1)
Then
2388 If (xdont(icrs) <= xpiv)
Then
2389 If (icrs >= ndon)
Exit
2402 If (jlm2 == jlow .And. jhm2 == jhig)
Then
2407 If (inth > jlow)
Then
2408 xmin = xdont(ihigt(1))
2411 If (xdont(ihigt(icrs)) < xmin)
Then
2412 xmin = xdont(ihigt(icrs))
2418 ilowt(jlow) = ihigt(ihig)
2419 ihigt(ihig) = ihigt(jhig)
2426 If (xdont(ilowt(icrs)) > xmax)
Then
2444 Select Case (inth - jlow)
2461 If (xdont(ihigt(1)) <= xdont(ihigt(2)))
Then
2463 ilowt(jlow) = ihigt(1)
2465 ilowt(jlow) = ihigt(2)
2468 ilowt(jlow) = ihigt(2)
2470 ilowt(jlow) = ihigt(1)
2480 If (xdont(iwrk2) < xdont(iwrk1))
Then
2485 If (xdont(iwrk2) > xdont(iwrk3))
Then
2489 If (xdont(iwrk2) < xdont(ihigt(1)))
Then
2495 Do icrs = jlow + 1, inth
2497 ilowt(icrs) = ihigt(jhig)
2514 If (xdont(iwrk2) < xdont(iwrk1))
Then
2519 If (xdont(iwrk2) > xdont(iwrk3))
Then
2523 If (xdont(iwrk2) < xdont(ihigt(1)))
Then
2532 xpiv = xdont(iwrk1) + 0.5 * (xdont(ihigt(ifin)) - xdont(iwrk1))
2542 If (xdont(ihigt(icrs)) <= xpiv)
Then
2544 ilowt(jlow) = ihigt(icrs)
2545 If (jlow >= inth)
Exit
2548 ihigt(jhig) = ihigt(icrs)
2552 Do icrs = icrs + 1, ifin
2553 If (xdont(ihigt(icrs)) <= xpiv)
Then
2555 ilowt(jlow) = ihigt(icrs)
2565 xmin = xdont(ihigt(1))
2568 If (xdont(ihigt(icrs)) < xmin)
Then
2569 xmin = xdont(ihigt(icrs))
2590 ilow = 1 + inth - jlow
2594 Do idcr = icrs - 1, max(1, ilow), - 1
2595 If (xwrk < xdont(irngt(idcr)))
Then
2596 irngt(idcr + 1) = irngt(idcr)
2601 irngt(idcr + 1) = iwrk
2605 xwrk1 = xdont(irngt(inth))
2606 ilow = 2 * inth - jlow
2607 Do icrs = inth + 1, jlow
2608 If (xdont(ilowt(icrs)) < xwrk1)
Then
2609 xwrk = xdont(ilowt(icrs))
2610 Do idcr = inth - 1, max(1, ilow), - 1
2611 If (xwrk >= xdont(irngt(idcr)))
Exit
2612 irngt(idcr + 1) = irngt(idcr)
2614 irngt(idcr + 1) = ilowt(icrs)
2615 xwrk1 = xdont(irngt(inth))
2629 imil = (jlow + 1) / 2
2634 If (xdont(ilowt(imil)) < xdont(ilowt(1)))
Then
2636 ilowt(1) = ilowt(imil)
2639 If (xdont(ilowt(imil)) > xdont(ilowt(ifin)))
Then
2641 ilowt(ifin) = ilowt(imil)
2643 If (xdont(ilowt(imil)) < xdont(ilowt(1)))
Then
2645 ilowt(1) = ilowt(imil)
2651 xpiv = xdont(ilowt(1)) + real(inth,
dp) / real(jlow + inth,
dp) * &
2652 (xdont(ilowt(ifin)) - xdont(ilowt(1)))
2660 If (xdont(ilowt(ifin)) > xpiv)
Then
2664 If (xdont(ilowt(icrs)) > xpiv)
Then
2666 ihigt(jhig) = ilowt(icrs)
2667 If (icrs >= ifin)
Exit
2670 ilowt(jlow) = ilowt(icrs)
2671 If (jlow >= inth)
Exit
2675 If (icrs < ifin)
Then
2678 If (xdont(ilowt(icrs)) <= xpiv)
Then
2680 ilowt(jlow) = ilowt(icrs)
2682 If (icrs >= ifin)
Exit
2688 If (xdont(ilowt(icrs)) > xpiv)
Then
2690 ihigt(jhig) = ilowt(icrs)
2693 ilowt(jlow) = ilowt(icrs)
2694 If (jlow >= inth)
Exit
2698 Do icrs = icrs + 1, ifin
2699 If (xdont(ilowt(icrs)) <= xpiv)
Then
2701 ilowt(jlow) = ilowt(icrs)
2714 xwrk1 = xdont(iwrk1)
2715 Do icrs = 1 + 1, inth
2718 If (xwrk > xwrk1)
Then
2727 End Function d_indnth
2729 Function r_indnth (XDONT, NORD)
Result (INDNTH)
2744 Real(kind =
sp),
Dimension (:),
Intent (In) :: xdont
2745 Integer(kind = i4) :: INDNTH
2746 Integer(kind = i4),
Intent (In) :: NORD
2748 Real(kind =
sp) :: xpiv, xwrk, xwrk1, xmin, xmax
2750 Integer(kind = i4),
Dimension (NORD) :: IRNGT
2751 Integer(kind = i4),
Dimension (SIZE(XDONT)) :: ILOWT, IHIGT
2752 Integer(kind = i4) :: NDON, JHIG, JLOW, IHIG, IWRK, IWRK1, IWRK2, IWRK3
2753 Integer(kind = i4) :: IMIL, IFIN, ICRS, IDCR, ILOW
2754 Integer(kind = i4) :: JLM2, JLM1, JHM2, JHM1, INTH
2762 If (inth == 1)
indnth = 1
2769 If (xdont(2) < xdont(1))
Then
2778 If (inth == 1)
indnth = ilowt(1)
2779 If (inth == 2)
indnth = ihigt(1)
2783 If (xdont(3) < xdont(ihigt(1)))
Then
2785 If (xdont(3) < xdont(ilowt(1)))
Then
2796 If (inth == 1)
indnth = ilowt(1)
2797 If (inth == 2)
indnth = ihigt(1)
2798 If (inth == 3)
indnth = ihigt(2)
2802 If (xdont(ndon) < xdont(ihigt(1)))
Then
2805 If (xdont(ndon) < xdont(ilowt(1)))
Then
2816 If (inth == 1)
indnth = ilowt(1)
2817 If (inth == 2)
indnth = ihigt(1)
2818 If (inth == 3)
indnth = ihigt(2)
2819 If (inth == 4)
indnth = ihigt(3)
2826 xpiv = xdont(ilowt(1)) + real(2 * inth,
sp) / real(ndon + inth,
sp) * &
2827 (xdont(ihigt(3)) - xdont(ilowt(1)))
2828 If (xpiv >= xdont(ihigt(1)))
Then
2829 xpiv = xdont(ilowt(1)) + real(2 * inth,
sp) / real(ndon + inth,
sp) * &
2830 (xdont(ihigt(2)) - xdont(ilowt(1)))
2831 If (xpiv >= xdont(ihigt(1))) &
2832 xpiv = xdont(ilowt(1)) + real(2 * inth,
sp) / real(ndon + inth,
sp) * &
2833 (xdont(ihigt(1)) - xdont(ilowt(1)))
2844 If (xdont(ndon) > xpiv)
Then
2848 If (xdont(icrs) > xpiv)
Then
2849 If (icrs >= ndon)
Exit
2855 If (jlow >= inth)
Exit
2862 If (icrs < ndon - 1)
Then
2865 If (xdont(icrs) <= xpiv)
Then
2868 Else If (icrs >= ndon)
Then
2880 Do icrs = 4, ndon - 1
2881 If (xdont(icrs) > xpiv)
Then
2887 If (jlow >= inth)
Exit
2891 If (icrs < ndon - 1)
Then
2894 If (xdont(icrs) <= xpiv)
Then
2895 If (icrs >= ndon)
Exit
2908 If (jlm2 == jlow .And. jhm2 == jhig)
Then
2913 If (inth > jlow)
Then
2914 xmin = xdont(ihigt(1))
2917 If (xdont(ihigt(icrs)) < xmin)
Then
2918 xmin = xdont(ihigt(icrs))
2924 ilowt(jlow) = ihigt(ihig)
2925 ihigt(ihig) = ihigt(jhig)
2932 If (xdont(ilowt(icrs)) > xmax)
Then
2950 Select Case (inth - jlow)
2967 If (xdont(ihigt(1)) <= xdont(ihigt(2)))
Then
2969 ilowt(jlow) = ihigt(1)
2971 ilowt(jlow) = ihigt(2)
2974 ilowt(jlow) = ihigt(2)
2976 ilowt(jlow) = ihigt(1)
2986 If (xdont(iwrk2) < xdont(iwrk1))
Then
2991 If (xdont(iwrk2) > xdont(iwrk3))
Then
2995 If (xdont(iwrk2) < xdont(ihigt(1)))
Then
3001 Do icrs = jlow + 1, inth
3003 ilowt(icrs) = ihigt(jhig)
3020 If (xdont(iwrk2) < xdont(iwrk1))
Then
3025 If (xdont(iwrk2) > xdont(iwrk3))
Then
3029 If (xdont(iwrk2) < xdont(ihigt(1)))
Then
3038 xpiv = xdont(iwrk1) + 0.5 * (xdont(ihigt(ifin)) - xdont(iwrk1))
3048 If (xdont(ihigt(icrs)) <= xpiv)
Then
3050 ilowt(jlow) = ihigt(icrs)
3051 If (jlow >= inth)
Exit
3054 ihigt(jhig) = ihigt(icrs)
3058 Do icrs = icrs + 1, ifin
3059 If (xdont(ihigt(icrs)) <= xpiv)
Then
3061 ilowt(jlow) = ihigt(icrs)
3071 xmin = xdont(ihigt(1))
3074 If (xdont(ihigt(icrs)) < xmin)
Then
3075 xmin = xdont(ihigt(icrs))
3096 ilow = 1 + inth - jlow
3100 Do idcr = icrs - 1, max(1, ilow), - 1
3101 If (xwrk < xdont(irngt(idcr)))
Then
3102 irngt(idcr + 1) = irngt(idcr)
3107 irngt(idcr + 1) = iwrk
3111 xwrk1 = xdont(irngt(inth))
3112 ilow = 2 * inth - jlow
3113 Do icrs = inth + 1, jlow
3114 If (xdont(ilowt(icrs)) < xwrk1)
Then
3115 xwrk = xdont(ilowt(icrs))
3116 Do idcr = inth - 1, max(1, ilow), - 1
3117 If (xwrk >= xdont(irngt(idcr)))
Exit
3118 irngt(idcr + 1) = irngt(idcr)
3120 irngt(idcr + 1) = ilowt(icrs)
3121 xwrk1 = xdont(irngt(inth))
3135 imil = (jlow + 1) / 2
3140 If (xdont(ilowt(imil)) < xdont(ilowt(1)))
Then
3142 ilowt(1) = ilowt(imil)
3145 If (xdont(ilowt(imil)) > xdont(ilowt(ifin)))
Then
3147 ilowt(ifin) = ilowt(imil)
3149 If (xdont(ilowt(imil)) < xdont(ilowt(1)))
Then
3151 ilowt(1) = ilowt(imil)
3157 xpiv = xdont(ilowt(1)) + real(inth,
sp) / real(jlow + inth,
sp) * &
3158 (xdont(ilowt(ifin)) - xdont(ilowt(1)))
3166 If (xdont(ilowt(ifin)) > xpiv)
Then
3170 If (xdont(ilowt(icrs)) > xpiv)
Then
3172 ihigt(jhig) = ilowt(icrs)
3173 If (icrs >= ifin)
Exit
3176 ilowt(jlow) = ilowt(icrs)
3177 If (jlow >= inth)
Exit
3181 If (icrs < ifin)
Then
3184 If (xdont(ilowt(icrs)) <= xpiv)
Then
3186 ilowt(jlow) = ilowt(icrs)
3188 If (icrs >= ifin)
Exit
3194 If (xdont(ilowt(icrs)) > xpiv)
Then
3196 ihigt(jhig) = ilowt(icrs)
3199 ilowt(jlow) = ilowt(icrs)
3200 If (jlow >= inth)
Exit
3204 Do icrs = icrs + 1, ifin
3205 If (xdont(ilowt(icrs)) <= xpiv)
Then
3207 ilowt(jlow) = ilowt(icrs)
3220 xwrk1 = xdont(iwrk1)
3221 Do icrs = 1 + 1, inth
3224 If (xwrk > xwrk1)
Then
3233 End Function r_indnth
3235 Function i_indnth (XDONT, NORD)
Result (INDNTH)
3250 Integer(kind = i4),
Dimension (:),
Intent (In) :: XDONT
3251 Integer(kind = i4) :: INDNTH
3252 Integer(kind = i4),
Intent (In) :: NORD
3254 Integer(kind = i4) :: XPIV, XWRK, XWRK1, XMIN, XMAX
3256 Integer(kind = i4),
Dimension (NORD) :: IRNGT
3257 Integer(kind = i4),
Dimension (SIZE(XDONT)) :: ILOWT, IHIGT
3258 Integer(kind = i4) :: NDON, JHIG, JLOW, IHIG, IWRK, IWRK1, IWRK2, IWRK3
3259 Integer(kind = i4) :: IMIL, IFIN, ICRS, IDCR, ILOW
3260 Integer(kind = i4) :: JLM2, JLM1, JHM2, JHM1, INTH
3268 If (inth == 1)
indnth = 1
3275 If (xdont(2) < xdont(1))
Then
3284 If (inth == 1)
indnth = ilowt(1)
3285 If (inth == 2)
indnth = ihigt(1)
3289 If (xdont(3) < xdont(ihigt(1)))
Then
3291 If (xdont(3) < xdont(ilowt(1)))
Then
3302 If (inth == 1)
indnth = ilowt(1)
3303 If (inth == 2)
indnth = ihigt(1)
3304 If (inth == 3)
indnth = ihigt(2)
3308 If (xdont(ndon) < xdont(ihigt(1)))
Then
3311 If (xdont(ndon) < xdont(ilowt(1)))
Then
3322 If (inth == 1)
indnth = ilowt(1)
3323 If (inth == 2)
indnth = ihigt(1)
3324 If (inth == 3)
indnth = ihigt(2)
3325 If (inth == 4)
indnth = ihigt(3)
3332 xpiv = xdont(ilowt(1)) + int(real(2 * inth,
sp) / real(ndon + inth,
sp),
i4) * &
3333 (xdont(ihigt(3)) - xdont(ilowt(1)))
3334 If (xpiv >= xdont(ihigt(1)))
Then
3335 xpiv = xdont(ilowt(1)) + int(real(2 * inth,
sp) / real(ndon + inth,
sp),
i4) * &
3336 (xdont(ihigt(2)) - xdont(ilowt(1)))
3337 If (xpiv >= xdont(ihigt(1))) &
3338 xpiv = xdont(ilowt(1)) + int(real(2 * inth,
sp) / real(ndon + inth,
sp),
i4) * &
3339 (xdont(ihigt(1)) - xdont(ilowt(1)))
3350 If (xdont(ndon) > xpiv)
Then
3354 If (xdont(icrs) > xpiv)
Then
3355 If (icrs >= ndon)
Exit
3361 If (jlow >= inth)
Exit
3368 If (icrs < ndon - 1)
Then
3371 If (xdont(icrs) <= xpiv)
Then
3374 Else If (icrs >= ndon)
Then
3386 Do icrs = 4, ndon - 1
3387 If (xdont(icrs) > xpiv)
Then
3393 If (jlow >= inth)
Exit
3397 If (icrs < ndon - 1)
Then
3400 If (xdont(icrs) <= xpiv)
Then
3401 If (icrs >= ndon)
Exit
3414 If (jlm2 == jlow .And. jhm2 == jhig)
Then
3419 If (inth > jlow)
Then
3420 xmin = xdont(ihigt(1))
3423 If (xdont(ihigt(icrs)) < xmin)
Then
3424 xmin = xdont(ihigt(icrs))
3430 ilowt(jlow) = ihigt(ihig)
3431 ihigt(ihig) = ihigt(jhig)
3438 If (xdont(ilowt(icrs)) > xmax)
Then
3456 Select Case (inth - jlow)
3473 If (xdont(ihigt(1)) <= xdont(ihigt(2)))
Then
3475 ilowt(jlow) = ihigt(1)
3477 ilowt(jlow) = ihigt(2)
3480 ilowt(jlow) = ihigt(2)
3482 ilowt(jlow) = ihigt(1)
3492 If (xdont(iwrk2) < xdont(iwrk1))
Then
3497 If (xdont(iwrk2) > xdont(iwrk3))
Then
3501 If (xdont(iwrk2) < xdont(ihigt(1)))
Then
3507 Do icrs = jlow + 1, inth
3509 ilowt(icrs) = ihigt(jhig)
3526 If (xdont(iwrk2) < xdont(iwrk1))
Then
3531 If (xdont(iwrk2) > xdont(iwrk3))
Then
3535 If (xdont(iwrk2) < xdont(ihigt(1)))
Then
3544 xpiv = xdont(iwrk1) + (xdont(ihigt(ifin)) - xdont(iwrk1)) / 2
3554 If (xdont(ihigt(icrs)) <= xpiv)
Then
3556 ilowt(jlow) = ihigt(icrs)
3557 If (jlow >= inth)
Exit
3560 ihigt(jhig) = ihigt(icrs)
3564 Do icrs = icrs + 1, ifin
3565 If (xdont(ihigt(icrs)) <= xpiv)
Then
3567 ilowt(jlow) = ihigt(icrs)
3577 xmin = xdont(ihigt(1))
3580 If (xdont(ihigt(icrs)) < xmin)
Then
3581 xmin = xdont(ihigt(icrs))
3602 ilow = 1 + inth - jlow
3606 Do idcr = icrs - 1, max(1, ilow), - 1
3607 If (xwrk < xdont(irngt(idcr)))
Then
3608 irngt(idcr + 1) = irngt(idcr)
3613 irngt(idcr + 1) = iwrk
3617 xwrk1 = xdont(irngt(inth))
3618 ilow = 2 * inth - jlow
3619 Do icrs = inth + 1, jlow
3620 If (xdont(ilowt(icrs)) < xwrk1)
Then
3621 xwrk = xdont(ilowt(icrs))
3622 Do idcr = inth - 1, max(1, ilow), - 1
3623 If (xwrk >= xdont(irngt(idcr)))
Exit
3624 irngt(idcr + 1) = irngt(idcr)
3626 irngt(idcr + 1) = ilowt(icrs)
3627 xwrk1 = xdont(irngt(inth))
3641 imil = (jlow + 1) / 2
3646 If (xdont(ilowt(imil)) < xdont(ilowt(1)))
Then
3648 ilowt(1) = ilowt(imil)
3651 If (xdont(ilowt(imil)) > xdont(ilowt(ifin)))
Then
3653 ilowt(ifin) = ilowt(imil)
3655 If (xdont(ilowt(imil)) < xdont(ilowt(1)))
Then
3657 ilowt(1) = ilowt(imil)
3663 xpiv = xdont(ilowt(1)) + int(real(inth,
sp) / real(jlow + inth,
sp),
i4) * &
3664 (xdont(ilowt(ifin)) - xdont(ilowt(1)))
3672 If (xdont(ilowt(ifin)) > xpiv)
Then
3676 If (xdont(ilowt(icrs)) > xpiv)
Then
3678 ihigt(jhig) = ilowt(icrs)
3679 If (icrs >= ifin)
Exit
3682 ilowt(jlow) = ilowt(icrs)
3683 If (jlow >= inth)
Exit
3687 If (icrs < ifin)
Then
3690 If (xdont(ilowt(icrs)) <= xpiv)
Then
3692 ilowt(jlow) = ilowt(icrs)
3694 If (icrs >= ifin)
Exit
3700 If (xdont(ilowt(icrs)) > xpiv)
Then
3702 ihigt(jhig) = ilowt(icrs)
3705 ilowt(jlow) = ilowt(icrs)
3706 If (jlow >= inth)
Exit
3710 Do icrs = icrs + 1, ifin
3711 If (xdont(ilowt(icrs)) <= xpiv)
Then
3713 ilowt(jlow) = ilowt(icrs)
3726 xwrk1 = xdont(iwrk1)
3727 Do icrs = 1 + 1, inth
3730 If (xwrk > xwrk1)
Then
3739 End Function i_indnth
3741 Subroutine d_inspar (XDONT, NORD)
3753 real(kind =
dp),
Dimension (:),
Intent (InOut) :: xdont
3754 Integer(kind = i4),
Intent (In) :: NORD
3756 real(kind =
dp) :: xwrk, xwrk1
3758 Integer(kind = i4) :: ICRS, IDCR
3762 Do idcr = icrs - 1, 1, - 1
3763 If (xwrk >= xdont(idcr))
Exit
3764 xdont(idcr + 1) = xdont(idcr)
3766 xdont(idcr + 1) = xwrk
3770 Do icrs = nord + 1,
SIZE (xdont)
3771 If (xdont(icrs) < xwrk1)
Then
3774 Do idcr = nord - 1, 1, - 1
3775 If (xwrk >= xdont(idcr))
Exit
3776 xdont(idcr + 1) = xdont(idcr)
3778 xdont(idcr + 1) = xwrk
3784 End Subroutine d_inspar
3786 Subroutine r_inspar (XDONT, NORD)
3798 Real(kind =
sp),
Dimension (:),
Intent (InOut) :: xdont
3799 Integer(kind = i4),
Intent (In) :: NORD
3801 Real(kind =
sp) :: xwrk, xwrk1
3803 Integer(kind = i4) :: ICRS, IDCR
3807 Do idcr = icrs - 1, 1, - 1
3808 If (xwrk >= xdont(idcr))
Exit
3809 xdont(idcr + 1) = xdont(idcr)
3811 xdont(idcr + 1) = xwrk
3815 Do icrs = nord + 1,
SIZE (xdont)
3816 If (xdont(icrs) < xwrk1)
Then
3819 Do idcr = nord - 1, 1, - 1
3820 If (xwrk >= xdont(idcr))
Exit
3821 xdont(idcr + 1) = xdont(idcr)
3823 xdont(idcr + 1) = xwrk
3829 End Subroutine r_inspar
3831 Subroutine i_inspar (XDONT, NORD)
3843 Integer(kind = i4),
Dimension (:),
Intent (InOut) :: XDONT
3844 Integer(kind = i4),
Intent (In) :: NORD
3846 Integer(kind = i4) :: XWRK, XWRK1
3848 Integer(kind = i4) :: ICRS, IDCR
3852 Do idcr = icrs - 1, 1, - 1
3853 If (xwrk >= xdont(idcr))
Exit
3854 xdont(idcr + 1) = xdont(idcr)
3856 xdont(idcr + 1) = xwrk
3860 Do icrs = nord + 1,
SIZE (xdont)
3861 If (xdont(icrs) < xwrk1)
Then
3864 Do idcr = nord - 1, 1, - 1
3865 If (xwrk >= xdont(idcr))
Exit
3866 xdont(idcr + 1) = xdont(idcr)
3868 xdont(idcr + 1) = xwrk
3874 End Subroutine i_inspar
3876 Subroutine d_inssor (XDONT)
3888 real(kind =
dp),
Dimension (:),
Intent (InOut) :: xdont
3890 real(Kind =
dp) :: xwrk, xmin
3894 Integer(kind = i4) :: ICRS, IDCR, NDON
3902 If (xdont(1) < xdont(ndon))
Then
3906 xdont(ndon) = xdont(1)
3908 Do idcr = ndon - 1, 2, -1
3910 IF (xwrk < xmin)
Then
3924 If (xwrk < xdont(idcr))
Then
3925 xdont(icrs) = xdont(idcr)
3928 If (xwrk >= xdont(idcr))
Exit
3929 xdont(idcr + 1) = xdont(idcr)
3932 xdont(idcr + 1) = xwrk
3938 End Subroutine d_inssor
3940 Subroutine r_inssor (XDONT)
3952 Real(kind =
sp),
Dimension (:),
Intent (InOut) :: xdont
3954 Real(kind =
sp) :: xwrk, xmin
3958 Integer(kind = i4) :: ICRS, IDCR, NDON
3966 If (xdont(1) < xdont(ndon))
Then
3970 xdont(ndon) = xdont(1)
3972 Do idcr = ndon - 1, 2, -1
3974 IF (xwrk < xmin)
Then
3988 If (xwrk < xdont(idcr))
Then
3989 xdont(icrs) = xdont(idcr)
3992 If (xwrk >= xdont(idcr))
Exit
3993 xdont(idcr + 1) = xdont(idcr)
3996 xdont(idcr + 1) = xwrk
4002 End Subroutine r_inssor
4004 Subroutine i_inssor (XDONT)
4016 Integer(kind = i4),
Dimension (:),
Intent (InOut) :: XDONT
4018 Integer(kind = i4) :: XWRK, XMIN
4022 Integer(kind = i4) :: ICRS, IDCR, NDON
4030 If (xdont(1) < xdont(ndon))
Then
4034 xdont(ndon) = xdont(1)
4036 Do idcr = ndon - 1, 2, -1
4038 IF (xwrk < xmin)
Then
4052 If (xwrk < xdont(idcr))
Then
4053 xdont(icrs) = xdont(idcr)
4056 If (xwrk >= xdont(idcr))
Exit
4057 xdont(idcr + 1) = xdont(idcr)
4060 xdont(idcr + 1) = xwrk
4066 End Subroutine i_inssor
4068 Subroutine c_inssor (XDONT)
4080 character(*),
Dimension (:),
Intent (InOut) :: XDONT
4082 character(len(XDONT)) :: XWRK, XMIN
4086 Integer(kind = i4) :: ICRS, IDCR, NDON
4094 If (xdont(1) < xdont(ndon))
Then
4098 xdont(ndon) = xdont(1)
4100 Do idcr = ndon - 1, 2, -1
4102 IF (xwrk < xmin)
Then
4116 If (xwrk < xdont(idcr))
Then
4117 xdont(icrs) = xdont(idcr)
4120 If (xwrk >= xdont(idcr))
Exit
4121 xdont(idcr + 1) = xdont(idcr)
4124 xdont(idcr + 1) = xwrk
4130 End Subroutine c_inssor
4132 Function d_median (XDONT)
Result (median)
4148 real(Kind =
dp),
Dimension (:),
Intent (In) :: xdont
4149 real(Kind =
dp) :: median
4151 real(Kind =
dp),
Dimension (SIZE(XDONT)) :: xlowt, xhigt
4152 real(Kind =
dp) :: xpiv, xwrk, xwrk1, xwrk2, xwrk3, xmin, xmax
4155 Integer(kind = i4) :: NDON, JHIG, JLOW, IHIG
4156 Integer(kind = i4) :: IMIL, IFIN, ICRS, IDCR
4157 Integer(kind = i4) :: JLM2, JLM1, JHM2, JHM1, INTH
4161 ifodd = (2 * inth == ndon + 1)
4166 If (ndon > 0) median = 0.5 * (xdont(1) + xdont(ndon))
4173 If (xdont(2) < xdont(1))
Then
4182 If (xdont(3) < xhigt(1))
Then
4184 If (xdont(3) < xlowt(1))
Then
4199 If (xdont(ndon) < xhigt(1))
Then
4202 If (xdont(ndon) < xlowt(1))
Then
4204 xlowt(1) = xdont(ndon)
4206 xhigt(1) = xdont(ndon)
4209 If (xdont(ndon) < xhigt(2))
Then
4211 xhigt(2) = xdont(ndon)
4213 xhigt(3) = xdont(ndon)
4218 median = 0.5 * (xhigt(1) + xhigt(2))
4224 xpiv = xlowt(1) + 2.0 * (xhigt(3) - xlowt(1)) / 3.0
4225 If (xpiv >= xhigt(1))
Then
4226 xpiv = xlowt(1) + 2.0 * (xhigt(2) - xlowt(1)) / 3.0
4227 If (xpiv >= xhigt(1)) xpiv = xlowt(1) + 2.0 * (xhigt(1) - xlowt(1)) / 3.0
4238 If (xdont(ndon) > xpiv)
Then
4242 If (xdont(icrs) > xpiv)
Then
4243 If (icrs >= ndon)
Exit
4245 xhigt(jhig) = xdont(icrs)
4248 xlowt(jlow) = xdont(icrs)
4249 If (jlow >= inth)
Exit
4256 If (icrs < ndon - 1)
Then
4259 If (xdont(icrs) <= xpiv)
Then
4261 xlowt(jlow) = xdont(icrs)
4262 Else If (icrs >= ndon)
Then
4274 Do icrs = 4, ndon - 1
4275 If (xdont(icrs) > xpiv)
Then
4277 xhigt(jhig) = xdont(icrs)
4280 xlowt(jlow) = xdont(icrs)
4281 If (jlow >= inth)
Exit
4285 If (icrs < ndon - 1)
Then
4288 If (xdont(icrs) <= xpiv)
Then
4289 If (icrs >= ndon)
Exit
4291 xlowt(jlow) = xdont(icrs)
4302 If (jlm2 == jlow .And. jhm2 == jhig)
Then
4307 If (inth > jlow)
Then
4311 If (xhigt(icrs) < xmin)
Then
4318 xlowt(jlow) = xhigt(ihig)
4319 xhigt(ihig) = xhigt(jhig)
4326 If (xlowt(icrs) > xmax)
Then
4342 Select Case (inth - jlow)
4359 If (xhigt(1) <= xhigt(2))
Then
4361 xlowt(jlow) = xhigt(1)
4363 xlowt(jlow) = xhigt(2)
4366 xlowt(jlow) = xhigt(2)
4368 xlowt(jlow) = xhigt(1)
4378 If (xwrk2 < xwrk1)
Then
4383 If (xwrk2 > xwrk3)
Then
4387 If (xwrk2 < xhigt(1))
Then
4393 Do icrs = jlow + 1, inth
4395 xlowt(icrs) = xhigt(jhig)
4412 If (xwrk2 < xwrk1)
Then
4417 If (xwrk2 > xwrk3)
Then
4421 If (xwrk2 < xhigt(1))
Then
4430 xpiv = xwrk1 + 0.5 * (xhigt(ifin) - xwrk1)
4440 If (xhigt(icrs) <= xpiv)
Then
4442 xlowt(jlow) = xhigt(icrs)
4443 If (jlow >= inth)
Exit
4446 xhigt(jhig) = xhigt(icrs)
4450 Do icrs = icrs + 1, ifin
4451 If (xhigt(icrs) <= xpiv)
Then
4453 xlowt(jlow) = xhigt(icrs)
4465 If (xhigt(icrs) < xmin)
Then
4487 jhig = jlow - inth + 1
4489 jhig = jlow - inth + 2
4494 Do idcr = icrs - 1, 1, - 1
4495 If (xwrk < xhigt(idcr))
Then
4496 xhigt(idcr + 1) = xhigt(idcr)
4501 xhigt(idcr + 1) = xwrk
4504 Do icrs = jhig + 1, jlow
4505 If (xlowt(icrs) > xhigt(1))
Then
4508 If (xwrk >= xhigt(idcr))
Then
4509 xhigt(idcr - 1) = xhigt(idcr)
4514 xhigt(idcr - 1) = xwrk
4521 median = 0.5 * (xhigt(1) + xhigt(2))
4531 imil = (jlow + 1) / 2
4536 If (xlowt(imil) < xlowt(1))
Then
4538 xlowt(1) = xlowt(imil)
4541 If (xlowt(imil) > xlowt(ifin))
Then
4543 xlowt(ifin) = xlowt(imil)
4545 If (xlowt(imil) < xlowt(1))
Then
4547 xlowt(1) = xlowt(imil)
4553 xpiv = xlowt(1) + real(inth,
dp) / real(jlow + inth,
dp) * &
4554 (xlowt(ifin) - xlowt(1))
4562 If (xlowt(ifin) > xpiv)
Then
4566 If (xlowt(icrs) > xpiv)
Then
4568 xhigt(jhig) = xlowt(icrs)
4569 If (icrs >= ifin)
Exit
4572 xlowt(jlow) = xlowt(icrs)
4573 If (jlow >= inth)
Exit
4577 If (icrs < ifin)
Then
4580 If (xlowt(icrs) <= xpiv)
Then
4582 xlowt(jlow) = xlowt(icrs)
4584 If (icrs >= ifin)
Exit
4590 If (xlowt(icrs) > xpiv)
Then
4592 xhigt(jhig) = xlowt(icrs)
4595 xlowt(jlow) = xlowt(icrs)
4596 If (jlow >= inth)
Exit
4600 Do icrs = icrs + 1, ifin
4601 If (xlowt(icrs) <= xpiv)
Then
4603 xlowt(jlow) = xlowt(icrs)
4615 median = maxval(xlowt(1 : inth))
4617 xwrk = max(xlowt(1), xlowt(2))
4618 xwrk1 = min(xlowt(1), xlowt(2))
4620 IF (xlowt(icrs) > xwrk1)
THEN
4621 IF (xlowt(icrs) > xwrk)
THEN
4629 median = 0.5 * (xwrk + xwrk1)
4633 End Function d_median
4635 Function r_median (XDONT)
Result (median)
4650 Real(kind =
sp),
Dimension (:),
Intent (In) :: xdont
4651 Real(kind =
sp) :: median
4653 Real(kind =
sp),
Dimension (SIZE(XDONT)) :: xlowt, xhigt
4654 Real(kind =
sp) :: xpiv, xwrk, xwrk1, xwrk2, xwrk3, xmin, xmax
4657 Integer(kind = i4) :: NDON, JHIG, JLOW, IHIG
4658 Integer(kind = i4) :: IMIL, IFIN, ICRS, IDCR
4659 Integer(kind = i4) :: JLM2, JLM1, JHM2, JHM1, INTH
4663 ifodd = (2 * inth == ndon + 1)
4668 If (ndon > 0) median = 0.5 * (xdont(1) + xdont(ndon))
4675 If (xdont(2) < xdont(1))
Then
4684 If (xdont(3) < xhigt(1))
Then
4686 If (xdont(3) < xlowt(1))
Then
4701 If (xdont(ndon) < xhigt(1))
Then
4704 If (xdont(ndon) < xlowt(1))
Then
4706 xlowt(1) = xdont(ndon)
4708 xhigt(1) = xdont(ndon)
4711 If (xdont(ndon) < xhigt(2))
Then
4713 xhigt(2) = xdont(ndon)
4715 xhigt(3) = xdont(ndon)
4720 median = 0.5 * (xhigt(1) + xhigt(2))
4726 xpiv = xlowt(1) + 2.0 * (xhigt(3) - xlowt(1)) / 3.0
4727 If (xpiv >= xhigt(1))
Then
4728 xpiv = xlowt(1) + 2.0 * (xhigt(2) - xlowt(1)) / 3.0
4729 If (xpiv >= xhigt(1)) xpiv = xlowt(1) + 2.0 * (xhigt(1) - xlowt(1)) / 3.0
4740 If (xdont(ndon) > xpiv)
Then
4744 If (xdont(icrs) > xpiv)
Then
4745 If (icrs >= ndon)
Exit
4747 xhigt(jhig) = xdont(icrs)
4750 xlowt(jlow) = xdont(icrs)
4751 If (jlow >= inth)
Exit
4758 If (icrs < ndon - 1)
Then
4761 If (xdont(icrs) <= xpiv)
Then
4763 xlowt(jlow) = xdont(icrs)
4764 Else If (icrs >= ndon)
Then
4776 Do icrs = 4, ndon - 1
4777 If (xdont(icrs) > xpiv)
Then
4779 xhigt(jhig) = xdont(icrs)
4782 xlowt(jlow) = xdont(icrs)
4783 If (jlow >= inth)
Exit
4787 If (icrs < ndon - 1)
Then
4790 If (xdont(icrs) <= xpiv)
Then
4791 If (icrs >= ndon)
Exit
4793 xlowt(jlow) = xdont(icrs)
4804 If (jlm2 == jlow .And. jhm2 == jhig)
Then
4809 If (inth > jlow)
Then
4813 If (xhigt(icrs) < xmin)
Then
4820 xlowt(jlow) = xhigt(ihig)
4821 xhigt(ihig) = xhigt(jhig)
4828 If (xlowt(icrs) > xmax)
Then
4844 Select Case (inth - jlow)
4861 If (xhigt(1) <= xhigt(2))
Then
4863 xlowt(jlow) = xhigt(1)
4865 xlowt(jlow) = xhigt(2)
4868 xlowt(jlow) = xhigt(2)
4870 xlowt(jlow) = xhigt(1)
4880 If (xwrk2 < xwrk1)
Then
4885 If (xwrk2 > xwrk3)
Then
4889 If (xwrk2 < xhigt(1))
Then
4895 Do icrs = jlow + 1, inth
4897 xlowt(icrs) = xhigt(jhig)
4914 If (xwrk2 < xwrk1)
Then
4919 If (xwrk2 > xwrk3)
Then
4923 If (xwrk2 < xhigt(1))
Then
4932 xpiv = xwrk1 + 0.5 * (xhigt(ifin) - xwrk1)
4942 If (xhigt(icrs) <= xpiv)
Then
4944 xlowt(jlow) = xhigt(icrs)
4945 If (jlow >= inth)
Exit
4948 xhigt(jhig) = xhigt(icrs)
4952 Do icrs = icrs + 1, ifin
4953 If (xhigt(icrs) <= xpiv)
Then
4955 xlowt(jlow) = xhigt(icrs)
4967 If (xhigt(icrs) < xmin)
Then
4989 jhig = jlow - inth + 1
4991 jhig = jlow - inth + 2
4996 Do idcr = icrs - 1, 1, - 1
4997 If (xwrk < xhigt(idcr))
Then
4998 xhigt(idcr + 1) = xhigt(idcr)
5003 xhigt(idcr + 1) = xwrk
5006 Do icrs = jhig + 1, jlow
5007 If (xlowt(icrs) > xhigt(1))
Then
5010 If (xwrk >= xhigt(idcr))
Then
5011 xhigt(idcr - 1) = xhigt(idcr)
5016 xhigt(idcr - 1) = xwrk
5023 median = 0.5 * (xhigt(1) + xhigt(2))
5033 imil = (jlow + 1) / 2
5038 If (xlowt(imil) < xlowt(1))
Then
5040 xlowt(1) = xlowt(imil)
5043 If (xlowt(imil) > xlowt(ifin))
Then
5045 xlowt(ifin) = xlowt(imil)
5047 If (xlowt(imil) < xlowt(1))
Then
5049 xlowt(1) = xlowt(imil)
5055 xpiv = xlowt(1) + real(inth,
sp) / real(jlow + inth,
sp) * &
5056 (xlowt(ifin) - xlowt(1))
5064 If (xlowt(ifin) > xpiv)
Then
5068 If (xlowt(icrs) > xpiv)
Then
5070 xhigt(jhig) = xlowt(icrs)
5071 If (icrs >= ifin)
Exit
5074 xlowt(jlow) = xlowt(icrs)
5075 If (jlow >= inth)
Exit
5079 If (icrs < ifin)
Then
5082 If (xlowt(icrs) <= xpiv)
Then
5084 xlowt(jlow) = xlowt(icrs)
5086 If (icrs >= ifin)
Exit
5092 If (xlowt(icrs) > xpiv)
Then
5094 xhigt(jhig) = xlowt(icrs)
5097 xlowt(jlow) = xlowt(icrs)
5098 If (jlow >= inth)
Exit
5102 Do icrs = icrs + 1, ifin
5103 If (xlowt(icrs) <= xpiv)
Then
5105 xlowt(jlow) = xlowt(icrs)
5117 median = maxval(xlowt(1 : inth))
5119 xwrk = max(xlowt(1), xlowt(2))
5120 xwrk1 = min(xlowt(1), xlowt(2))
5122 IF (xlowt(icrs) > xwrk1)
THEN
5123 IF (xlowt(icrs) > xwrk)
THEN
5131 median = 0.5 * (xwrk + xwrk1)
5135 End Function r_median
5137 Function i_median (XDONT)
Result (median)
5152 Integer(kind = i4),
Dimension (:),
Intent (In) :: XDONT
5153 Integer(kind = i4) :: median
5155 Integer(kind = i4),
Dimension (SIZE(XDONT)) :: XLOWT, XHIGT
5156 Integer(kind = i4) :: XPIV, XWRK, XWRK1, XWRK2, XWRK3, XMIN, XMAX
5159 Integer(kind = i4) :: NDON, JHIG, JLOW, IHIG
5160 Integer(kind = i4) :: IMIL, IFIN, ICRS, IDCR
5161 Integer(kind = i4) :: JLM2, JLM1, JHM2, JHM1, INTH
5165 ifodd = (2 * inth == ndon + 1)
5170 If (ndon > 0) median = (xdont(1) + xdont(ndon)) / 2
5177 If (xdont(2) < xdont(1))
Then
5186 If (xdont(3) < xhigt(1))
Then
5188 If (xdont(3) < xlowt(1))
Then
5203 If (xdont(ndon) < xhigt(1))
Then
5206 If (xdont(ndon) < xlowt(1))
Then
5208 xlowt(1) = xdont(ndon)
5210 xhigt(1) = xdont(ndon)
5213 If (xdont(ndon) < xhigt(2))
Then
5215 xhigt(2) = xdont(ndon)
5217 xhigt(3) = xdont(ndon)
5222 median = (xhigt(1) + xhigt(2)) / 2
5228 xpiv = xlowt(1) + 2 * (xhigt(3) - xlowt(1)) / 3
5229 If (xpiv >= xhigt(1))
Then
5230 xpiv = xlowt(1) + 2 * (xhigt(2) - xlowt(1)) / 3
5231 If (xpiv >= xhigt(1)) xpiv = xlowt(1) + 2 * (xhigt(1) - xlowt(1)) / 3
5242 If (xdont(ndon) > xpiv)
Then
5246 If (xdont(icrs) > xpiv)
Then
5247 If (icrs >= ndon)
Exit
5249 xhigt(jhig) = xdont(icrs)
5252 xlowt(jlow) = xdont(icrs)
5253 If (jlow >= inth)
Exit
5260 If (icrs < ndon - 1)
Then
5263 If (xdont(icrs) <= xpiv)
Then
5265 xlowt(jlow) = xdont(icrs)
5266 Else If (icrs >= ndon)
Then
5278 Do icrs = 4, ndon - 1
5279 If (xdont(icrs) > xpiv)
Then
5281 xhigt(jhig) = xdont(icrs)
5284 xlowt(jlow) = xdont(icrs)
5285 If (jlow >= inth)
Exit
5289 If (icrs < ndon - 1)
Then
5292 If (xdont(icrs) <= xpiv)
Then
5293 If (icrs >= ndon)
Exit
5295 xlowt(jlow) = xdont(icrs)
5306 If (jlm2 == jlow .And. jhm2 == jhig)
Then
5311 If (inth > jlow)
Then
5315 If (xhigt(icrs) < xmin)
Then
5322 xlowt(jlow) = xhigt(ihig)
5323 xhigt(ihig) = xhigt(jhig)
5330 If (xlowt(icrs) > xmax)
Then
5346 Select Case (inth - jlow)
5363 If (xhigt(1) <= xhigt(2))
Then
5365 xlowt(jlow) = xhigt(1)
5367 xlowt(jlow) = xhigt(2)
5370 xlowt(jlow) = xhigt(2)
5372 xlowt(jlow) = xhigt(1)
5382 If (xwrk2 < xwrk1)
Then
5387 If (xwrk2 > xwrk3)
Then
5391 If (xwrk2 < xhigt(1))
Then
5397 Do icrs = jlow + 1, inth
5399 xlowt(icrs) = xhigt(jhig)
5416 If (xwrk2 < xwrk1)
Then
5421 If (xwrk2 > xwrk3)
Then
5425 If (xwrk2 < xhigt(1))
Then
5434 xpiv = xwrk1 + (xhigt(ifin) - xwrk1) / 2
5444 If (xhigt(icrs) <= xpiv)
Then
5446 xlowt(jlow) = xhigt(icrs)
5447 If (jlow >= inth)
Exit
5450 xhigt(jhig) = xhigt(icrs)
5454 Do icrs = icrs + 1, ifin
5455 If (xhigt(icrs) <= xpiv)
Then
5457 xlowt(jlow) = xhigt(icrs)
5469 If (xhigt(icrs) < xmin)
Then
5491 jhig = jlow - inth + 1
5493 jhig = jlow - inth + 2
5498 Do idcr = icrs - 1, 1, - 1
5499 If (xwrk < xhigt(idcr))
Then
5500 xhigt(idcr + 1) = xhigt(idcr)
5505 xhigt(idcr + 1) = xwrk
5508 Do icrs = jhig + 1, jlow
5509 If (xlowt(icrs) > xhigt(1))
Then
5512 If (xwrk >= xhigt(idcr))
Then
5513 xhigt(idcr - 1) = xhigt(idcr)
5518 xhigt(idcr - 1) = xwrk
5525 median = (xhigt(1) + xhigt(2)) / 2
5535 imil = (jlow + 1) / 2
5540 If (xlowt(imil) < xlowt(1))
Then
5542 xlowt(1) = xlowt(imil)
5545 If (xlowt(imil) > xlowt(ifin))
Then
5547 xlowt(ifin) = xlowt(imil)
5549 If (xlowt(imil) < xlowt(1))
Then
5551 xlowt(1) = xlowt(imil)
5557 xpiv = xlowt(1) + int(real(inth,
sp) / real(jlow + inth,
sp),
i4) * &
5558 (xlowt(ifin) - xlowt(1))
5566 If (xlowt(ifin) > xpiv)
Then
5570 If (xlowt(icrs) > xpiv)
Then
5572 xhigt(jhig) = xlowt(icrs)
5573 If (icrs >= ifin)
Exit
5576 xlowt(jlow) = xlowt(icrs)
5577 If (jlow >= inth)
Exit
5581 If (icrs < ifin)
Then
5584 If (xlowt(icrs) <= xpiv)
Then
5586 xlowt(jlow) = xlowt(icrs)
5588 If (icrs >= ifin)
Exit
5594 If (xlowt(icrs) > xpiv)
Then
5596 xhigt(jhig) = xlowt(icrs)
5599 xlowt(jlow) = xlowt(icrs)
5600 If (jlow >= inth)
Exit
5604 Do icrs = icrs + 1, ifin
5605 If (xlowt(icrs) <= xpiv)
Then
5607 xlowt(jlow) = xlowt(icrs)
5619 median = maxval(xlowt(1 : inth))
5621 xwrk = max(xlowt(1), xlowt(2))
5622 xwrk1 = min(xlowt(1), xlowt(2))
5624 IF (xlowt(icrs) > xwrk1)
THEN
5625 IF (xlowt(icrs) > xwrk)
THEN
5633 median = (xwrk + xwrk1) / 2
5637 End Function i_median
5639 Subroutine d_mrgref (XVALT, IRNGT)
5647 real(kind =
dp),
Dimension (:),
Intent (In) :: xvalt
5648 Integer(kind = i4),
Dimension (:),
Intent (Out) :: IRNGT
5651 Integer(kind = i4),
Dimension (:),
Allocatable :: JWRKT
5652 Integer(kind = i4) :: LMTNA, LMTNC
5653 Integer(kind = i4) :: NVAL, IIND, IWRKD, IWRK, IWRKF, JINDA, IINDA, IINDB
5655 nval = min(
SIZE(xvalt),
SIZE(irngt))
5662 Do iind = 2, nval, 2
5663 If (xvalt(iind - 1) <= xvalt(iind))
Then
5664 irngt(iind - 1) = iind - 1
5667 irngt(iind - 1) = iind
5668 irngt(iind) = iind - 1
5671 If (modulo(nval, 2) /= 0)
Then
5678 Allocate (jwrkt(1 : nval))
5686 If (lmtna >= nval)
Exit
5696 iwrkf = iinda + lmtnc
5697 jinda = iinda + lmtna
5698 If (iwrkf >= nval)
Then
5699 If (jinda >= nval)
Exit
5707 If (xvalt(irngt(jinda)) <= xvalt(irngt(jinda + 1)))
Then
5715 If (iwrk >= iwrkf)
Then
5719 irngt(iwrkd : iwrkf) = jwrkt(iwrkd : iwrkf)
5727 If (iinda < jinda)
Then
5728 If (iindb < iwrkf)
Then
5729 If (xvalt(irngt(iinda + 1)) > xvalt(irngt(iindb + 1))) &
5732 jwrkt(iwrk) = irngt(iindb)
5735 jwrkt(iwrk) = irngt(iinda)
5742 jwrkt(iwrk) = irngt(iinda)
5748 irngt(iwrkd : iindb) = jwrkt(iwrkd : iindb)
5766 End Subroutine d_mrgref
5768 Subroutine r_mrgref (XVALT, IRNGT)
5776 Real(kind =
sp),
Dimension (:),
Intent (In) :: xvalt
5777 Integer(kind = i4),
Dimension (:),
Intent (Out) :: IRNGT
5780 Integer(kind = i4),
Dimension (:),
Allocatable :: JWRKT
5781 Integer(kind = i4) :: LMTNA, LMTNC
5782 Integer(kind = i4) :: NVAL, IIND, IWRKD, IWRK, IWRKF, JINDA, IINDA, IINDB
5784 nval = min(
SIZE(xvalt),
SIZE(irngt))
5791 Do iind = 2, nval, 2
5792 If (xvalt(iind - 1) <= xvalt(iind))
Then
5793 irngt(iind - 1) = iind - 1
5796 irngt(iind - 1) = iind
5797 irngt(iind) = iind - 1
5800 If (modulo(nval, 2) /= 0)
Then
5807 Allocate (jwrkt(1 : nval))
5815 If (lmtna >= nval)
Exit
5825 iwrkf = iinda + lmtnc
5826 jinda = iinda + lmtna
5827 If (iwrkf >= nval)
Then
5828 If (jinda >= nval)
Exit
5836 If (xvalt(irngt(jinda)) <= xvalt(irngt(jinda + 1)))
Then
5844 If (iwrk >= iwrkf)
Then
5848 irngt(iwrkd : iwrkf) = jwrkt(iwrkd : iwrkf)
5856 If (iinda < jinda)
Then
5857 If (iindb < iwrkf)
Then
5858 If (xvalt(irngt(iinda + 1)) > xvalt(irngt(iindb + 1))) &
5861 jwrkt(iwrk) = irngt(iindb)
5864 jwrkt(iwrk) = irngt(iinda)
5871 jwrkt(iwrk) = irngt(iinda)
5877 irngt(iwrkd : iindb) = jwrkt(iwrkd : iindb)
5895 End Subroutine r_mrgref
5897 Subroutine i_mrgref (XVALT, IRNGT)
5905 Integer(kind = i4),
Dimension (:),
Intent (In) :: XVALT
5906 Integer(kind = i4),
Dimension (:),
Intent (Out) :: IRNGT
5909 Integer(kind = i4),
Dimension (:),
Allocatable :: JWRKT
5910 Integer(kind = i4) :: LMTNA, LMTNC
5911 Integer(kind = i4) :: NVAL, IIND, IWRKD, IWRK, IWRKF, JINDA, IINDA, IINDB
5913 nval = min(
SIZE(xvalt),
SIZE(irngt))
5920 Do iind = 2, nval, 2
5921 If (xvalt(iind - 1) <= xvalt(iind))
Then
5922 irngt(iind - 1) = iind - 1
5925 irngt(iind - 1) = iind
5926 irngt(iind) = iind - 1
5929 If (modulo(nval, 2) /= 0)
Then
5936 Allocate (jwrkt(1 : nval))
5944 If (lmtna >= nval)
Exit
5954 iwrkf = iinda + lmtnc
5955 jinda = iinda + lmtna
5956 If (iwrkf >= nval)
Then
5957 If (jinda >= nval)
Exit
5965 If (xvalt(irngt(jinda)) <= xvalt(irngt(jinda + 1)))
Then
5973 If (iwrk >= iwrkf)
Then
5977 irngt(iwrkd : iwrkf) = jwrkt(iwrkd : iwrkf)
5985 If (iinda < jinda)
Then
5986 If (iindb < iwrkf)
Then
5987 If (xvalt(irngt(iinda + 1)) > xvalt(irngt(iindb + 1))) &
5990 jwrkt(iwrk) = irngt(iindb)
5993 jwrkt(iwrk) = irngt(iinda)
6000 jwrkt(iwrk) = irngt(iinda)
6006 irngt(iwrkd : iindb) = jwrkt(iwrkd : iindb)
6024 End Subroutine i_mrgref
6026 Subroutine d_mrgrnk (XDONT, IRNGT)
6033 real(kind =
dp),
Dimension (:),
Intent (In) :: xdont
6034 Integer(kind = i4),
Dimension (:),
Intent (Out) :: IRNGT
6036 real(kind =
dp) :: xvala, xvalb
6038 Integer(kind = i4),
Dimension (SIZE(IRNGT)) :: JWRKT
6039 Integer(kind = i4) :: LMTNA, LMTNC, IRNG1, IRNG2
6040 Integer(kind = i4) :: NVAL, IIND, IWRKD, IWRK, IWRKF, JINDA, IINDA, IINDB
6042 nval = min(
SIZE(xdont),
SIZE(irngt))
6055 Do iind = 2, nval, 2
6056 If (xdont(iind - 1) <= xdont(iind))
Then
6057 irngt(iind - 1) = iind - 1
6060 irngt(iind - 1) = iind
6061 irngt(iind) = iind - 1
6064 If (modulo(nval, 2) /= 0)
Then
6081 Do iwrkd = 0, nval - 1, 4
6082 If ((iwrkd + 4) > nval)
Then
6083 If ((iwrkd + 2) >= nval)
Exit
6087 If (xdont(irngt(iwrkd + 2)) <= xdont(irngt(iwrkd + 3)))
Exit
6091 If (xdont(irngt(iwrkd + 1)) <= xdont(irngt(iwrkd + 3)))
Then
6092 irng2 = irngt(iwrkd + 2)
6093 irngt(iwrkd + 2) = irngt(iwrkd + 3)
6094 irngt(iwrkd + 3) = irng2
6099 irng1 = irngt(iwrkd + 1)
6100 irngt(iwrkd + 1) = irngt(iwrkd + 3)
6101 irngt(iwrkd + 3) = irngt(iwrkd + 2)
6102 irngt(iwrkd + 2) = irng1
6109 If (xdont(irngt(iwrkd + 2)) <= xdont(irngt(iwrkd + 3))) cycle
6113 If (xdont(irngt(iwrkd + 1)) <= xdont(irngt(iwrkd + 3)))
Then
6114 irng2 = irngt(iwrkd + 2)
6115 irngt(iwrkd + 2) = irngt(iwrkd + 3)
6116 If (xdont(irng2) <= xdont(irngt(iwrkd + 4)))
Then
6118 irngt(iwrkd + 3) = irng2
6121 irngt(iwrkd + 3) = irngt(iwrkd + 4)
6122 irngt(iwrkd + 4) = irng2
6128 irng1 = irngt(iwrkd + 1)
6129 irng2 = irngt(iwrkd + 2)
6130 irngt(iwrkd + 1) = irngt(iwrkd + 3)
6131 If (xdont(irng1) <= xdont(irngt(iwrkd + 4)))
Then
6132 irngt(iwrkd + 2) = irng1
6133 If (xdont(irng2) <= xdont(irngt(iwrkd + 4)))
Then
6135 irngt(iwrkd + 3) = irng2
6138 irngt(iwrkd + 3) = irngt(iwrkd + 4)
6139 irngt(iwrkd + 4) = irng2
6143 irngt(iwrkd + 2) = irngt(iwrkd + 4)
6144 irngt(iwrkd + 3) = irng1
6145 irngt(iwrkd + 4) = irng2
6160 If (lmtna >= nval)
Exit
6169 jinda = iwrkf + lmtna
6170 iwrkf = iwrkf + lmtnc
6171 If (iwrkf >= nval)
Then
6172 If (jinda >= nval)
Exit
6188 jwrkt(1 : lmtna) = irngt(iwrkd : jinda)
6190 xvala = xdont(jwrkt(iinda))
6191 xvalb = xdont(irngt(iindb))
6198 If (xvala > xvalb)
Then
6199 irngt(iwrk) = irngt(iindb)
6201 If (iindb > iwrkf)
Then
6203 irngt(iwrk + 1 : iwrkf) = jwrkt(iinda : lmtna)
6206 xvalb = xdont(irngt(iindb))
6208 irngt(iwrk) = jwrkt(iinda)
6210 If (iinda > lmtna) exit
6211 xvala = xdont(jwrkt(iinda))
6224 End Subroutine d_mrgrnk
6226 Subroutine r_mrgrnk (XDONT, IRNGT)
6233 Real(kind =
sp),
Dimension (:),
Intent (In) :: xdont
6234 Integer(kind = i4),
Dimension (:),
Intent (Out) :: IRNGT
6236 Real(kind =
sp) :: xvala, xvalb
6238 Integer(kind = i4),
Dimension (SIZE(IRNGT)) :: JWRKT
6239 Integer(kind = i4) :: LMTNA, LMTNC, IRNG1, IRNG2
6240 Integer(kind = i4) :: NVAL, IIND, IWRKD, IWRK, IWRKF, JINDA, IINDA, IINDB
6242 nval = min(
SIZE(xdont),
SIZE(irngt))
6255 Do iind = 2, nval, 2
6256 If (xdont(iind - 1) <= xdont(iind))
Then
6257 irngt(iind - 1) = iind - 1
6260 irngt(iind - 1) = iind
6261 irngt(iind) = iind - 1
6264 If (modulo(nval, 2) /= 0)
Then
6281 Do iwrkd = 0, nval - 1, 4
6282 If ((iwrkd + 4) > nval)
Then
6283 If ((iwrkd + 2) >= nval)
Exit
6287 If (xdont(irngt(iwrkd + 2)) <= xdont(irngt(iwrkd + 3)))
Exit
6291 If (xdont(irngt(iwrkd + 1)) <= xdont(irngt(iwrkd + 3)))
Then
6292 irng2 = irngt(iwrkd + 2)
6293 irngt(iwrkd + 2) = irngt(iwrkd + 3)
6294 irngt(iwrkd + 3) = irng2
6299 irng1 = irngt(iwrkd + 1)
6300 irngt(iwrkd + 1) = irngt(iwrkd + 3)
6301 irngt(iwrkd + 3) = irngt(iwrkd + 2)
6302 irngt(iwrkd + 2) = irng1
6309 If (xdont(irngt(iwrkd + 2)) <= xdont(irngt(iwrkd + 3))) cycle
6313 If (xdont(irngt(iwrkd + 1)) <= xdont(irngt(iwrkd + 3)))
Then
6314 irng2 = irngt(iwrkd + 2)
6315 irngt(iwrkd + 2) = irngt(iwrkd + 3)
6316 If (xdont(irng2) <= xdont(irngt(iwrkd + 4)))
Then
6318 irngt(iwrkd + 3) = irng2
6321 irngt(iwrkd + 3) = irngt(iwrkd + 4)
6322 irngt(iwrkd + 4) = irng2
6328 irng1 = irngt(iwrkd + 1)
6329 irng2 = irngt(iwrkd + 2)
6330 irngt(iwrkd + 1) = irngt(iwrkd + 3)
6331 If (xdont(irng1) <= xdont(irngt(iwrkd + 4)))
Then
6332 irngt(iwrkd + 2) = irng1
6333 If (xdont(irng2) <= xdont(irngt(iwrkd + 4)))
Then
6335 irngt(iwrkd + 3) = irng2
6338 irngt(iwrkd + 3) = irngt(iwrkd + 4)
6339 irngt(iwrkd + 4) = irng2
6343 irngt(iwrkd + 2) = irngt(iwrkd + 4)
6344 irngt(iwrkd + 3) = irng1
6345 irngt(iwrkd + 4) = irng2
6360 If (lmtna >= nval)
Exit
6369 jinda = iwrkf + lmtna
6370 iwrkf = iwrkf + lmtnc
6371 If (iwrkf >= nval)
Then
6372 If (jinda >= nval)
Exit
6388 jwrkt(1 : lmtna) = irngt(iwrkd : jinda)
6390 xvala = xdont(jwrkt(iinda))
6391 xvalb = xdont(irngt(iindb))
6398 If (xvala > xvalb)
Then
6399 irngt(iwrk) = irngt(iindb)
6401 If (iindb > iwrkf)
Then
6403 irngt(iwrk + 1 : iwrkf) = jwrkt(iinda : lmtna)
6406 xvalb = xdont(irngt(iindb))
6408 irngt(iwrk) = jwrkt(iinda)
6410 If (iinda > lmtna) exit
6411 xvala = xdont(jwrkt(iinda))
6424 End Subroutine r_mrgrnk
6426 Subroutine i_mrgrnk (XDONT, IRNGT)
6433 Integer(kind = i4),
Dimension (:),
Intent (In) :: XDONT
6434 Integer(kind = i4),
Dimension (:),
Intent (Out) :: IRNGT
6436 Integer(kind = i4) :: XVALA, XVALB
6438 Integer(kind = i4),
Dimension (SIZE(IRNGT)) :: JWRKT
6439 Integer(kind = i4) :: LMTNA, LMTNC, IRNG1, IRNG2
6440 Integer(kind = i4) :: NVAL, IIND, IWRKD, IWRK, IWRKF, JINDA, IINDA, IINDB
6442 nval = min(
SIZE(xdont),
SIZE(irngt))
6455 Do iind = 2, nval, 2
6456 If (xdont(iind - 1) <= xdont(iind))
Then
6457 irngt(iind - 1) = iind - 1
6460 irngt(iind - 1) = iind
6461 irngt(iind) = iind - 1
6464 If (modulo(nval, 2) /= 0)
Then
6481 Do iwrkd = 0, nval - 1, 4
6482 If ((iwrkd + 4) > nval)
Then
6483 If ((iwrkd + 2) >= nval)
Exit
6487 If (xdont(irngt(iwrkd + 2)) <= xdont(irngt(iwrkd + 3)))
Exit
6491 If (xdont(irngt(iwrkd + 1)) <= xdont(irngt(iwrkd + 3)))
Then
6492 irng2 = irngt(iwrkd + 2)
6493 irngt(iwrkd + 2) = irngt(iwrkd + 3)
6494 irngt(iwrkd + 3) = irng2
6499 irng1 = irngt(iwrkd + 1)
6500 irngt(iwrkd + 1) = irngt(iwrkd + 3)
6501 irngt(iwrkd + 3) = irngt(iwrkd + 2)
6502 irngt(iwrkd + 2) = irng1
6509 If (xdont(irngt(iwrkd + 2)) <= xdont(irngt(iwrkd + 3))) cycle
6513 If (xdont(irngt(iwrkd + 1)) <= xdont(irngt(iwrkd + 3)))
Then
6514 irng2 = irngt(iwrkd + 2)
6515 irngt(iwrkd + 2) = irngt(iwrkd + 3)
6516 If (xdont(irng2) <= xdont(irngt(iwrkd + 4)))
Then
6518 irngt(iwrkd + 3) = irng2
6521 irngt(iwrkd + 3) = irngt(iwrkd + 4)
6522 irngt(iwrkd + 4) = irng2
6528 irng1 = irngt(iwrkd + 1)
6529 irng2 = irngt(iwrkd + 2)
6530 irngt(iwrkd + 1) = irngt(iwrkd + 3)
6531 If (xdont(irng1) <= xdont(irngt(iwrkd + 4)))
Then
6532 irngt(iwrkd + 2) = irng1
6533 If (xdont(irng2) <= xdont(irngt(iwrkd + 4)))
Then
6535 irngt(iwrkd + 3) = irng2
6538 irngt(iwrkd + 3) = irngt(iwrkd + 4)
6539 irngt(iwrkd + 4) = irng2
6543 irngt(iwrkd + 2) = irngt(iwrkd + 4)
6544 irngt(iwrkd + 3) = irng1
6545 irngt(iwrkd + 4) = irng2
6560 If (lmtna >= nval)
Exit
6569 jinda = iwrkf + lmtna
6570 iwrkf = iwrkf + lmtnc
6571 If (iwrkf >= nval)
Then
6572 If (jinda >= nval)
Exit
6588 jwrkt(1 : lmtna) = irngt(iwrkd : jinda)
6590 xvala = xdont(jwrkt(iinda))
6591 xvalb = xdont(irngt(iindb))
6598 If (xvala > xvalb)
Then
6599 irngt(iwrk) = irngt(iindb)
6601 If (iindb > iwrkf)
Then
6603 irngt(iwrk + 1 : iwrkf) = jwrkt(iinda : lmtna)
6606 xvalb = xdont(irngt(iindb))
6608 irngt(iwrk) = jwrkt(iinda)
6610 If (iinda > lmtna) exit
6611 xvala = xdont(jwrkt(iinda))
6624 End Subroutine i_mrgrnk
6626 Subroutine c_mrgrnk (XDONT, IRNGT)
6633 character(*),
Dimension (:),
Intent (In) :: XDONT
6634 Integer(kind = i4),
Dimension (:),
Intent (Out) :: IRNGT
6636 character(len(XDONT)) :: XVALA, XVALB
6638 Integer(kind = i4),
Dimension (SIZE(IRNGT)) :: JWRKT
6639 Integer(kind = i4) :: LMTNA, LMTNC, IRNG1, IRNG2
6640 Integer(kind = i4) :: NVAL, IIND, IWRKD, IWRK, IWRKF, JINDA, IINDA, IINDB
6642 nval = min(
SIZE(xdont),
SIZE(irngt))
6655 Do iind = 2, nval, 2
6656 If (xdont(iind - 1) <= xdont(iind))
Then
6657 irngt(iind - 1) = iind - 1
6660 irngt(iind - 1) = iind
6661 irngt(iind) = iind - 1
6664 If (modulo(nval, 2) /= 0)
Then
6681 Do iwrkd = 0, nval - 1, 4
6682 If ((iwrkd + 4) > nval)
Then
6683 If ((iwrkd + 2) >= nval)
Exit
6687 If (xdont(irngt(iwrkd + 2)) <= xdont(irngt(iwrkd + 3)))
Exit
6691 If (xdont(irngt(iwrkd + 1)) <= xdont(irngt(iwrkd + 3)))
Then
6692 irng2 = irngt(iwrkd + 2)
6693 irngt(iwrkd + 2) = irngt(iwrkd + 3)
6694 irngt(iwrkd + 3) = irng2
6699 irng1 = irngt(iwrkd + 1)
6700 irngt(iwrkd + 1) = irngt(iwrkd + 3)
6701 irngt(iwrkd + 3) = irngt(iwrkd + 2)
6702 irngt(iwrkd + 2) = irng1
6709 If (xdont(irngt(iwrkd + 2)) <= xdont(irngt(iwrkd + 3))) cycle
6713 If (xdont(irngt(iwrkd + 1)) <= xdont(irngt(iwrkd + 3)))
Then
6714 irng2 = irngt(iwrkd + 2)
6715 irngt(iwrkd + 2) = irngt(iwrkd + 3)
6716 If (xdont(irng2) <= xdont(irngt(iwrkd + 4)))
Then
6718 irngt(iwrkd + 3) = irng2
6721 irngt(iwrkd + 3) = irngt(iwrkd + 4)
6722 irngt(iwrkd + 4) = irng2
6728 irng1 = irngt(iwrkd + 1)
6729 irng2 = irngt(iwrkd + 2)
6730 irngt(iwrkd + 1) = irngt(iwrkd + 3)
6731 If (xdont(irng1) <= xdont(irngt(iwrkd + 4)))
Then
6732 irngt(iwrkd + 2) = irng1
6733 If (xdont(irng2) <= xdont(irngt(iwrkd + 4)))
Then
6735 irngt(iwrkd + 3) = irng2
6738 irngt(iwrkd + 3) = irngt(iwrkd + 4)
6739 irngt(iwrkd + 4) = irng2
6743 irngt(iwrkd + 2) = irngt(iwrkd + 4)
6744 irngt(iwrkd + 3) = irng1
6745 irngt(iwrkd + 4) = irng2
6760 If (lmtna >= nval)
Exit
6769 jinda = iwrkf + lmtna
6770 iwrkf = iwrkf + lmtnc
6771 If (iwrkf >= nval)
Then
6772 If (jinda >= nval)
Exit
6788 jwrkt(1 : lmtna) = irngt(iwrkd : jinda)
6790 xvala = xdont(jwrkt(iinda))
6791 xvalb = xdont(irngt(iindb))
6798 If (xvala > xvalb)
Then
6799 irngt(iwrk) = irngt(iindb)
6801 If (iindb > iwrkf)
Then
6803 irngt(iwrk + 1 : iwrkf) = jwrkt(iinda : lmtna)
6806 xvalb = xdont(irngt(iindb))
6808 irngt(iwrk) = jwrkt(iinda)
6810 If (iinda > lmtna) exit
6811 xvala = xdont(jwrkt(iinda))
6824 End Subroutine c_mrgrnk
6826 Subroutine d_mulcnt (XDONT, IMULT)
6833 real(kind =
dp),
Dimension (:),
Intent (In) :: xdont
6834 Integer(kind = i4),
Dimension (:),
Intent (Out) :: IMULT
6837 Integer(kind = i4),
Dimension (Size(XDONT)) :: IWRKT
6838 Integer(kind = i4),
Dimension (Size(XDONT)) :: ICNTT
6839 Integer(kind = i4) :: ICRS
6841 Call uniinv (xdont, iwrkt)
6843 Do icrs = 1,
Size(xdont)
6844 icntt(iwrkt(icrs)) = icntt(iwrkt(icrs)) + 1
6846 Do icrs = 1,
Size(xdont)
6847 imult(icrs) = icntt(iwrkt(icrs))
6851 End Subroutine d_mulcnt
6853 Subroutine r_mulcnt (XDONT, IMULT)
6860 Real(kind =
sp),
Dimension (:),
Intent (In) :: xdont
6861 Integer(kind = i4),
Dimension (:),
Intent (Out) :: IMULT
6864 Integer(kind = i4),
Dimension (Size(XDONT)) :: IWRKT
6865 Integer(kind = i4),
Dimension (Size(XDONT)) :: ICNTT
6866 Integer(kind = i4) :: ICRS
6868 Call uniinv (xdont, iwrkt)
6870 Do icrs = 1,
Size(xdont)
6871 icntt(iwrkt(icrs)) = icntt(iwrkt(icrs)) + 1
6873 Do icrs = 1,
Size(xdont)
6874 imult(icrs) = icntt(iwrkt(icrs))
6878 End Subroutine r_mulcnt
6880 Subroutine i_mulcnt (XDONT, IMULT)
6887 Integer(kind = i4),
Dimension (:),
Intent (In) :: XDONT
6888 Integer(kind = i4),
Dimension (:),
Intent (Out) :: IMULT
6891 Integer(kind = i4),
Dimension (Size(XDONT)) :: IWRKT
6892 Integer(kind = i4),
Dimension (Size(XDONT)) :: ICNTT
6893 Integer(kind = i4) :: ICRS
6895 Call uniinv (xdont, iwrkt)
6897 Do icrs = 1,
Size(xdont)
6898 icntt(iwrkt(icrs)) = icntt(iwrkt(icrs)) + 1
6900 Do icrs = 1,
Size(xdont)
6901 imult(icrs) = icntt(iwrkt(icrs))
6905 End Subroutine i_mulcnt
6907 Subroutine d_rapknr (XDONT, IRNGT, NORD)
6924 real(kind =
dp),
Dimension (:),
Intent (In) :: xdont
6925 Integer(kind = i4),
Dimension (:),
Intent (Out) :: IRNGT
6926 Integer(kind = i4),
Intent (In) :: NORD
6928 real(kind =
dp) :: xpiv, xpiv0, xwrk, xwrk1, xmin, xmax
6930 Integer(kind = i4),
Dimension (SIZE(XDONT)) :: ILOWT, IHIGT
6931 Integer(kind = i4) :: NDON, JHIG, JLOW, IHIG, IWRK, IWRK1, IWRK2, IWRK3
6932 Integer(kind = i4) :: IDEB, JDEB, IMIL, IFIN, NWRK, ICRS, IDCR, ILOW
6933 Integer(kind = i4) :: JLM2, JLM1, JHM2, JHM1
6940 If (nord >= 1) irngt(1) = 1
6947 If (xdont(2) < xdont(1))
Then
6956 If (nord >= 1) irngt(1) = ihigt(1)
6957 If (nord >= 2) irngt(2) = ilowt(1)
6961 If (xdont(3) > xdont(ilowt(1)))
Then
6963 If (xdont(3) > xdont(ihigt(1)))
Then
6974 If (nord >= 1) irngt(1) = ihigt(1)
6975 If (nord >= 2) irngt(2) = ilowt(1)
6976 If (nord >= 3) irngt(3) = ilowt(2)
6980 If (xdont(ndon) > xdont(ilowt(1)))
Then
6983 If (xdont(ndon) > xdont(ihigt(1)))
Then
6990 if (xdont(ndon) > xdont(ilowt(2)))
Then
6999 If (nord >= 1) irngt(1) = ihigt(1)
7000 If (nord >= 2) irngt(2) = ilowt(1)
7001 If (nord >= 3) irngt(3) = ilowt(2)
7002 If (nord >= 4) irngt(4) = ilowt(3)
7010 xpiv = xdont(ihigt(ideb)) + real(2 * nord,
dp) / real(ndon + nord,
dp) * &
7011 (xdont(ilowt(3)) - xdont(ihigt(ideb)))
7012 If (xpiv >= xdont(ilowt(1)))
Then
7013 xpiv = xdont(ihigt(ideb)) + real(2 * nord,
dp) / real(ndon + nord,
dp) * &
7014 (xdont(ilowt(2)) - xdont(ihigt(ideb)))
7015 If (xpiv >= xdont(ilowt(1))) &
7016 xpiv = xdont(ihigt(ideb)) + real(2 * nord,
dp) / real(ndon + nord,
dp) * &
7017 (xdont(ilowt(1)) - xdont(ihigt(ideb)))
7029 If (xdont(ndon) < xpiv)
Then
7033 If (xdont(icrs) < xpiv)
Then
7034 If (icrs >= ndon)
Exit
7040 If (jhig >= nord)
Exit
7047 If (icrs < ndon - 1)
Then
7050 If (xdont(icrs) >= xpiv)
Then
7053 Else If (icrs >= ndon)
Then
7065 Do icrs = 4, ndon - 1
7066 If (xdont(icrs) < xpiv)
Then
7072 If (jhig >= nord)
Exit
7076 If (icrs < ndon - 1)
Then
7079 If (xdont(icrs) >= xpiv)
Then
7080 If (icrs >= ndon)
Exit
7093 if (jhig == nord)
Exit
7094 If (jhm2 == jhig .And. jlm2 == jlow)
Then
7099 If (nord > jhig)
Then
7100 xmax = xdont(ilowt(1))
7103 If (xdont(ilowt(icrs)) > xmax)
Then
7104 xmax = xdont(ilowt(icrs))
7110 ihigt(jhig) = ilowt(ilow)
7111 ilowt(ilow) = ilowt(jlow)
7117 If (xdont(ihigt(icrs)) < xmin)
Then
7135 Select Case (nord - jhig)
7150 If (xdont(ilowt(1)) >= xdont(ilowt(2)))
Then
7152 ihigt(jhig) = ilowt(1)
7154 ihigt(jhig) = ilowt(2)
7157 ihigt(jhig) = ilowt(2)
7159 ihigt(jhig) = ilowt(1)
7169 If (xdont(iwrk2) > xdont(iwrk1))
Then
7174 If (xdont(iwrk2) < xdont(iwrk3))
Then
7178 If (xdont(iwrk2) > xdont(ilowt(1)))
Then
7184 Do icrs = jhig + 1, nord
7186 ihigt(icrs) = ilowt(jlow)
7204 If (xdont(iwrk2) > xdont(iwrk1))
Then
7209 If (xdont(iwrk2) < xdont(iwrk3))
Then
7213 If (xdont(iwrk2) > xdont(ihigt(1)))
Then
7224 xpiv = xdont(iwrk1) + real(nwrk,
dp) / real(nord + nwrk,
dp) * &
7225 (xdont(ilowt(ifin)) - xdont(iwrk1))
7235 If (xdont(ilowt(icrs)) >= xpiv)
Then
7237 ihigt(jhig) = ilowt(icrs)
7238 If (jhig >= nord)
Exit
7241 ilowt(jlow) = ilowt(icrs)
7245 Do icrs = icrs + 1, ifin
7246 If (xdont(ilowt(icrs)) >= xpiv)
Then
7248 ihigt(jhig) = ilowt(icrs)
7258 xmax = xdont(ilowt(1))
7261 If (xdont(ilowt(icrs)) > xmax)
Then
7262 xmax = xdont(ilowt(icrs))
7268 ihigt(jhig) = ilowt(ilow)
7287 Do idcr = icrs - 1, 1, - 1
7288 If (xwrk > xdont(irngt(idcr)))
Then
7289 irngt(idcr + 1) = irngt(idcr)
7294 irngt(idcr + 1) = iwrk
7297 xwrk1 = xdont(irngt(nord))
7298 Do icrs = nord + 1, jhig
7299 If (xdont(ihigt(icrs)) > xwrk1)
Then
7300 xwrk = xdont(ihigt(icrs))
7301 Do idcr = nord - 1, 1, - 1
7302 If (xwrk <= xdont(irngt(idcr)))
Exit
7303 irngt(idcr + 1) = irngt(idcr)
7305 irngt(idcr + 1) = ihigt(icrs)
7306 xwrk1 = xdont(irngt(nord))
7318 imil = (jhig + ideb) / 2
7323 If (xdont(ihigt(imil)) > xdont(ihigt(ideb)))
Then
7325 ihigt(ideb) = ihigt(imil)
7328 If (xdont(ihigt(imil)) < xdont(ihigt(ifin)))
Then
7330 ihigt(ifin) = ihigt(imil)
7332 If (xdont(ihigt(imil)) > xdont(ihigt(ideb)))
Then
7334 ihigt(ideb) = ihigt(imil)
7340 xpiv = xdont(ihigt(1)) + real(nord,
sp) / real(jhig + nord,
sp) * &
7341 (xdont(ihigt(ifin)) - xdont(ihigt(1)))
7343 If (xpiv <= xpiv0) &
7344 xpiv = xpiv0 + real(2 * nord - jdeb,
dp) / real(jhig + nord,
dp) * &
7345 (xdont(ihigt(ifin)) - xpiv0)
7357 If (xdont(ihigt(ifin)) < xpiv)
Then
7361 If (xdont(ihigt(icrs)) < xpiv)
Then
7363 ilowt(jlow) = ihigt(icrs)
7364 If (icrs >= ifin)
Exit
7367 ihigt(jhig) = ihigt(icrs)
7368 If (jhig >= nord)
Exit
7372 If (icrs < ifin)
Then
7375 If (xdont(ihigt(icrs)) >= xpiv)
Then
7377 ihigt(jhig) = ihigt(icrs)
7379 If (icrs >= ifin)
Exit
7384 Do icrs = ideb, ifin
7385 If (xdont(ihigt(icrs)) < xpiv)
Then
7387 ilowt(jlow) = ihigt(icrs)
7390 ihigt(jhig) = ihigt(icrs)
7391 If (jhig >= nord)
Exit
7395 Do icrs = icrs + 1, ifin
7396 If (xdont(ihigt(icrs)) >= xpiv)
Then
7398 ihigt(jhig) = ihigt(icrs)
7414 Do idcr = icrs - 1, 1, - 1
7415 If (xwrk > xdont(irngt(idcr)))
Then
7416 irngt(idcr + 1) = irngt(idcr)
7421 irngt(idcr + 1) = iwrk
7426 End Subroutine d_rapknr
7428 Subroutine r_rapknr (XDONT, IRNGT, NORD)
7446 Real(kind =
sp),
Dimension (:),
Intent (In) :: xdont
7447 Integer(kind = i4),
Dimension (:),
Intent (Out) :: IRNGT
7448 Integer(kind = i4),
Intent (In) :: NORD
7450 Real(kind =
sp) :: xpiv, xpiv0, xwrk, xwrk1, xmin, xmax
7452 Integer(kind = i4),
Dimension (SIZE(XDONT)) :: ILOWT, IHIGT
7453 Integer(kind = i4) :: NDON, JHIG, JLOW, IHIG, IWRK, IWRK1, IWRK2, IWRK3
7454 Integer(kind = i4) :: IDEB, JDEB, IMIL, IFIN, NWRK, ICRS, IDCR, ILOW
7455 Integer(kind = i4) :: JLM2, JLM1, JHM2, JHM1
7462 If (nord >= 1) irngt(1) = 1
7469 If (xdont(2) < xdont(1))
Then
7478 If (nord >= 1) irngt(1) = ihigt(1)
7479 If (nord >= 2) irngt(2) = ilowt(1)
7483 If (xdont(3) > xdont(ilowt(1)))
Then
7485 If (xdont(3) > xdont(ihigt(1)))
Then
7496 If (nord >= 1) irngt(1) = ihigt(1)
7497 If (nord >= 2) irngt(2) = ilowt(1)
7498 If (nord >= 3) irngt(3) = ilowt(2)
7502 If (xdont(ndon) > xdont(ilowt(1)))
Then
7505 If (xdont(ndon) > xdont(ihigt(1)))
Then
7512 if (xdont(ndon) > xdont(ilowt(2)))
Then
7521 If (nord >= 1) irngt(1) = ihigt(1)
7522 If (nord >= 2) irngt(2) = ilowt(1)
7523 If (nord >= 3) irngt(3) = ilowt(2)
7524 If (nord >= 4) irngt(4) = ilowt(3)
7532 xpiv = xdont(ihigt(ideb)) + real(2 * nord,
sp) / real(ndon + nord,
sp) * &
7533 (xdont(ilowt(3)) - xdont(ihigt(ideb)))
7534 If (xpiv >= xdont(ilowt(1)))
Then
7535 xpiv = xdont(ihigt(ideb)) + real(2 * nord,
sp) / real(ndon + nord,
sp) * &
7536 (xdont(ilowt(2)) - xdont(ihigt(ideb)))
7537 If (xpiv >= xdont(ilowt(1))) &
7538 xpiv = xdont(ihigt(ideb)) + real(2 * nord,
sp) / real(ndon + nord,
sp) * &
7539 (xdont(ilowt(1)) - xdont(ihigt(ideb)))
7551 If (xdont(ndon) < xpiv)
Then
7555 If (xdont(icrs) < xpiv)
Then
7556 If (icrs >= ndon)
Exit
7562 If (jhig >= nord)
Exit
7569 If (icrs < ndon - 1)
Then
7572 If (xdont(icrs) >= xpiv)
Then
7575 Else If (icrs >= ndon)
Then
7587 Do icrs = 4, ndon - 1
7588 If (xdont(icrs) < xpiv)
Then
7594 If (jhig >= nord)
Exit
7598 If (icrs < ndon - 1)
Then
7601 If (xdont(icrs) >= xpiv)
Then
7602 If (icrs >= ndon)
Exit
7615 if (jhig == nord)
Exit
7616 If (jhm2 == jhig .And. jlm2 == jlow)
Then
7621 If (nord > jhig)
Then
7622 xmax = xdont(ilowt(1))
7625 If (xdont(ilowt(icrs)) > xmax)
Then
7626 xmax = xdont(ilowt(icrs))
7632 ihigt(jhig) = ilowt(ilow)
7633 ilowt(ilow) = ilowt(jlow)
7639 If (xdont(ihigt(icrs)) < xmin)
Then
7657 Select Case (nord - jhig)
7672 If (xdont(ilowt(1)) >= xdont(ilowt(2)))
Then
7674 ihigt(jhig) = ilowt(1)
7676 ihigt(jhig) = ilowt(2)
7679 ihigt(jhig) = ilowt(2)
7681 ihigt(jhig) = ilowt(1)
7691 If (xdont(iwrk2) > xdont(iwrk1))
Then
7696 If (xdont(iwrk2) < xdont(iwrk3))
Then
7700 If (xdont(iwrk2) > xdont(ilowt(1)))
Then
7706 Do icrs = jhig + 1, nord
7708 ihigt(icrs) = ilowt(jlow)
7726 If (xdont(iwrk2) > xdont(iwrk1))
Then
7731 If (xdont(iwrk2) < xdont(iwrk3))
Then
7735 If (xdont(iwrk2) > xdont(ihigt(1)))
Then
7746 xpiv = xdont(iwrk1) + real(nwrk,
sp) / real(nord + nwrk,
sp) * &
7747 (xdont(ilowt(ifin)) - xdont(iwrk1))
7757 If (xdont(ilowt(icrs)) >= xpiv)
Then
7759 ihigt(jhig) = ilowt(icrs)
7760 If (jhig >= nord)
Exit
7763 ilowt(jlow) = ilowt(icrs)
7767 Do icrs = icrs + 1, ifin
7768 If (xdont(ilowt(icrs)) >= xpiv)
Then
7770 ihigt(jhig) = ilowt(icrs)
7780 xmax = xdont(ilowt(1))
7783 If (xdont(ilowt(icrs)) > xmax)
Then
7784 xmax = xdont(ilowt(icrs))
7790 ihigt(jhig) = ilowt(ilow)
7809 Do idcr = icrs - 1, 1, - 1
7810 If (xwrk > xdont(irngt(idcr)))
Then
7811 irngt(idcr + 1) = irngt(idcr)
7816 irngt(idcr + 1) = iwrk
7819 xwrk1 = xdont(irngt(nord))
7820 Do icrs = nord + 1, jhig
7821 If (xdont(ihigt(icrs)) > xwrk1)
Then
7822 xwrk = xdont(ihigt(icrs))
7823 Do idcr = nord - 1, 1, - 1
7824 If (xwrk <= xdont(irngt(idcr)))
Exit
7825 irngt(idcr + 1) = irngt(idcr)
7827 irngt(idcr + 1) = ihigt(icrs)
7828 xwrk1 = xdont(irngt(nord))
7840 imil = (jhig + ideb) / 2
7845 If (xdont(ihigt(imil)) > xdont(ihigt(ideb)))
Then
7847 ihigt(ideb) = ihigt(imil)
7850 If (xdont(ihigt(imil)) < xdont(ihigt(ifin)))
Then
7852 ihigt(ifin) = ihigt(imil)
7854 If (xdont(ihigt(imil)) > xdont(ihigt(ideb)))
Then
7856 ihigt(ideb) = ihigt(imil)
7862 xpiv = xdont(ihigt(1)) + real(nord,
sp) / real(jhig + nord,
sp) * &
7863 (xdont(ihigt(ifin)) - xdont(ihigt(1)))
7865 If (xpiv <= xpiv0) &
7866 xpiv = xpiv0 + real(2 * nord - jdeb,
sp) / real(jhig + nord,
sp) * &
7867 (xdont(ihigt(ifin)) - xpiv0)
7879 If (xdont(ihigt(ifin)) < xpiv)
Then
7883 If (xdont(ihigt(icrs)) < xpiv)
Then
7885 ilowt(jlow) = ihigt(icrs)
7886 If (icrs >= ifin)
Exit
7889 ihigt(jhig) = ihigt(icrs)
7890 If (jhig >= nord)
Exit
7894 If (icrs < ifin)
Then
7897 If (xdont(ihigt(icrs)) >= xpiv)
Then
7899 ihigt(jhig) = ihigt(icrs)
7901 If (icrs >= ifin)
Exit
7906 Do icrs = ideb, ifin
7907 If (xdont(ihigt(icrs)) < xpiv)
Then
7909 ilowt(jlow) = ihigt(icrs)
7912 ihigt(jhig) = ihigt(icrs)
7913 If (jhig >= nord)
Exit
7917 Do icrs = icrs + 1, ifin
7918 If (xdont(ihigt(icrs)) >= xpiv)
Then
7920 ihigt(jhig) = ihigt(icrs)
7936 Do idcr = icrs - 1, 1, - 1
7937 If (xwrk > xdont(irngt(idcr)))
Then
7938 irngt(idcr + 1) = irngt(idcr)
7943 irngt(idcr + 1) = iwrk
7948 End Subroutine r_rapknr
7950 Subroutine i_rapknr (XDONT, IRNGT, NORD)
7968 Integer(kind = i4),
Dimension (:),
Intent (In) :: XDONT
7969 Integer(kind = i4),
Dimension (:),
Intent (Out) :: IRNGT
7970 Integer(kind = i4),
Intent (In) :: NORD
7972 Integer(kind = i4) :: XPIV, XPIV0, XWRK, XWRK1, XMIN, XMAX
7974 Integer(kind = i4),
Dimension (SIZE(XDONT)) :: ILOWT, IHIGT
7975 Integer(kind = i4) :: NDON, JHIG, JLOW, IHIG, IWRK, IWRK1, IWRK2, IWRK3
7976 Integer(kind = i4) :: IDEB, JDEB, IMIL, IFIN, NWRK, ICRS, IDCR, ILOW
7977 Integer(kind = i4) :: JLM2, JLM1, JHM2, JHM1
7984 If (nord >= 1) irngt(1) = 1
7991 If (xdont(2) < xdont(1))
Then
8000 If (nord >= 1) irngt(1) = ihigt(1)
8001 If (nord >= 2) irngt(2) = ilowt(1)
8005 If (xdont(3) > xdont(ilowt(1)))
Then
8007 If (xdont(3) > xdont(ihigt(1)))
Then
8018 If (nord >= 1) irngt(1) = ihigt(1)
8019 If (nord >= 2) irngt(2) = ilowt(1)
8020 If (nord >= 3) irngt(3) = ilowt(2)
8024 If (xdont(ndon) > xdont(ilowt(1)))
Then
8027 If (xdont(ndon) > xdont(ihigt(1)))
Then
8034 if (xdont(ndon) > xdont(ilowt(2)))
Then
8043 If (nord >= 1) irngt(1) = ihigt(1)
8044 If (nord >= 2) irngt(2) = ilowt(1)
8045 If (nord >= 3) irngt(3) = ilowt(2)
8046 If (nord >= 4) irngt(4) = ilowt(3)
8054 xpiv = xdont(ihigt(ideb)) + int(real(2 * nord,
sp) / real(ndon + nord,
sp),
i4) * &
8055 (xdont(ilowt(3)) - xdont(ihigt(ideb)))
8056 If (xpiv >= xdont(ilowt(1)))
Then
8057 xpiv = xdont(ihigt(ideb)) + int(real(2 * nord,
sp) / real(ndon + nord,
sp),
i4) * &
8058 (xdont(ilowt(2)) - xdont(ihigt(ideb)))
8059 If (xpiv >= xdont(ilowt(1))) &
8060 xpiv = xdont(ihigt(ideb)) + int(real(2 * nord,
sp) / real(ndon + nord,
sp),
i4) * &
8061 (xdont(ilowt(1)) - xdont(ihigt(ideb)))
8073 If (xdont(ndon) < xpiv)
Then
8077 If (xdont(icrs) < xpiv)
Then
8078 If (icrs >= ndon)
Exit
8084 If (jhig >= nord)
Exit
8091 If (icrs < ndon - 1)
Then
8094 If (xdont(icrs) >= xpiv)
Then
8097 Else If (icrs >= ndon)
Then
8109 Do icrs = 4, ndon - 1
8110 If (xdont(icrs) < xpiv)
Then
8116 If (jhig >= nord)
Exit
8120 If (icrs < ndon - 1)
Then
8123 If (xdont(icrs) >= xpiv)
Then
8124 If (icrs >= ndon)
Exit
8137 if (jhig == nord)
Exit
8138 If (jhm2 == jhig .And. jlm2 == jlow)
Then
8143 If (nord > jhig)
Then
8144 xmax = xdont(ilowt(1))
8147 If (xdont(ilowt(icrs)) > xmax)
Then
8148 xmax = xdont(ilowt(icrs))
8154 ihigt(jhig) = ilowt(ilow)
8155 ilowt(ilow) = ilowt(jlow)
8161 If (xdont(ihigt(icrs)) < xmin)
Then
8179 Select Case (nord - jhig)
8194 If (xdont(ilowt(1)) >= xdont(ilowt(2)))
Then
8196 ihigt(jhig) = ilowt(1)
8198 ihigt(jhig) = ilowt(2)
8201 ihigt(jhig) = ilowt(2)
8203 ihigt(jhig) = ilowt(1)
8213 If (xdont(iwrk2) > xdont(iwrk1))
Then
8218 If (xdont(iwrk2) < xdont(iwrk3))
Then
8222 If (xdont(iwrk2) > xdont(ilowt(1)))
Then
8228 Do icrs = jhig + 1, nord
8230 ihigt(icrs) = ilowt(jlow)
8248 If (xdont(iwrk2) > xdont(iwrk1))
Then
8253 If (xdont(iwrk2) < xdont(iwrk3))
Then
8257 If (xdont(iwrk2) > xdont(ihigt(1)))
Then
8268 xpiv = xdont(iwrk1) + int(real(nwrk,
sp) / real(nord + nwrk,
sp),
i4) * &
8269 (xdont(ilowt(ifin)) - xdont(iwrk1))
8279 If (xdont(ilowt(icrs)) >= xpiv)
Then
8281 ihigt(jhig) = ilowt(icrs)
8282 If (jhig >= nord)
Exit
8285 ilowt(jlow) = ilowt(icrs)
8289 Do icrs = icrs + 1, ifin
8290 If (xdont(ilowt(icrs)) >= xpiv)
Then
8292 ihigt(jhig) = ilowt(icrs)
8302 xmax = xdont(ilowt(1))
8305 If (xdont(ilowt(icrs)) > xmax)
Then
8306 xmax = xdont(ilowt(icrs))
8312 ihigt(jhig) = ilowt(ilow)
8331 Do idcr = icrs - 1, 1, - 1
8332 If (xwrk > xdont(irngt(idcr)))
Then
8333 irngt(idcr + 1) = irngt(idcr)
8338 irngt(idcr + 1) = iwrk
8341 xwrk1 = xdont(irngt(nord))
8342 Do icrs = nord + 1, jhig
8343 If (xdont(ihigt(icrs)) > xwrk1)
Then
8344 xwrk = xdont(ihigt(icrs))
8345 Do idcr = nord - 1, 1, - 1
8346 If (xwrk <= xdont(irngt(idcr)))
Exit
8347 irngt(idcr + 1) = irngt(idcr)
8349 irngt(idcr + 1) = ihigt(icrs)
8350 xwrk1 = xdont(irngt(nord))
8362 imil = (jhig + ideb) / 2
8367 If (xdont(ihigt(imil)) > xdont(ihigt(ideb)))
Then
8369 ihigt(ideb) = ihigt(imil)
8372 If (xdont(ihigt(imil)) < xdont(ihigt(ifin)))
Then
8374 ihigt(ifin) = ihigt(imil)
8376 If (xdont(ihigt(imil)) > xdont(ihigt(ideb)))
Then
8378 ihigt(ideb) = ihigt(imil)
8384 xpiv = xdont(ihigt(1)) + int(real(nord,
sp) / real(jhig + nord,
sp),
i4) * &
8385 (xdont(ihigt(ifin)) - xdont(ihigt(1)))
8387 If (xpiv <= xpiv0) &
8388 xpiv = xpiv0 + int(real(2 * nord - jdeb,
sp) / real(jhig + nord,
sp),
i4) * &
8389 (xdont(ihigt(ifin)) - xpiv0)
8401 If (xdont(ihigt(ifin)) < xpiv)
Then
8405 If (xdont(ihigt(icrs)) < xpiv)
Then
8407 ilowt(jlow) = ihigt(icrs)
8408 If (icrs >= ifin)
Exit
8411 ihigt(jhig) = ihigt(icrs)
8412 If (jhig >= nord)
Exit
8416 If (icrs < ifin)
Then
8419 If (xdont(ihigt(icrs)) >= xpiv)
Then
8421 ihigt(jhig) = ihigt(icrs)
8423 If (icrs >= ifin)
Exit
8428 Do icrs = ideb, ifin
8429 If (xdont(ihigt(icrs)) < xpiv)
Then
8431 ilowt(jlow) = ihigt(icrs)
8434 ihigt(jhig) = ihigt(icrs)
8435 If (jhig >= nord)
Exit
8439 Do icrs = icrs + 1, ifin
8440 If (xdont(ihigt(icrs)) >= xpiv)
Then
8442 ihigt(jhig) = ihigt(icrs)
8458 Do idcr = icrs - 1, 1, - 1
8459 If (xwrk > xdont(irngt(idcr)))
Then
8460 irngt(idcr + 1) = irngt(idcr)
8465 irngt(idcr + 1) = iwrk
8470 End Subroutine i_rapknr
8472 Subroutine d_refpar (XDONT, IRNGT, NORD)
8484 real(kind =
dp),
Dimension (:),
Intent (In) :: xdont
8485 Integer(kind = i4),
Dimension (:),
Intent (Out) :: IRNGT
8486 Integer(kind = i4),
Intent (In) :: NORD
8488 real(kind =
dp) :: xpiv, xwrk
8491 Integer(kind = i4),
Dimension (SIZE(XDONT)) :: IWRKT
8492 Integer(kind = i4) :: NDON, ICRS, IDEB, IDCR, IFIN, IMIL, IWRK
8502 If (ideb >= ifin)
Exit
8503 imil = (ideb + ifin) / 2
8507 If (xdont(iwrkt(imil)) < xdont(iwrkt(ideb)))
Then
8509 iwrkt(ideb) = iwrkt(imil)
8512 If (xdont(iwrkt(imil)) > xdont(iwrkt(ifin)))
Then
8514 iwrkt(ifin) = iwrkt(imil)
8516 If (xdont(iwrkt(imil)) < xdont(iwrkt(ideb)))
Then
8518 iwrkt(ideb) = iwrkt(imil)
8522 If ((ifin - ideb) < 3)
Exit
8523 xpiv = xdont(iwrkt(imil))
8533 If (icrs >= idcr)
Then
8545 If (xdont(iwrkt(icrs)) > xpiv)
Exit
8548 If (xdont(iwrkt(idcr)) <= xpiv)
Exit
8550 If (icrs >= idcr)
Then
8559 iwrkt(idcr) = iwrkt(icrs)
8565 If (icrs <= nord) ideb = icrs
8566 If (icrs > nord) ifin = icrs - 1
8575 Do idcr = icrs - 1, 1, - 1
8576 If (xwrk <= xdont(iwrkt(idcr)))
Then
8577 iwrkt(idcr + 1) = iwrkt(idcr)
8582 iwrkt(idcr + 1) = iwrk
8584 irngt(1 : nord) = iwrkt(1 : nord)
8587 End Subroutine d_refpar
8589 Subroutine r_refpar (XDONT, IRNGT, NORD)
8601 Real(kind =
sp),
Dimension (:),
Intent (In) :: xdont
8602 Integer(kind = i4),
Dimension (:),
Intent (Out) :: IRNGT
8603 Integer(kind = i4),
Intent (In) :: NORD
8605 Real(kind =
sp) :: xpiv, xwrk
8608 Integer(kind = i4),
Dimension (SIZE(XDONT)) :: IWRKT
8609 Integer(kind = i4) :: NDON, ICRS, IDEB, IDCR, IFIN, IMIL, IWRK
8619 If (ideb >= ifin)
Exit
8620 imil = (ideb + ifin) / 2
8624 If (xdont(iwrkt(imil)) < xdont(iwrkt(ideb)))
Then
8626 iwrkt(ideb) = iwrkt(imil)
8629 If (xdont(iwrkt(imil)) > xdont(iwrkt(ifin)))
Then
8631 iwrkt(ifin) = iwrkt(imil)
8633 If (xdont(iwrkt(imil)) < xdont(iwrkt(ideb)))
Then
8635 iwrkt(ideb) = iwrkt(imil)
8639 If ((ifin - ideb) < 3)
Exit
8640 xpiv = xdont(iwrkt(imil))
8650 If (icrs >= idcr)
Then
8662 If (xdont(iwrkt(icrs)) > xpiv)
Exit
8665 If (xdont(iwrkt(idcr)) <= xpiv)
Exit
8667 If (icrs >= idcr)
Then
8676 iwrkt(idcr) = iwrkt(icrs)
8682 If (icrs <= nord) ideb = icrs
8683 If (icrs > nord) ifin = icrs - 1
8692 Do idcr = icrs - 1, 1, - 1
8693 If (xwrk <= xdont(iwrkt(idcr)))
Then
8694 iwrkt(idcr + 1) = iwrkt(idcr)
8699 iwrkt(idcr + 1) = iwrk
8701 irngt(1 : nord) = iwrkt(1 : nord)
8704 End Subroutine r_refpar
8706 Subroutine i_refpar (XDONT, IRNGT, NORD)
8718 Integer(kind = i4),
Dimension (:),
Intent (In) :: XDONT
8719 Integer(kind = i4),
Dimension (:),
Intent (Out) :: IRNGT
8720 Integer(kind = i4),
Intent (In) :: NORD
8722 Integer(kind = i4) :: XPIV, XWRK
8724 Integer(kind = i4),
Dimension (SIZE(XDONT)) :: IWRKT
8725 Integer(kind = i4) :: NDON, ICRS, IDEB, IDCR, IFIN, IMIL, IWRK
8735 If (ideb >= ifin)
Exit
8736 imil = (ideb + ifin) / 2
8740 If (xdont(iwrkt(imil)) < xdont(iwrkt(ideb)))
Then
8742 iwrkt(ideb) = iwrkt(imil)
8745 If (xdont(iwrkt(imil)) > xdont(iwrkt(ifin)))
Then
8747 iwrkt(ifin) = iwrkt(imil)
8749 If (xdont(iwrkt(imil)) < xdont(iwrkt(ideb)))
Then
8751 iwrkt(ideb) = iwrkt(imil)
8755 If ((ifin - ideb) < 3)
Exit
8756 xpiv = xdont(iwrkt(imil))
8766 If (icrs >= idcr)
Then
8778 If (xdont(iwrkt(icrs)) > xpiv)
Exit
8781 If (xdont(iwrkt(idcr)) <= xpiv)
Exit
8783 If (icrs >= idcr)
Then
8792 iwrkt(idcr) = iwrkt(icrs)
8798 If (icrs <= nord) ideb = icrs
8799 If (icrs > nord) ifin = icrs - 1
8808 Do idcr = icrs - 1, 1, - 1
8809 If (xwrk <= xdont(iwrkt(idcr)))
Then
8810 iwrkt(idcr + 1) = iwrkt(idcr)
8815 iwrkt(idcr + 1) = iwrk
8817 irngt(1 : nord) = iwrkt(1 : nord)
8820 End Subroutine i_refpar
8822 Subroutine d_refsor (XDONT)
8837 real(kind =
dp),
Dimension (:),
Intent (InOut) :: xdont
8841 Call d_subsor (xdont, 1,
Size (xdont))
8842 Call d_inssor (xdont)
8844 End Subroutine d_refsor
8846 Recursive Subroutine d_subsor (XDONT, IDEB1, IFIN1)
8849 Real(kind =
dp),
dimension (:),
Intent (InOut) :: xdont
8850 Integer(kind = i4),
Intent (In) :: IDEB1, IFIN1
8852 Integer(kind = i4),
Parameter :: NINS = 16
8853 Integer(kind = i4) :: ICRS, IDEB, IDCR, IFIN, IMIL
8854 Real(kind =
dp) :: xpiv, xwrk
8862 If ((ifin - ideb) > nins)
Then
8863 imil = (ideb + ifin) / 2
8867 If (xdont(imil) < xdont(ideb))
Then
8869 xdont(ideb) = xdont(imil)
8872 If (xdont(imil) > xdont(ifin))
Then
8874 xdont(ifin) = xdont(imil)
8876 If (xdont(imil) < xdont(ideb))
Then
8878 xdont(ideb) = xdont(imil)
8892 If (icrs >= idcr)
Then
8904 If (xdont(icrs) > xpiv)
Exit
8907 If (xdont(idcr) <= xpiv)
Exit
8909 If (icrs >= idcr)
Then
8918 xdont(idcr) = xdont(icrs)
8924 Call d_subsor (xdont, ideb1, icrs - 1)
8925 Call d_subsor (xdont, idcr, ifin1)
8928 End Subroutine d_subsor
8930 Subroutine r_refsor (XDONT)
8945 Real(kind =
sp),
Dimension (:),
Intent (InOut) :: xdont
8949 Call r_subsor (xdont, 1,
Size (xdont))
8950 Call r_inssor (xdont)
8952 End Subroutine r_refsor
8954 Recursive Subroutine r_subsor (XDONT, IDEB1, IFIN1)
8957 Real(kind =
sp),
dimension (:),
Intent (InOut) :: xdont
8958 Integer(kind = i4),
Intent (In) :: IDEB1, IFIN1
8960 Integer(kind = i4),
Parameter :: NINS = 16
8961 Integer(kind = i4) :: ICRS, IDEB, IDCR, IFIN, IMIL
8962 Real(kind =
sp) :: xpiv, xwrk
8970 If ((ifin - ideb) > nins)
Then
8971 imil = (ideb + ifin) / 2
8975 If (xdont(imil) < xdont(ideb))
Then
8977 xdont(ideb) = xdont(imil)
8980 If (xdont(imil) > xdont(ifin))
Then
8982 xdont(ifin) = xdont(imil)
8984 If (xdont(imil) < xdont(ideb))
Then
8986 xdont(ideb) = xdont(imil)
9000 If (icrs >= idcr)
Then
9012 If (xdont(icrs) > xpiv)
Exit
9015 If (xdont(idcr) <= xpiv)
Exit
9017 If (icrs >= idcr)
Then
9026 xdont(idcr) = xdont(icrs)
9032 Call r_subsor (xdont, ideb1, icrs - 1)
9033 Call r_subsor (xdont, idcr, ifin1)
9036 End Subroutine r_subsor
9038 Subroutine i_refsor (XDONT)
9053 Integer(kind = i4),
Dimension (:),
Intent (InOut) :: XDONT
9057 Call i_subsor (xdont, 1,
Size (xdont))
9058 Call i_inssor (xdont)
9060 End Subroutine i_refsor
9062 Recursive Subroutine i_subsor (XDONT, IDEB1, IFIN1)
9065 Integer(kind = i4),
dimension (:),
Intent (InOut) :: XDONT
9066 Integer(kind = i4),
Intent (In) :: IDEB1, IFIN1
9068 Integer(kind = i4),
Parameter :: NINS = 16
9069 Integer(kind = i4) :: ICRS, IDEB, IDCR, IFIN, IMIL
9070 Integer(kind = i4) :: XPIV, XWRK
9078 If ((ifin - ideb) > nins)
Then
9079 imil = (ideb + ifin) / 2
9083 If (xdont(imil) < xdont(ideb))
Then
9085 xdont(ideb) = xdont(imil)
9088 If (xdont(imil) > xdont(ifin))
Then
9090 xdont(ifin) = xdont(imil)
9092 If (xdont(imil) < xdont(ideb))
Then
9094 xdont(ideb) = xdont(imil)
9108 If (icrs >= idcr)
Then
9120 If (xdont(icrs) > xpiv)
Exit
9123 If (xdont(idcr) <= xpiv)
Exit
9125 If (icrs >= idcr)
Then
9134 xdont(idcr) = xdont(icrs)
9140 Call i_subsor (xdont, ideb1, icrs - 1)
9141 Call i_subsor (xdont, idcr, ifin1)
9144 End Subroutine i_subsor
9146 Subroutine c_refsor (XDONT)
9161 character(*),
Dimension (:),
Intent (InOut) :: XDONT
9165 Call c_subsor (xdont, 1,
Size (xdont))
9166 Call c_inssor (xdont)
9168 End Subroutine c_refsor
9170 Recursive Subroutine c_subsor (XDONT, IDEB1, IFIN1)
9173 character(*),
dimension (:),
Intent (InOut) :: XDONT
9174 Integer(kind = i4),
Intent (In) :: IDEB1, IFIN1
9176 Integer(kind = i4),
Parameter :: NINS = 16
9177 Integer(kind = i4) :: ICRS, IDEB, IDCR, IFIN, IMIL
9178 character(len(XDONT)) :: XPIV, XWRK
9186 If ((ifin - ideb) > nins)
Then
9187 imil = (ideb + ifin) / 2
9191 If (xdont(imil) < xdont(ideb))
Then
9193 xdont(ideb) = xdont(imil)
9196 If (xdont(imil) > xdont(ifin))
Then
9198 xdont(ifin) = xdont(imil)
9200 If (xdont(imil) < xdont(ideb))
Then
9202 xdont(ideb) = xdont(imil)
9216 If (icrs >= idcr)
Then
9228 If (xdont(icrs) > xpiv)
Exit
9231 If (xdont(idcr) <= xpiv)
Exit
9233 If (icrs >= idcr)
Then
9242 xdont(idcr) = xdont(icrs)
9248 Call c_subsor (xdont, ideb1, icrs - 1)
9249 Call c_subsor (xdont, idcr, ifin1)
9252 End Subroutine c_subsor
9254 Subroutine d_rinpar (XDONT, IRNGT, NORD)
9265 real(kind =
dp),
Dimension (:),
Intent (In) :: xdont
9266 Integer(kind = i4),
Dimension (:),
Intent (Out) :: IRNGT
9267 Integer(kind = i4),
Intent (In) :: NORD
9269 real(kind =
dp) :: xwrk, xwrk1
9271 Integer(kind = i4) :: ICRS, IDCR
9276 Do idcr = icrs - 1, 1, - 1
9277 If (xwrk >= xdont(irngt(idcr)))
Exit
9278 irngt(idcr + 1) = irngt(idcr)
9280 irngt(idcr + 1) = icrs
9283 xwrk1 = xdont(irngt(nord))
9284 Do icrs = nord + 1,
SIZE (xdont)
9285 If (xdont(icrs) < xwrk1)
Then
9287 Do idcr = nord - 1, 1, - 1
9288 If (xwrk >= xdont(irngt(idcr)))
Exit
9289 irngt(idcr + 1) = irngt(idcr)
9291 irngt(idcr + 1) = icrs
9292 xwrk1 = xdont(irngt(nord))
9297 End Subroutine d_rinpar
9299 Subroutine r_rinpar (XDONT, IRNGT, NORD)
9310 Real(kind =
sp),
Dimension (:),
Intent (In) :: xdont
9311 Integer(kind = i4),
Dimension (:),
Intent (Out) :: IRNGT
9312 Integer(kind = i4),
Intent (In) :: NORD
9314 Real(kind =
sp) :: xwrk, xwrk1
9316 Integer(kind = i4) :: ICRS, IDCR
9321 Do idcr = icrs - 1, 1, - 1
9322 If (xwrk >= xdont(irngt(idcr)))
Exit
9323 irngt(idcr + 1) = irngt(idcr)
9325 irngt(idcr + 1) = icrs
9328 xwrk1 = xdont(irngt(nord))
9329 Do icrs = nord + 1,
SIZE (xdont)
9330 If (xdont(icrs) < xwrk1)
Then
9332 Do idcr = nord - 1, 1, - 1
9333 If (xwrk >= xdont(irngt(idcr)))
Exit
9334 irngt(idcr + 1) = irngt(idcr)
9336 irngt(idcr + 1) = icrs
9337 xwrk1 = xdont(irngt(nord))
9342 End Subroutine r_rinpar
9344 Subroutine i_rinpar (XDONT, IRNGT, NORD)
9355 Integer(kind = i4),
Dimension (:),
Intent (In) :: XDONT
9356 Integer(kind = i4),
Dimension (:),
Intent (Out) :: IRNGT
9357 Integer(kind = i4),
Intent (In) :: NORD
9359 Integer(kind = i4) :: XWRK, XWRK1
9361 Integer(kind = i4) :: ICRS, IDCR
9366 Do idcr = icrs - 1, 1, - 1
9367 If (xwrk >= xdont(irngt(idcr)))
Exit
9368 irngt(idcr + 1) = irngt(idcr)
9370 irngt(idcr + 1) = icrs
9373 xwrk1 = xdont(irngt(nord))
9374 Do icrs = nord + 1,
SIZE (xdont)
9375 If (xdont(icrs) < xwrk1)
Then
9377 Do idcr = nord - 1, 1, - 1
9378 If (xwrk >= xdont(irngt(idcr)))
Exit
9379 irngt(idcr + 1) = irngt(idcr)
9381 irngt(idcr + 1) = icrs
9382 xwrk1 = xdont(irngt(nord))
9387 End Subroutine i_rinpar
9389 Subroutine d_rnkpar (XDONT, IRNGT, NORD)
9405 real(kind =
dp),
Dimension (:),
Intent (In) :: xdont
9406 Integer(kind = i4),
Dimension (:),
Intent (Out) :: IRNGT
9407 Integer(kind = i4),
Intent (In) :: NORD
9409 real(kind =
dp) :: xpiv, xpiv0, xwrk, xwrk1, xmin, xmax
9411 Integer(kind = i4),
Dimension (SIZE(XDONT)) :: ILOWT, IHIGT
9412 Integer(kind = i4) :: NDON, JHIG, JLOW, IHIG, IWRK, IWRK1, IWRK2, IWRK3
9413 Integer(kind = i4) :: IDEB, JDEB, IMIL, IFIN, NWRK, ICRS, IDCR, ILOW
9414 Integer(kind = i4) :: JLM2, JLM1, JHM2, JHM1
9421 If (nord >= 1) irngt(1) = 1
9428 If (xdont(2) < xdont(1))
Then
9437 If (nord >= 1) irngt(1) = ilowt(1)
9438 If (nord >= 2) irngt(2) = ihigt(1)
9442 If (xdont(3) <= xdont(ihigt(1)))
Then
9444 If (xdont(3) < xdont(ilowt(1)))
Then
9455 If (nord >= 1) irngt(1) = ilowt(1)
9456 If (nord >= 2) irngt(2) = ihigt(1)
9457 If (nord >= 3) irngt(3) = ihigt(2)
9461 If (xdont(ndon) <= xdont(ihigt(1)))
Then
9464 If (xdont(ndon) < xdont(ilowt(1)))
Then
9471 if (xdont(ndon) < xdont(ihigt(2)))
Then
9480 If (nord >= 1) irngt(1) = ilowt(1)
9481 If (nord >= 2) irngt(2) = ihigt(1)
9482 If (nord >= 3) irngt(3) = ihigt(2)
9483 If (nord >= 4) irngt(4) = ihigt(3)
9491 xpiv = xdont(ilowt(ideb)) + real(2 * nord,
dp) / real(ndon + nord,
dp) * &
9492 (xdont(ihigt(3)) - xdont(ilowt(ideb)))
9493 If (xpiv >= xdont(ihigt(1)))
Then
9494 xpiv = xdont(ilowt(ideb)) + real(2 * nord,
dp) / real(ndon + nord,
dp) * &
9495 (xdont(ihigt(2)) - xdont(ilowt(ideb)))
9496 If (xpiv >= xdont(ihigt(1))) &
9497 xpiv = xdont(ilowt(ideb)) + real(2 * nord,
dp) / real(ndon + nord,
dp) * &
9498 (xdont(ihigt(1)) - xdont(ilowt(ideb)))
9510 If (xdont(ndon) > xpiv)
Then
9514 If (xdont(icrs) > xpiv)
Then
9515 If (icrs >= ndon)
Exit
9521 If (jlow >= nord)
Exit
9528 If (icrs < ndon - 1)
Then
9531 If (xdont(icrs) <= xpiv)
Then
9534 Else If (icrs >= ndon)
Then
9546 Do icrs = 4, ndon - 1
9547 If (xdont(icrs) > xpiv)
Then
9553 If (jlow >= nord)
Exit
9557 If (icrs < ndon - 1)
Then
9560 If (xdont(icrs) <= xpiv)
Then
9561 If (icrs >= ndon)
Exit
9574 if (jlow == nord)
Exit
9575 If (jlm2 == jlow .And. jhm2 == jhig)
Then
9580 If (nord > jlow)
Then
9581 xmin = xdont(ihigt(1))
9584 If (xdont(ihigt(icrs)) < xmin)
Then
9585 xmin = xdont(ihigt(icrs))
9591 ilowt(jlow) = ihigt(ihig)
9592 ihigt(ihig) = ihigt(jhig)
9598 If (xdont(ilowt(icrs)) > xmax)
Then
9616 Select Case (nord - jlow)
9631 If (xdont(ihigt(1)) <= xdont(ihigt(2)))
Then
9633 ilowt(jlow) = ihigt(1)
9635 ilowt(jlow) = ihigt(2)
9638 ilowt(jlow) = ihigt(2)
9640 ilowt(jlow) = ihigt(1)
9650 If (xdont(iwrk2) < xdont(iwrk1))
Then
9655 If (xdont(iwrk2) > xdont(iwrk3))
Then
9659 If (xdont(iwrk2) < xdont(ihigt(1)))
Then
9665 Do icrs = jlow + 1, nord
9667 ilowt(icrs) = ihigt(jhig)
9685 If (xdont(iwrk2) < xdont(iwrk1))
Then
9690 If (xdont(iwrk2) > xdont(iwrk3))
Then
9694 If (xdont(iwrk2) < xdont(ihigt(1)))
Then
9705 xpiv = xdont(iwrk1) + real(nwrk,
dp) / real(nord + nwrk,
dp) * &
9706 (xdont(ihigt(ifin)) - xdont(iwrk1))
9716 If (xdont(ihigt(icrs)) <= xpiv)
Then
9718 ilowt(jlow) = ihigt(icrs)
9719 If (jlow >= nord)
Exit
9722 ihigt(jhig) = ihigt(icrs)
9726 Do icrs = icrs + 1, ifin
9727 If (xdont(ihigt(icrs)) <= xpiv)
Then
9729 ilowt(jlow) = ihigt(icrs)
9739 xmin = xdont(ihigt(1))
9742 If (xdont(ihigt(icrs)) < xmin)
Then
9743 xmin = xdont(ihigt(icrs))
9749 ilowt(jlow) = ihigt(ihig)
9768 Do idcr = icrs - 1, 1, - 1
9769 If (xwrk < xdont(irngt(idcr)))
Then
9770 irngt(idcr + 1) = irngt(idcr)
9775 irngt(idcr + 1) = iwrk
9778 xwrk1 = xdont(irngt(nord))
9779 Do icrs = nord + 1, jlow
9780 If (xdont(ilowt(icrs)) < xwrk1)
Then
9781 xwrk = xdont(ilowt(icrs))
9782 Do idcr = nord - 1, 1, - 1
9783 If (xwrk >= xdont(irngt(idcr)))
Exit
9784 irngt(idcr + 1) = irngt(idcr)
9786 irngt(idcr + 1) = ilowt(icrs)
9787 xwrk1 = xdont(irngt(nord))
9799 imil = (jlow + ideb) / 2
9804 If (xdont(ilowt(imil)) < xdont(ilowt(ideb)))
Then
9806 ilowt(ideb) = ilowt(imil)
9809 If (xdont(ilowt(imil)) > xdont(ilowt(ifin)))
Then
9811 ilowt(ifin) = ilowt(imil)
9813 If (xdont(ilowt(imil)) < xdont(ilowt(ideb)))
Then
9815 ilowt(ideb) = ilowt(imil)
9821 xpiv = xdont(ilowt(1)) + real(nord,
dp) / real(jlow + nord,
dp) * &
9822 (xdont(ilowt(ifin)) - xdont(ilowt(1)))
9824 If (xpiv <= xpiv0) &
9825 xpiv = xpiv0 + real(2 * nord - jdeb,
dp) / real(jlow + nord,
dp) * &
9826 (xdont(ilowt(ifin)) - xpiv0)
9838 If (xdont(ilowt(ifin)) > xpiv)
Then
9842 If (xdont(ilowt(icrs)) > xpiv)
Then
9844 ihigt(jhig) = ilowt(icrs)
9845 If (icrs >= ifin)
Exit
9848 ilowt(jlow) = ilowt(icrs)
9849 If (jlow >= nord)
Exit
9853 If (icrs < ifin)
Then
9856 If (xdont(ilowt(icrs)) <= xpiv)
Then
9858 ilowt(jlow) = ilowt(icrs)
9860 If (icrs >= ifin)
Exit
9865 Do icrs = ideb, ifin
9866 If (xdont(ilowt(icrs)) > xpiv)
Then
9868 ihigt(jhig) = ilowt(icrs)
9871 ilowt(jlow) = ilowt(icrs)
9872 If (jlow >= nord)
Exit
9876 Do icrs = icrs + 1, ifin
9877 If (xdont(ilowt(icrs)) <= xpiv)
Then
9879 ilowt(jlow) = ilowt(icrs)
9895 Do idcr = icrs - 1, 1, - 1
9896 If (xwrk < xdont(irngt(idcr)))
Then
9897 irngt(idcr + 1) = irngt(idcr)
9902 irngt(idcr + 1) = iwrk
9907 End Subroutine d_rnkpar
9909 Subroutine r_rnkpar (XDONT, IRNGT, NORD)
9925 Real(kind =
sp),
Dimension (:),
Intent (In) :: xdont
9926 Integer(kind = i4),
Dimension (:),
Intent (Out) :: IRNGT
9927 Integer(kind = i4),
Intent (In) :: NORD
9929 Real(kind =
sp) :: xpiv, xpiv0, xwrk, xwrk1, xmin, xmax
9931 Integer(kind = i4),
Dimension (SIZE(XDONT)) :: ILOWT, IHIGT
9932 Integer(kind = i4) :: NDON, JHIG, JLOW, IHIG, IWRK, IWRK1, IWRK2, IWRK3
9933 Integer(kind = i4) :: IDEB, JDEB, IMIL, IFIN, NWRK, ICRS, IDCR, ILOW
9934 Integer(kind = i4) :: JLM2, JLM1, JHM2, JHM1
9941 If (nord >= 1) irngt(1) = 1
9948 If (xdont(2) < xdont(1))
Then
9957 If (nord >= 1) irngt(1) = ilowt(1)
9958 If (nord >= 2) irngt(2) = ihigt(1)
9962 If (xdont(3) <= xdont(ihigt(1)))
Then
9964 If (xdont(3) < xdont(ilowt(1)))
Then
9975 If (nord >= 1) irngt(1) = ilowt(1)
9976 If (nord >= 2) irngt(2) = ihigt(1)
9977 If (nord >= 3) irngt(3) = ihigt(2)
9981 If (xdont(ndon) <= xdont(ihigt(1)))
Then
9984 If (xdont(ndon) < xdont(ilowt(1)))
Then
9991 if (xdont(ndon) < xdont(ihigt(2)))
Then
10000 If (nord >= 1) irngt(1) = ilowt(1)
10001 If (nord >= 2) irngt(2) = ihigt(1)
10002 If (nord >= 3) irngt(3) = ihigt(2)
10003 If (nord >= 4) irngt(4) = ihigt(3)
10011 xpiv = xdont(ilowt(ideb)) + real(2 * nord,
sp) / real(ndon + nord,
sp) * &
10012 (xdont(ihigt(3)) - xdont(ilowt(ideb)))
10013 If (xpiv >= xdont(ihigt(1)))
Then
10014 xpiv = xdont(ilowt(ideb)) + real(2 * nord,
sp) / real(ndon + nord,
sp) * &
10015 (xdont(ihigt(2)) - xdont(ilowt(ideb)))
10016 If (xpiv >= xdont(ihigt(1))) &
10017 xpiv = xdont(ilowt(ideb)) + real(2 * nord,
sp) / real(ndon + nord,
sp) * &
10018 (xdont(ihigt(1)) - xdont(ilowt(ideb)))
10030 If (xdont(ndon) > xpiv)
Then
10034 If (xdont(icrs) > xpiv)
Then
10035 If (icrs >= ndon)
Exit
10041 If (jlow >= nord)
Exit
10048 If (icrs < ndon - 1)
Then
10051 If (xdont(icrs) <= xpiv)
Then
10054 Else If (icrs >= ndon)
Then
10066 Do icrs = 4, ndon - 1
10067 If (xdont(icrs) > xpiv)
Then
10073 If (jlow >= nord)
Exit
10077 If (icrs < ndon - 1)
Then
10080 If (xdont(icrs) <= xpiv)
Then
10081 If (icrs >= ndon)
Exit
10094 if (jlow == nord)
Exit
10095 If (jlm2 == jlow .And. jhm2 == jhig)
Then
10100 If (nord > jlow)
Then
10101 xmin = xdont(ihigt(1))
10104 If (xdont(ihigt(icrs)) < xmin)
Then
10105 xmin = xdont(ihigt(icrs))
10111 ilowt(jlow) = ihigt(ihig)
10112 ihigt(ihig) = ihigt(jhig)
10118 If (xdont(ilowt(icrs)) > xmax)
Then
10136 Select Case (nord - jlow)
10151 If (xdont(ihigt(1)) <= xdont(ihigt(2)))
Then
10153 ilowt(jlow) = ihigt(1)
10155 ilowt(jlow) = ihigt(2)
10158 ilowt(jlow) = ihigt(2)
10160 ilowt(jlow) = ihigt(1)
10170 If (xdont(iwrk2) < xdont(iwrk1))
Then
10175 If (xdont(iwrk2) > xdont(iwrk3))
Then
10179 If (xdont(iwrk2) < xdont(ihigt(1)))
Then
10180 ihigt(2) = ihigt(1)
10185 Do icrs = jlow + 1, nord
10187 ilowt(icrs) = ihigt(jhig)
10204 iwrk3 = ihigt(ifin)
10205 If (xdont(iwrk2) < xdont(iwrk1))
Then
10210 If (xdont(iwrk2) > xdont(iwrk3))
Then
10211 ihigt(ifin) = iwrk2
10214 If (xdont(iwrk2) < xdont(ihigt(1)))
Then
10215 ihigt(2) = ihigt(1)
10224 ilowt(jlow) = iwrk1
10225 xpiv = xdont(iwrk1) + real(nwrk,
sp) / real(nord + nwrk,
sp) * &
10226 (xdont(ihigt(ifin)) - xdont(iwrk1))
10236 If (xdont(ihigt(icrs)) <= xpiv)
Then
10238 ilowt(jlow) = ihigt(icrs)
10239 If (jlow >= nord)
Exit
10242 ihigt(jhig) = ihigt(icrs)
10246 Do icrs = icrs + 1, ifin
10247 If (xdont(ihigt(icrs)) <= xpiv)
Then
10249 ilowt(jlow) = ihigt(icrs)
10259 xmin = xdont(ihigt(1))
10262 If (xdont(ihigt(icrs)) < xmin)
Then
10263 xmin = xdont(ihigt(icrs))
10269 ilowt(jlow) = ihigt(ihig)
10284 irngt(1) = ilowt(1)
10288 Do idcr = icrs - 1, 1, - 1
10289 If (xwrk < xdont(irngt(idcr)))
Then
10290 irngt(idcr + 1) = irngt(idcr)
10295 irngt(idcr + 1) = iwrk
10298 xwrk1 = xdont(irngt(nord))
10299 Do icrs = nord + 1, jlow
10300 If (xdont(ilowt(icrs)) < xwrk1)
Then
10301 xwrk = xdont(ilowt(icrs))
10302 Do idcr = nord - 1, 1, - 1
10303 If (xwrk >= xdont(irngt(idcr)))
Exit
10304 irngt(idcr + 1) = irngt(idcr)
10306 irngt(idcr + 1) = ilowt(icrs)
10307 xwrk1 = xdont(irngt(nord))
10319 imil = (jlow + ideb) / 2
10324 If (xdont(ilowt(imil)) < xdont(ilowt(ideb)))
Then
10326 ilowt(ideb) = ilowt(imil)
10329 If (xdont(ilowt(imil)) > xdont(ilowt(ifin)))
Then
10331 ilowt(ifin) = ilowt(imil)
10333 If (xdont(ilowt(imil)) < xdont(ilowt(ideb)))
Then
10335 ilowt(ideb) = ilowt(imil)
10339 If (ifin <= 3)
Exit
10341 xpiv = xdont(ilowt(1)) + real(nord,
sp) / real(jlow + nord,
sp) * &
10342 (xdont(ilowt(ifin)) - xdont(ilowt(1)))
10344 If (xpiv <= xpiv0) &
10345 xpiv = xpiv0 + real(2 * nord - jdeb,
sp) / real(jlow + nord,
sp) * &
10346 (xdont(ilowt(ifin)) - xpiv0)
10358 If (xdont(ilowt(ifin)) > xpiv)
Then
10362 If (xdont(ilowt(icrs)) > xpiv)
Then
10364 ihigt(jhig) = ilowt(icrs)
10365 If (icrs >= ifin)
Exit
10368 ilowt(jlow) = ilowt(icrs)
10369 If (jlow >= nord)
Exit
10373 If (icrs < ifin)
Then
10376 If (xdont(ilowt(icrs)) <= xpiv)
Then
10378 ilowt(jlow) = ilowt(icrs)
10380 If (icrs >= ifin)
Exit
10385 Do icrs = ideb, ifin
10386 If (xdont(ilowt(icrs)) > xpiv)
Then
10388 ihigt(jhig) = ilowt(icrs)
10391 ilowt(jlow) = ilowt(icrs)
10392 If (jlow >= nord)
Exit
10396 Do icrs = icrs + 1, ifin
10397 If (xdont(ilowt(icrs)) <= xpiv)
Then
10399 ilowt(jlow) = ilowt(icrs)
10411 irngt(1) = ilowt(1)
10415 Do idcr = icrs - 1, 1, - 1
10416 If (xwrk < xdont(irngt(idcr)))
Then
10417 irngt(idcr + 1) = irngt(idcr)
10422 irngt(idcr + 1) = iwrk
10427 End Subroutine r_rnkpar
10429 Subroutine i_rnkpar (XDONT, IRNGT, NORD)
10445 Integer(kind = i4),
Dimension (:),
Intent (In) :: XDONT
10446 Integer(kind = i4),
Dimension (:),
Intent (Out) :: IRNGT
10447 Integer(kind = i4),
Intent (In) :: NORD
10449 Integer(kind = i4) :: XPIV, XPIV0, XWRK, XWRK1, XMIN, XMAX
10451 Integer(kind = i4),
Dimension (SIZE(XDONT)) :: ILOWT, IHIGT
10452 Integer(kind = i4) :: NDON, JHIG, JLOW, IHIG, IWRK, IWRK1, IWRK2, IWRK3
10453 Integer(kind = i4) :: IDEB, JDEB, IMIL, IFIN, NWRK, ICRS, IDCR, ILOW
10454 Integer(kind = i4) :: JLM2, JLM1, JHM2, JHM1
10456 ndon =
SIZE (xdont)
10461 If (nord >= 1) irngt(1) = 1
10468 If (xdont(2) < xdont(1))
Then
10477 If (nord >= 1) irngt(1) = ilowt(1)
10478 If (nord >= 2) irngt(2) = ihigt(1)
10482 If (xdont(3) <= xdont(ihigt(1)))
Then
10483 ihigt(2) = ihigt(1)
10484 If (xdont(3) < xdont(ilowt(1)))
Then
10485 ihigt(1) = ilowt(1)
10495 If (nord >= 1) irngt(1) = ilowt(1)
10496 If (nord >= 2) irngt(2) = ihigt(1)
10497 If (nord >= 3) irngt(3) = ihigt(2)
10501 If (xdont(ndon) <= xdont(ihigt(1)))
Then
10502 ihigt(3) = ihigt(2)
10503 ihigt(2) = ihigt(1)
10504 If (xdont(ndon) < xdont(ilowt(1)))
Then
10505 ihigt(1) = ilowt(1)
10511 if (xdont(ndon) < xdont(ihigt(2)))
Then
10512 ihigt(3) = ihigt(2)
10520 If (nord >= 1) irngt(1) = ilowt(1)
10521 If (nord >= 2) irngt(2) = ihigt(1)
10522 If (nord >= 3) irngt(3) = ihigt(2)
10523 If (nord >= 4) irngt(4) = ihigt(3)
10531 xpiv = xdont(ilowt(ideb)) + int(real(2 * nord,
sp) / real(ndon + nord,
sp),
i4) * &
10532 (xdont(ihigt(3)) - xdont(ilowt(ideb)))
10533 If (xpiv >= xdont(ihigt(1)))
Then
10534 xpiv = xdont(ilowt(ideb)) + int(real(2 * nord,
sp) / real(ndon + nord,
sp),
i4) * &
10535 (xdont(ihigt(2)) - xdont(ilowt(ideb)))
10536 If (xpiv >= xdont(ihigt(1))) &
10537 xpiv = xdont(ilowt(ideb)) + int(real(2 * nord,
sp) / real(ndon + nord,
sp),
i4) * &
10538 (xdont(ihigt(1)) - xdont(ilowt(ideb)))
10550 If (xdont(ndon) > xpiv)
Then
10554 If (xdont(icrs) > xpiv)
Then
10555 If (icrs >= ndon)
Exit
10561 If (jlow >= nord)
Exit
10568 If (icrs < ndon - 1)
Then
10571 If (xdont(icrs) <= xpiv)
Then
10574 Else If (icrs >= ndon)
Then
10586 Do icrs = 4, ndon - 1
10587 If (xdont(icrs) > xpiv)
Then
10593 If (jlow >= nord)
Exit
10597 If (icrs < ndon - 1)
Then
10600 If (xdont(icrs) <= xpiv)
Then
10601 If (icrs >= ndon)
Exit
10614 if (jlow == nord)
Exit
10615 If (jlm2 == jlow .And. jhm2 == jhig)
Then
10620 If (nord > jlow)
Then
10621 xmin = xdont(ihigt(1))
10624 If (xdont(ihigt(icrs)) < xmin)
Then
10625 xmin = xdont(ihigt(icrs))
10631 ilowt(jlow) = ihigt(ihig)
10632 ihigt(ihig) = ihigt(jhig)
10638 If (xdont(ilowt(icrs)) > xmax)
Then
10656 Select Case (nord - jlow)
10671 If (xdont(ihigt(1)) <= xdont(ihigt(2)))
Then
10673 ilowt(jlow) = ihigt(1)
10675 ilowt(jlow) = ihigt(2)
10678 ilowt(jlow) = ihigt(2)
10680 ilowt(jlow) = ihigt(1)
10690 If (xdont(iwrk2) < xdont(iwrk1))
Then
10695 If (xdont(iwrk2) > xdont(iwrk3))
Then
10699 If (xdont(iwrk2) < xdont(ihigt(1)))
Then
10700 ihigt(2) = ihigt(1)
10705 Do icrs = jlow + 1, nord
10707 ilowt(icrs) = ihigt(jhig)
10724 iwrk3 = ihigt(ifin)
10725 If (xdont(iwrk2) < xdont(iwrk1))
Then
10730 If (xdont(iwrk2) > xdont(iwrk3))
Then
10731 ihigt(ifin) = iwrk2
10734 If (xdont(iwrk2) < xdont(ihigt(1)))
Then
10735 ihigt(2) = ihigt(1)
10744 ilowt(jlow) = iwrk1
10745 xpiv = xdont(iwrk1) + int(real(nwrk,
sp) / real(nord + nwrk,
sp),
i4) * &
10746 (xdont(ihigt(ifin)) - xdont(iwrk1))
10756 If (xdont(ihigt(icrs)) <= xpiv)
Then
10758 ilowt(jlow) = ihigt(icrs)
10759 If (jlow >= nord)
Exit
10762 ihigt(jhig) = ihigt(icrs)
10766 Do icrs = icrs + 1, ifin
10767 If (xdont(ihigt(icrs)) <= xpiv)
Then
10769 ilowt(jlow) = ihigt(icrs)
10779 xmin = xdont(ihigt(1))
10782 If (xdont(ihigt(icrs)) < xmin)
Then
10783 xmin = xdont(ihigt(icrs))
10789 ilowt(jlow) = ihigt(ihig)
10804 irngt(1) = ilowt(1)
10808 Do idcr = icrs - 1, 1, - 1
10809 If (xwrk < xdont(irngt(idcr)))
Then
10810 irngt(idcr + 1) = irngt(idcr)
10815 irngt(idcr + 1) = iwrk
10818 xwrk1 = xdont(irngt(nord))
10819 Do icrs = nord + 1, jlow
10820 If (xdont(ilowt(icrs)) < xwrk1)
Then
10821 xwrk = xdont(ilowt(icrs))
10822 Do idcr = nord - 1, 1, - 1
10823 If (xwrk >= xdont(irngt(idcr)))
Exit
10824 irngt(idcr + 1) = irngt(idcr)
10826 irngt(idcr + 1) = ilowt(icrs)
10827 xwrk1 = xdont(irngt(nord))
10839 imil = (jlow + ideb) / 2
10844 If (xdont(ilowt(imil)) < xdont(ilowt(ideb)))
Then
10846 ilowt(ideb) = ilowt(imil)
10849 If (xdont(ilowt(imil)) > xdont(ilowt(ifin)))
Then
10851 ilowt(ifin) = ilowt(imil)
10853 If (xdont(ilowt(imil)) < xdont(ilowt(ideb)))
Then
10855 ilowt(ideb) = ilowt(imil)
10859 If (ifin <= 3)
Exit
10861 xpiv = xdont(ilowt(1)) + int(real(nord,
sp) / real(jlow + nord,
sp),
i4) * &
10862 (xdont(ilowt(ifin)) - xdont(ilowt(1)))
10864 If (xpiv <= xpiv0) &
10865 xpiv = xpiv0 + int(real(2 * nord - jdeb,
sp) / real(jlow + nord,
sp),
i4) * &
10866 (xdont(ilowt(ifin)) - xpiv0)
10878 If (xdont(ilowt(ifin)) > xpiv)
Then
10882 If (xdont(ilowt(icrs)) > xpiv)
Then
10884 ihigt(jhig) = ilowt(icrs)
10885 If (icrs >= ifin)
Exit
10888 ilowt(jlow) = ilowt(icrs)
10889 If (jlow >= nord)
Exit
10893 If (icrs < ifin)
Then
10896 If (xdont(ilowt(icrs)) <= xpiv)
Then
10898 ilowt(jlow) = ilowt(icrs)
10900 If (icrs >= ifin)
Exit
10905 Do icrs = ideb, ifin
10906 If (xdont(ilowt(icrs)) > xpiv)
Then
10908 ihigt(jhig) = ilowt(icrs)
10911 ilowt(jlow) = ilowt(icrs)
10912 If (jlow >= nord)
Exit
10916 Do icrs = icrs + 1, ifin
10917 If (xdont(ilowt(icrs)) <= xpiv)
Then
10919 ilowt(jlow) = ilowt(icrs)
10931 irngt(1) = ilowt(1)
10935 Do idcr = icrs - 1, 1, - 1
10936 If (xwrk < xdont(irngt(idcr)))
Then
10937 irngt(idcr + 1) = irngt(idcr)
10942 irngt(idcr + 1) = iwrk
10947 End Subroutine i_rnkpar
10949 Subroutine d_uniinv (XDONT, IGOEST)
10960 real(kind =
dp),
Dimension (:),
Intent (In) :: xdont
10961 Integer(kind = i4),
Dimension (:),
Intent (Out) :: IGOEST
10963 real(kind =
dp) :: xtst, xdona, xdonb
10966 Integer(kind = i4),
Dimension (SIZE(IGOEST)) :: JWRKT, IRNGT
10967 Integer(kind = i4) :: LMTNA, LMTNC, IRNG, IRNG1, IRNG2, NUNI
10968 Integer(kind = i4) :: NVAL, IIND, IWRKD, IWRK, IWRKF, JINDA, IINDA, IINDB
10970 nval = min(
SIZE(xdont),
SIZE(igoest))
10984 Do iind = 2, nval, 2
10985 If (xdont(iind - 1) < xdont(iind))
Then
10986 irngt(iind - 1) = iind - 1
10989 irngt(iind - 1) = iind
10990 irngt(iind) = iind - 1
10993 If (modulo(nval, 2) /= 0)
Then
11006 If (nval <= 4)
Exit
11010 Do iwrkd = 0, nval - 1, 4
11011 If ((iwrkd + 4) > nval)
Then
11012 If ((iwrkd + 2) >= nval)
Exit
11016 If (xdont(irngt(iwrkd + 2)) <= xdont(irngt(iwrkd + 3)))
Exit
11020 If (xdont(irngt(iwrkd + 1)) <= xdont(irngt(iwrkd + 3)))
Then
11021 irng2 = irngt(iwrkd + 2)
11022 irngt(iwrkd + 2) = irngt(iwrkd + 3)
11023 irngt(iwrkd + 3) = irng2
11028 irng1 = irngt(iwrkd + 1)
11029 irngt(iwrkd + 1) = irngt(iwrkd + 3)
11030 irngt(iwrkd + 3) = irngt(iwrkd + 2)
11031 irngt(iwrkd + 2) = irng1
11038 If (xdont(irngt(iwrkd + 2)) <= xdont(irngt(iwrkd + 3))) cycle
11042 If (xdont(irngt(iwrkd + 1)) <= xdont(irngt(iwrkd + 3)))
Then
11043 irng2 = irngt(iwrkd + 2)
11044 irngt(iwrkd + 2) = irngt(iwrkd + 3)
11045 If (xdont(irng2) <= xdont(irngt(iwrkd + 4)))
Then
11047 irngt(iwrkd + 3) = irng2
11050 irngt(iwrkd + 3) = irngt(iwrkd + 4)
11051 irngt(iwrkd + 4) = irng2
11057 irng1 = irngt(iwrkd + 1)
11058 irng2 = irngt(iwrkd + 2)
11059 irngt(iwrkd + 1) = irngt(iwrkd + 3)
11060 If (xdont(irng1) <= xdont(irngt(iwrkd + 4)))
Then
11061 irngt(iwrkd + 2) = irng1
11062 If (xdont(irng2) <= xdont(irngt(iwrkd + 4)))
Then
11064 irngt(iwrkd + 3) = irng2
11067 irngt(iwrkd + 3) = irngt(iwrkd + 4)
11068 irngt(iwrkd + 4) = irng2
11072 irngt(iwrkd + 2) = irngt(iwrkd + 4)
11073 irngt(iwrkd + 3) = irng1
11074 irngt(iwrkd + 4) = irng2
11089 If (2 * lmtna >= nval)
Exit
11098 jinda = iwrkf + lmtna
11099 iwrkf = iwrkf + lmtnc
11100 If (iwrkf >= nval)
Then
11101 If (jinda >= nval)
Exit
11111 jwrkt(1 : lmtna) = irngt(iwrkd : jinda)
11112 xdona = xdont(jwrkt(iinda))
11113 xdonb = xdont(irngt(iindb))
11120 If (xdona > xdonb)
Then
11121 irngt(iwrk) = irngt(iindb)
11123 If (iindb > iwrkf)
Then
11125 irngt(iwrk + 1 : iwrkf) = jwrkt(iinda : lmtna)
11128 xdonb = xdont(irngt(iindb))
11130 irngt(iwrk) = jwrkt(iinda)
11132 If (iinda > lmtna) exit
11133 xdona = xdont(jwrkt(iinda))
11152 jwrkt(1 : lmtna) = irngt(1 : lmtna)
11153 If (iindb <= nval)
Then
11154 xtst =
nearless(min(xdont(jwrkt(1)), xdont(irngt(iindb))))
11162 If (iinda <= lmtna)
Then
11163 If (iindb <= nval)
Then
11164 If (xdont(jwrkt(iinda)) > xdont(irngt(iindb)))
Then
11165 irng = irngt(iindb)
11168 irng = jwrkt(iinda)
11175 irng = jwrkt(iinda)
11184 If (xdont(irng) > xtst)
Then
11188 igoest(irng) = nuni
11194 End Subroutine d_uniinv
11196 Subroutine r_uniinv (XDONT, IGOEST)
11207 Real(kind =
sp),
Dimension (:),
Intent (In) :: xdont
11208 Integer(kind = i4),
Dimension (:),
Intent (Out) :: IGOEST
11210 Real(kind =
sp) :: xtst, xdona, xdonb
11213 Integer(kind = i4),
Dimension (SIZE(IGOEST)) :: JWRKT, IRNGT
11214 Integer(kind = i4) :: LMTNA, LMTNC, IRNG, IRNG1, IRNG2, NUNI
11215 Integer(kind = i4) :: NVAL, IIND, IWRKD, IWRK, IWRKF, JINDA, IINDA, IINDB
11217 nval = min(
SIZE(xdont),
SIZE(igoest))
11231 Do iind = 2, nval, 2
11232 If (xdont(iind - 1) < xdont(iind))
Then
11233 irngt(iind - 1) = iind - 1
11236 irngt(iind - 1) = iind
11237 irngt(iind) = iind - 1
11240 If (modulo(nval, 2) /= 0)
Then
11253 If (nval <= 4)
Exit
11257 Do iwrkd = 0, nval - 1, 4
11258 If ((iwrkd + 4) > nval)
Then
11259 If ((iwrkd + 2) >= nval)
Exit
11263 If (xdont(irngt(iwrkd + 2)) <= xdont(irngt(iwrkd + 3)))
Exit
11267 If (xdont(irngt(iwrkd + 1)) <= xdont(irngt(iwrkd + 3)))
Then
11268 irng2 = irngt(iwrkd + 2)
11269 irngt(iwrkd + 2) = irngt(iwrkd + 3)
11270 irngt(iwrkd + 3) = irng2
11275 irng1 = irngt(iwrkd + 1)
11276 irngt(iwrkd + 1) = irngt(iwrkd + 3)
11277 irngt(iwrkd + 3) = irngt(iwrkd + 2)
11278 irngt(iwrkd + 2) = irng1
11285 If (xdont(irngt(iwrkd + 2)) <= xdont(irngt(iwrkd + 3))) cycle
11289 If (xdont(irngt(iwrkd + 1)) <= xdont(irngt(iwrkd + 3)))
Then
11290 irng2 = irngt(iwrkd + 2)
11291 irngt(iwrkd + 2) = irngt(iwrkd + 3)
11292 If (xdont(irng2) <= xdont(irngt(iwrkd + 4)))
Then
11294 irngt(iwrkd + 3) = irng2
11297 irngt(iwrkd + 3) = irngt(iwrkd + 4)
11298 irngt(iwrkd + 4) = irng2
11304 irng1 = irngt(iwrkd + 1)
11305 irng2 = irngt(iwrkd + 2)
11306 irngt(iwrkd + 1) = irngt(iwrkd + 3)
11307 If (xdont(irng1) <= xdont(irngt(iwrkd + 4)))
Then
11308 irngt(iwrkd + 2) = irng1
11309 If (xdont(irng2) <= xdont(irngt(iwrkd + 4)))
Then
11311 irngt(iwrkd + 3) = irng2
11314 irngt(iwrkd + 3) = irngt(iwrkd + 4)
11315 irngt(iwrkd + 4) = irng2
11319 irngt(iwrkd + 2) = irngt(iwrkd + 4)
11320 irngt(iwrkd + 3) = irng1
11321 irngt(iwrkd + 4) = irng2
11336 If (2 * lmtna >= nval)
Exit
11345 jinda = iwrkf + lmtna
11346 iwrkf = iwrkf + lmtnc
11347 If (iwrkf >= nval)
Then
11348 If (jinda >= nval)
Exit
11358 jwrkt(1 : lmtna) = irngt(iwrkd : jinda)
11359 xdona = xdont(jwrkt(iinda))
11360 xdonb = xdont(irngt(iindb))
11367 If (xdona > xdonb)
Then
11368 irngt(iwrk) = irngt(iindb)
11370 If (iindb > iwrkf)
Then
11372 irngt(iwrk + 1 : iwrkf) = jwrkt(iinda : lmtna)
11375 xdonb = xdont(irngt(iindb))
11377 irngt(iwrk) = jwrkt(iinda)
11379 If (iinda > lmtna) exit
11380 xdona = xdont(jwrkt(iinda))
11399 jwrkt(1 : lmtna) = irngt(1 : lmtna)
11400 If (iindb <= nval)
Then
11401 xtst =
nearless(min(xdont(jwrkt(1)), xdont(irngt(iindb))))
11409 If (iinda <= lmtna)
Then
11410 If (iindb <= nval)
Then
11411 If (xdont(jwrkt(iinda)) > xdont(irngt(iindb)))
Then
11412 irng = irngt(iindb)
11415 irng = jwrkt(iinda)
11422 irng = jwrkt(iinda)
11431 If (xdont(irng) > xtst)
Then
11435 igoest(irng) = nuni
11441 End Subroutine r_uniinv
11443 Subroutine i_uniinv (XDONT, IGOEST)
11454 Integer(kind = i4),
Dimension (:),
Intent (In) :: XDONT
11455 Integer(kind = i4),
Dimension (:),
Intent (Out) :: IGOEST
11457 Integer(kind = i4) :: XTST, XDONA, XDONB
11460 Integer(kind = i4),
Dimension (SIZE(IGOEST)) :: JWRKT, IRNGT
11461 Integer(kind = i4) :: LMTNA, LMTNC, IRNG, IRNG1, IRNG2, NUNI
11462 Integer(kind = i4) :: NVAL, IIND, IWRKD, IWRK, IWRKF, JINDA, IINDA, IINDB
11464 nval = min(
SIZE(xdont),
SIZE(igoest))
11478 Do iind = 2, nval, 2
11479 If (xdont(iind - 1) < xdont(iind))
Then
11480 irngt(iind - 1) = iind - 1
11483 irngt(iind - 1) = iind
11484 irngt(iind) = iind - 1
11487 If (modulo(nval, 2) /= 0)
Then
11500 If (nval <= 4)
Exit
11504 Do iwrkd = 0, nval - 1, 4
11505 If ((iwrkd + 4) > nval)
Then
11506 If ((iwrkd + 2) >= nval)
Exit
11510 If (xdont(irngt(iwrkd + 2)) <= xdont(irngt(iwrkd + 3)))
Exit
11514 If (xdont(irngt(iwrkd + 1)) <= xdont(irngt(iwrkd + 3)))
Then
11515 irng2 = irngt(iwrkd + 2)
11516 irngt(iwrkd + 2) = irngt(iwrkd + 3)
11517 irngt(iwrkd + 3) = irng2
11522 irng1 = irngt(iwrkd + 1)
11523 irngt(iwrkd + 1) = irngt(iwrkd + 3)
11524 irngt(iwrkd + 3) = irngt(iwrkd + 2)
11525 irngt(iwrkd + 2) = irng1
11532 If (xdont(irngt(iwrkd + 2)) <= xdont(irngt(iwrkd + 3))) cycle
11536 If (xdont(irngt(iwrkd + 1)) <= xdont(irngt(iwrkd + 3)))
Then
11537 irng2 = irngt(iwrkd + 2)
11538 irngt(iwrkd + 2) = irngt(iwrkd + 3)
11539 If (xdont(irng2) <= xdont(irngt(iwrkd + 4)))
Then
11541 irngt(iwrkd + 3) = irng2
11544 irngt(iwrkd + 3) = irngt(iwrkd + 4)
11545 irngt(iwrkd + 4) = irng2
11551 irng1 = irngt(iwrkd + 1)
11552 irng2 = irngt(iwrkd + 2)
11553 irngt(iwrkd + 1) = irngt(iwrkd + 3)
11554 If (xdont(irng1) <= xdont(irngt(iwrkd + 4)))
Then
11555 irngt(iwrkd + 2) = irng1
11556 If (xdont(irng2) <= xdont(irngt(iwrkd + 4)))
Then
11558 irngt(iwrkd + 3) = irng2
11561 irngt(iwrkd + 3) = irngt(iwrkd + 4)
11562 irngt(iwrkd + 4) = irng2
11566 irngt(iwrkd + 2) = irngt(iwrkd + 4)
11567 irngt(iwrkd + 3) = irng1
11568 irngt(iwrkd + 4) = irng2
11583 If (2 * lmtna >= nval)
Exit
11592 jinda = iwrkf + lmtna
11593 iwrkf = iwrkf + lmtnc
11594 If (iwrkf >= nval)
Then
11595 If (jinda >= nval)
Exit
11605 jwrkt(1 : lmtna) = irngt(iwrkd : jinda)
11606 xdona = xdont(jwrkt(iinda))
11607 xdonb = xdont(irngt(iindb))
11614 If (xdona > xdonb)
Then
11615 irngt(iwrk) = irngt(iindb)
11617 If (iindb > iwrkf)
Then
11619 irngt(iwrk + 1 : iwrkf) = jwrkt(iinda : lmtna)
11622 xdonb = xdont(irngt(iindb))
11624 irngt(iwrk) = jwrkt(iinda)
11626 If (iinda > lmtna) exit
11627 xdona = xdont(jwrkt(iinda))
11646 jwrkt(1 : lmtna) = irngt(1 : lmtna)
11647 If (iindb <= nval)
Then
11648 xtst =
nearless(min(xdont(jwrkt(1)), xdont(irngt(iindb))))
11656 If (iinda <= lmtna)
Then
11657 If (iindb <= nval)
Then
11658 If (xdont(jwrkt(iinda)) > xdont(irngt(iindb)))
Then
11659 irng = irngt(iindb)
11662 irng = jwrkt(iinda)
11669 irng = jwrkt(iinda)
11678 If (xdont(irng) > xtst)
Then
11682 igoest(irng) = nuni
11688 End Subroutine i_uniinv
11690 Function d_nearless (XVAL)
result (D_nl)
11693 real(kind =
dp),
Intent (In) :: xval
11694 real(kind =
dp) :: d_nl
11696 d_nl = nearest(xval, -1.0_dp)
11699 End Function d_nearless
11701 Function r_nearless (XVAL)
result (R_nl)
11704 Real(kind =
sp),
Intent (In) :: xval
11705 Real(kind =
sp) :: r_nl
11707 r_nl = nearest(xval, -1.0)
11710 End Function r_nearless
11712 Function i_nearless (XVAL)
result (I_nl)
11715 Integer(kind = i4),
Intent (In) :: XVAL
11716 Integer(kind = i4) :: I_nl
11721 End Function i_nearless
11724 Subroutine d_unipar (XDONT, IRNGT, NORD)
11743 real(kind =
dp),
Dimension (:),
Intent (In) :: xdont
11744 Integer(kind = i4),
Dimension (:),
Intent (Out) :: IRNGT
11745 Integer(kind = i4),
Intent (InOut) :: NORD
11747 real(kind =
dp) :: xpiv, xwrk, xwrk1, xmin, xmax, xpiv0
11749 Integer(kind = i4),
Dimension (SIZE(XDONT)) :: ILOWT, IHIGT
11750 Integer(kind = i4) :: NDON, JHIG, JLOW, IHIG, IWRK, IWRK1, IWRK2, IWRK3
11751 Integer(kind = i4) :: IDEB, JDEB, IMIL, IFIN, NWRK, ICRS, IDCR, ILOW
11752 Integer(kind = i4) :: JLM2, JLM1, JHM2, JHM1
11754 ndon =
SIZE (xdont)
11759 If (nord >= 1)
Then
11770 If (
eq(xdont(icrs), xdont(1)))
Then
11772 Else If (xdont(icrs) < xdont(1))
Then
11782 If (ndon <= icrs)
Then
11783 nord = min(nord, 2)
11784 If (nord >= 1) irngt(1) = ilowt(1)
11785 If (nord >= 2) irngt(2) = ihigt(1)
11791 If (xdont(icrs) < xdont(ihigt(1)))
Then
11792 If (xdont(icrs) < xdont(ilowt(1)))
Then
11794 ihigt(jhig) = ihigt(1)
11795 ihigt(1) = ilowt(1)
11797 Else If (xdont(icrs) > xdont(ilowt(1)))
Then
11799 ihigt(jhig) = ihigt(1)
11802 ElseIf (xdont(icrs) > xdont(ihigt(1)))
Then
11807 If (ndon <= icrs)
Then
11808 nord = min(nord, jhig + 1)
11809 If (nord >= 1) irngt(1) = ilowt(1)
11810 If (nord >= 2) irngt(2) = ihigt(1)
11811 If (nord >= 3) irngt(3) = ihigt(2)
11815 If (xdont(ndon) < xdont(ihigt(1)))
Then
11816 If (xdont(ndon) < xdont(ilowt(1)))
Then
11817 Do idcr = jhig, 1, -1
11818 ihigt(idcr + 1) = ihigt(idcr)
11820 ihigt(1) = ilowt(1)
11823 ElseIf (xdont(ndon) > xdont(ilowt(1)))
Then
11824 Do idcr = jhig, 1, -1
11825 ihigt(idcr + 1) = ihigt(idcr)
11830 ElseIf (xdont(ndon) > xdont(ihigt(1)))
Then
11835 If (ndon <= icrs + 1)
Then
11836 nord = min(nord, jhig + 1)
11837 If (nord >= 1) irngt(1) = ilowt(1)
11838 If (nord >= 2) irngt(2) = ihigt(1)
11839 If (nord >= 3) irngt(3) = ihigt(2)
11840 If (nord >= 4) irngt(4) = ihigt(3)
11847 xpiv = xdont(ilowt(ideb)) + real(2 * nord,
dp) / real(ndon + nord,
dp) * &
11848 (xdont(ihigt(3)) - xdont(ilowt(ideb)))
11849 If (xpiv >= xdont(ihigt(1)))
Then
11850 xpiv = xdont(ilowt(ideb)) + real(2 * nord,
dp) / real(ndon + nord,
dp) * &
11851 (xdont(ihigt(2)) - xdont(ilowt(ideb)))
11852 If (xpiv >= xdont(ihigt(1))) &
11853 xpiv = xdont(ilowt(ideb)) + real(2 * nord,
dp) / real(ndon + nord,
dp) * &
11854 (xdont(ihigt(1)) - xdont(ilowt(ideb)))
11869 If (xdont(ndon) > xpiv)
Then
11872 If (xdont(icrs) > xpiv)
Then
11873 If (icrs >= ndon)
Exit
11878 If (
eq(xdont(icrs), xdont(ilowt(ilow)))) cycle lowloop1
11882 If (jlow >= nord)
Exit
11889 If (icrs < ndon - 1)
Then
11892 If (xdont(icrs) <= xpiv)
Then
11895 Else If (icrs >= ndon)
Then
11907 lowloop2 :
Do icrs = icrs + 1, ndon - 1
11908 If (xdont(icrs) > xpiv)
Then
11913 If (
eq(xdont(icrs), xdont(ilowt(ilow)))) cycle lowloop2
11917 If (jlow >= nord)
Exit
11921 If (icrs < ndon - 1)
Then
11924 If (xdont(icrs) <= xpiv)
Then
11925 If (icrs >= ndon)
Exit
11938 if (jlow == nord)
Exit
11939 If (jlm2 == jlow .And. jhm2 == jhig)
Then
11944 If (nord > jlow)
Then
11945 xmin = xdont(ihigt(1))
11948 If (xdont(ihigt(icrs)) < xmin)
Then
11949 xmin = xdont(ihigt(icrs))
11955 ilowt(jlow) = ihigt(ihig)
11958 If (
ne(xdont(ihigt(icrs)), xmin))
then
11960 ihigt(ihig) = ihigt(icrs)
11968 If (xdont(ilowt(icrs)) > xmax)
Then
11988 IF (jlow + jhig < nord) nord = jlow + jhig
11989 Select Case (nord - jlow)
12004 ilowt(jlow) = ihigt(1)
12012 If (
le(xdont(ihigt(1)), xdont(ihigt(2))))
Then
12014 ilowt(jlow) = ihigt(1)
12016 ilowt(jlow) = ihigt(2)
12017 ElseIf (
eq(xdont(ihigt(1)), xdont(ihigt(2))))
Then
12019 ilowt(jlow) = ihigt(1)
12023 ilowt(jlow) = ihigt(2)
12025 ilowt(jlow) = ihigt(1)
12035 If (xdont(iwrk2) < xdont(iwrk1))
Then
12040 If (xdont(iwrk2) > xdont(iwrk3))
Then
12044 If (xdont(iwrk2) < xdont(ihigt(1)))
Then
12045 ihigt(2) = ihigt(1)
12051 ilowt(jlow) = ihigt(1)
12053 IF (
ne(xdont(ihigt(jhig)), xdont(ilowt(jlow))))
Then
12055 ilowt(jlow) = ihigt(jhig)
12058 IF (
ne(xdont(ihigt(jhig)), xdont(ilowt(jlow))))
Then
12060 ilowt(jlow) = ihigt(jhig)
12062 nord = min(jlow, nord)
12077 iwrk3 = ihigt(ifin)
12078 If (xdont(iwrk2) < xdont(iwrk1))
Then
12083 If (xdont(iwrk2) > xdont(iwrk3))
Then
12084 ihigt(ifin) = iwrk2
12087 If (xdont(iwrk2) < xdont(ihigt(1)))
Then
12088 ihigt(2) = ihigt(1)
12096 xpiv = xdont(iwrk1) + real(nwrk,
dp) / real(nord + nwrk,
dp) * &
12097 (xdont(ihigt(ifin)) - xdont(iwrk1))
12106 lowloop3 :
Do icrs = 1, ifin
12107 If (xdont(ihigt(icrs)) <= xpiv)
Then
12109 If (
eq(xdont(ihigt(icrs)), xdont(ilowt(ilow)))) &
12113 ilowt(jlow) = ihigt(icrs)
12114 If (jlow > nord)
Exit
12117 ihigt(jhig) = ihigt(icrs)
12121 Do icrs = icrs + 1, ifin
12122 If (xdont(ihigt(icrs)) <= xpiv)
Then
12124 ilowt(jlow) = ihigt(icrs)
12135 xmin = xdont(ihigt(1))
12138 If (xdont(ihigt(icrs)) < xmin)
Then
12139 xmin = xdont(ihigt(icrs))
12145 ilowt(jlow) = ihigt(ihig)
12162 irngt(1) = ilowt(1)
12166 Do idcr = icrs - 1, 1, - 1
12167 If (xwrk < xdont(irngt(idcr)))
Then
12168 irngt(idcr + 1) = irngt(idcr)
12173 irngt(idcr + 1) = iwrk
12176 xwrk1 = xdont(irngt(nord))
12177 insert1 :
Do icrs = nord + 1, jlow
12178 If (xdont(ilowt(icrs)) < xwrk1)
Then
12179 xwrk = xdont(ilowt(icrs))
12180 Do ilow = 1, nord - 1
12181 If (xwrk <= xdont(irngt(ilow)))
Then
12182 If (
eq(xwrk, xdont(irngt(ilow)))) cycle insert1
12186 Do idcr = nord - 1, ilow, - 1
12187 irngt(idcr + 1) = irngt(idcr)
12189 irngt(idcr + 1) = ilowt(icrs)
12190 xwrk1 = xdont(irngt(nord))
12203 imil = min((jlow + ideb) / 2, nord)
12204 ifin = min(jlow, nord + 1)
12208 If (xdont(ilowt(imil)) < xdont(ilowt(ideb)))
Then
12210 ilowt(ideb) = ilowt(imil)
12213 If (xdont(ilowt(imil)) > xdont(ilowt(ifin)))
Then
12215 ilowt(ifin) = ilowt(imil)
12217 If (xdont(ilowt(imil)) < xdont(ilowt(ideb)))
Then
12219 ilowt(ideb) = ilowt(imil)
12223 If (ifin <= 3)
Exit
12225 xpiv = xdont(ilowt(ideb)) + real(nord,
dp) / real(jlow + nord,
dp) * &
12226 (xdont(ilowt(ifin)) - xdont(ilowt(1)))
12228 If (xpiv <= xpiv0) &
12229 xpiv = xpiv0 + real(2 * nord - jdeb,
dp) / real(jlow + nord,
dp) * &
12230 (xdont(ilowt(ifin)) - xpiv0)
12243 If (xdont(ilowt(ifin)) > xpiv)
Then
12247 If (xdont(ilowt(icrs)) > xpiv)
Then
12249 ihigt(jhig) = ilowt(icrs)
12250 If (icrs >= ifin)
Exit
12252 xwrk1 = xdont(ilowt(icrs))
12253 Do ilow = ideb, jlow
12254 If (
eq(xwrk1, xdont(ilowt(ilow)))) &
12258 ilowt(jlow) = ilowt(icrs)
12259 If (jlow >= nord)
Exit
12263 If (icrs < ifin)
Then
12266 If (xdont(ilowt(icrs)) <= xpiv)
Then
12268 ilowt(jlow) = ilowt(icrs)
12270 If (icrs >= ifin)
Exit
12275 lowloop5 :
Do icrs = ideb, ifin
12276 If (xdont(ilowt(icrs)) > xpiv)
Then
12278 ihigt(jhig) = ilowt(icrs)
12280 xwrk1 = xdont(ilowt(icrs))
12281 Do ilow = ideb, jlow
12282 If (
eq(xwrk1, xdont(ilowt(ilow)))) &
12286 ilowt(jlow) = ilowt(icrs)
12287 If (jlow >= nord)
Exit
12291 Do icrs = icrs + 1, ifin
12292 If (xdont(ilowt(icrs)) <= xpiv)
Then
12294 ilowt(jlow) = ilowt(icrs)
12307 irngt(1) = ilowt(1)
12311 Do idcr = icrs - 1, 1, - 1
12312 If (xwrk < xdont(irngt(idcr)))
Then
12313 irngt(idcr + 1) = irngt(idcr)
12318 irngt(idcr + 1) = iwrk
12323 End Subroutine d_unipar
12325 Subroutine r_unipar (XDONT, IRNGT, NORD)
12344 Real(kind =
sp),
Dimension (:),
Intent (In) :: xdont
12345 Integer(kind = i4),
Dimension (:),
Intent (Out) :: IRNGT
12346 Integer(kind = i4),
Intent (InOut) :: NORD
12348 Real(kind =
sp) :: xpiv, xwrk, xwrk1, xmin, xmax, xpiv0
12350 Integer(kind = i4),
Dimension (SIZE(XDONT)) :: ILOWT, IHIGT
12351 Integer(kind = i4) :: NDON, JHIG, JLOW, IHIG, IWRK, IWRK1, IWRK2, IWRK3
12352 Integer(kind = i4) :: IDEB, JDEB, IMIL, IFIN, NWRK, ICRS, IDCR, ILOW
12353 Integer(kind = i4) :: JLM2, JLM1, JHM2, JHM1
12355 ndon =
SIZE (xdont)
12360 If (nord >= 1)
Then
12371 If (
eq(xdont(icrs), xdont(1)))
Then
12373 Else If (xdont(icrs) < xdont(1))
Then
12383 If (ndon <= icrs)
Then
12384 nord = min(nord, 2)
12385 If (nord >= 1) irngt(1) = ilowt(1)
12386 If (nord >= 2) irngt(2) = ihigt(1)
12392 If (xdont(icrs) < xdont(ihigt(1)))
Then
12393 If (xdont(icrs) < xdont(ilowt(1)))
Then
12395 ihigt(jhig) = ihigt(1)
12396 ihigt(1) = ilowt(1)
12398 Else If (xdont(icrs) > xdont(ilowt(1)))
Then
12400 ihigt(jhig) = ihigt(1)
12403 ElseIf (xdont(icrs) > xdont(ihigt(1)))
Then
12408 If (ndon <= icrs)
Then
12409 nord = min(nord, jhig + 1)
12410 If (nord >= 1) irngt(1) = ilowt(1)
12411 If (nord >= 2) irngt(2) = ihigt(1)
12412 If (nord >= 3) irngt(3) = ihigt(2)
12416 If (xdont(ndon) < xdont(ihigt(1)))
Then
12417 If (xdont(ndon) < xdont(ilowt(1)))
Then
12418 Do idcr = jhig, 1, -1
12419 ihigt(idcr + 1) = ihigt(idcr)
12421 ihigt(1) = ilowt(1)
12424 ElseIf (xdont(ndon) > xdont(ilowt(1)))
Then
12425 Do idcr = jhig, 1, -1
12426 ihigt(idcr + 1) = ihigt(idcr)
12431 ElseIf (xdont(ndon) > xdont(ihigt(1)))
Then
12436 If (ndon <= icrs + 1)
Then
12437 nord = min(nord, jhig + 1)
12438 If (nord >= 1) irngt(1) = ilowt(1)
12439 If (nord >= 2) irngt(2) = ihigt(1)
12440 If (nord >= 3) irngt(3) = ihigt(2)
12441 If (nord >= 4) irngt(4) = ihigt(3)
12448 xpiv = xdont(ilowt(ideb)) + real(2 * nord,
sp) / real(ndon + nord,
sp) * &
12449 (xdont(ihigt(3)) - xdont(ilowt(ideb)))
12450 If (xpiv >= xdont(ihigt(1)))
Then
12451 xpiv = xdont(ilowt(ideb)) + real(2 * nord,
sp) / real(ndon + nord,
sp) * &
12452 (xdont(ihigt(2)) - xdont(ilowt(ideb)))
12453 If (xpiv >= xdont(ihigt(1))) &
12454 xpiv = xdont(ilowt(ideb)) + real(2 * nord,
sp) / real(ndon + nord,
sp) * &
12455 (xdont(ihigt(1)) - xdont(ilowt(ideb)))
12470 If (xdont(ndon) > xpiv)
Then
12473 If (xdont(icrs) > xpiv)
Then
12474 If (icrs >= ndon)
Exit
12479 If (
eq(xdont(icrs), xdont(ilowt(ilow)))) cycle lowloop1
12483 If (jlow >= nord)
Exit
12490 If (icrs < ndon - 1)
Then
12493 If (xdont(icrs) <= xpiv)
Then
12496 Else If (icrs >= ndon)
Then
12508 lowloop2 :
Do icrs = icrs + 1, ndon - 1
12509 If (xdont(icrs) > xpiv)
Then
12514 If (
eq(xdont(icrs), xdont(ilowt(ilow)))) cycle lowloop2
12518 If (jlow >= nord)
Exit
12522 If (icrs < ndon - 1)
Then
12525 If (xdont(icrs) <= xpiv)
Then
12526 If (icrs >= ndon)
Exit
12539 if (jlow == nord)
Exit
12540 If (jlm2 == jlow .And. jhm2 == jhig)
Then
12545 If (nord > jlow)
Then
12546 xmin = xdont(ihigt(1))
12549 If (xdont(ihigt(icrs)) < xmin)
Then
12550 xmin = xdont(ihigt(icrs))
12556 ilowt(jlow) = ihigt(ihig)
12559 If (
ne(xdont(ihigt(icrs)), xmin))
then
12561 ihigt(ihig) = ihigt(icrs)
12569 If (xdont(ilowt(icrs)) > xmax)
Then
12589 IF (jlow + jhig < nord) nord = jlow + jhig
12590 Select Case (nord - jlow)
12605 ilowt(jlow) = ihigt(1)
12613 If (
le(xdont(ihigt(1)), xdont(ihigt(2))))
Then
12615 ilowt(jlow) = ihigt(1)
12617 ilowt(jlow) = ihigt(2)
12618 ElseIf (
eq(xdont(ihigt(1)), xdont(ihigt(2))))
Then
12620 ilowt(jlow) = ihigt(1)
12624 ilowt(jlow) = ihigt(2)
12626 ilowt(jlow) = ihigt(1)
12636 If (xdont(iwrk2) < xdont(iwrk1))
Then
12641 If (xdont(iwrk2) > xdont(iwrk3))
Then
12645 If (xdont(iwrk2) < xdont(ihigt(1)))
Then
12646 ihigt(2) = ihigt(1)
12652 ilowt(jlow) = ihigt(1)
12654 IF (
ne(xdont(ihigt(jhig)), xdont(ilowt(jlow))))
Then
12656 ilowt(jlow) = ihigt(jhig)
12659 IF (
ne(xdont(ihigt(jhig)), xdont(ilowt(jlow))))
Then
12661 ilowt(jlow) = ihigt(jhig)
12663 nord = min(jlow, nord)
12678 iwrk3 = ihigt(ifin)
12679 If (xdont(iwrk2) < xdont(iwrk1))
Then
12684 If (xdont(iwrk2) > xdont(iwrk3))
Then
12685 ihigt(ifin) = iwrk2
12688 If (xdont(iwrk2) < xdont(ihigt(1)))
Then
12689 ihigt(2) = ihigt(1)
12697 xpiv = xdont(iwrk1) + real(nwrk,
sp) / real(nord + nwrk,
sp) * &
12698 (xdont(ihigt(ifin)) - xdont(iwrk1))
12707 lowloop3 :
Do icrs = 1, ifin
12708 If (xdont(ihigt(icrs)) <= xpiv)
Then
12710 If (
eq(xdont(ihigt(icrs)), xdont(ilowt(ilow)))) &
12714 ilowt(jlow) = ihigt(icrs)
12715 If (jlow > nord)
Exit
12718 ihigt(jhig) = ihigt(icrs)
12722 Do icrs = icrs + 1, ifin
12723 If (xdont(ihigt(icrs)) <= xpiv)
Then
12725 ilowt(jlow) = ihigt(icrs)
12736 xmin = xdont(ihigt(1))
12739 If (xdont(ihigt(icrs)) < xmin)
Then
12740 xmin = xdont(ihigt(icrs))
12746 ilowt(jlow) = ihigt(ihig)
12763 irngt(1) = ilowt(1)
12767 Do idcr = icrs - 1, 1, - 1
12768 If (xwrk < xdont(irngt(idcr)))
Then
12769 irngt(idcr + 1) = irngt(idcr)
12774 irngt(idcr + 1) = iwrk
12777 xwrk1 = xdont(irngt(nord))
12778 insert1 :
Do icrs = nord + 1, jlow
12779 If (xdont(ilowt(icrs)) < xwrk1)
Then
12780 xwrk = xdont(ilowt(icrs))
12781 Do ilow = 1, nord - 1
12782 If (xwrk <= xdont(irngt(ilow)))
Then
12783 If (
eq(xwrk, xdont(irngt(ilow)))) cycle insert1
12787 Do idcr = nord - 1, ilow, - 1
12788 irngt(idcr + 1) = irngt(idcr)
12790 irngt(idcr + 1) = ilowt(icrs)
12791 xwrk1 = xdont(irngt(nord))
12804 imil = min((jlow + ideb) / 2, nord)
12805 ifin = min(jlow, nord + 1)
12809 If (xdont(ilowt(imil)) < xdont(ilowt(ideb)))
Then
12811 ilowt(ideb) = ilowt(imil)
12814 If (xdont(ilowt(imil)) > xdont(ilowt(ifin)))
Then
12816 ilowt(ifin) = ilowt(imil)
12818 If (xdont(ilowt(imil)) < xdont(ilowt(ideb)))
Then
12820 ilowt(ideb) = ilowt(imil)
12824 If (ifin <= 3)
Exit
12826 xpiv = xdont(ilowt(ideb)) + real(nord,
sp) / real(jlow + nord,
sp) * &
12827 (xdont(ilowt(ifin)) - xdont(ilowt(1)))
12829 If (xpiv <= xpiv0) &
12830 xpiv = xpiv0 + real(2 * nord - jdeb,
sp) / real(jlow + nord,
sp) * &
12831 (xdont(ilowt(ifin)) - xpiv0)
12844 If (xdont(ilowt(ifin)) > xpiv)
Then
12848 If (xdont(ilowt(icrs)) > xpiv)
Then
12850 ihigt(jhig) = ilowt(icrs)
12851 If (icrs >= ifin)
Exit
12853 xwrk1 = xdont(ilowt(icrs))
12854 Do ilow = ideb, jlow
12855 If (
eq(xwrk1, xdont(ilowt(ilow)))) &
12859 ilowt(jlow) = ilowt(icrs)
12860 If (jlow >= nord)
Exit
12864 If (icrs < ifin)
Then
12867 If (xdont(ilowt(icrs)) <= xpiv)
Then
12869 ilowt(jlow) = ilowt(icrs)
12871 If (icrs >= ifin)
Exit
12876 lowloop5 :
Do icrs = ideb, ifin
12877 If (xdont(ilowt(icrs)) > xpiv)
Then
12879 ihigt(jhig) = ilowt(icrs)
12881 xwrk1 = xdont(ilowt(icrs))
12882 Do ilow = ideb, jlow
12883 If (
eq(xwrk1, xdont(ilowt(ilow)))) &
12887 ilowt(jlow) = ilowt(icrs)
12888 If (jlow >= nord)
Exit
12892 Do icrs = icrs + 1, ifin
12893 If (xdont(ilowt(icrs)) <= xpiv)
Then
12895 ilowt(jlow) = ilowt(icrs)
12908 irngt(1) = ilowt(1)
12912 Do idcr = icrs - 1, 1, - 1
12913 If (xwrk < xdont(irngt(idcr)))
Then
12914 irngt(idcr + 1) = irngt(idcr)
12919 irngt(idcr + 1) = iwrk
12924 End Subroutine r_unipar
12926 Subroutine i_unipar (XDONT, IRNGT, NORD)
12945 Integer(kind = i4),
Dimension (:),
Intent (In) :: XDONT
12946 Integer(kind = i4),
Dimension (:),
Intent (Out) :: IRNGT
12947 Integer(kind = i4),
Intent (InOut) :: NORD
12949 Integer(kind = i4) :: XPIV, XWRK, XWRK1, XMIN, XMAX, XPIV0
12951 Integer(kind = i4),
Dimension (SIZE(XDONT)) :: ILOWT, IHIGT
12952 Integer(kind = i4) :: NDON, JHIG, JLOW, IHIG, IWRK, IWRK1, IWRK2, IWRK3
12953 Integer(kind = i4) :: IDEB, JDEB, IMIL, IFIN, NWRK, ICRS, IDCR, ILOW
12954 Integer(kind = i4) :: JLM2, JLM1, JHM2, JHM1
12956 ndon =
SIZE (xdont)
12961 If (nord >= 1)
Then
12972 If (xdont(icrs) == xdont(1))
Then
12974 Else If (xdont(icrs) < xdont(1))
Then
12984 If (ndon <= icrs)
Then
12985 nord = min(nord, 2)
12986 If (nord >= 1) irngt(1) = ilowt(1)
12987 If (nord >= 2) irngt(2) = ihigt(1)
12993 If (xdont(icrs) < xdont(ihigt(1)))
Then
12994 If (xdont(icrs) < xdont(ilowt(1)))
Then
12996 ihigt(jhig) = ihigt(1)
12997 ihigt(1) = ilowt(1)
12999 Else If (xdont(icrs) > xdont(ilowt(1)))
Then
13001 ihigt(jhig) = ihigt(1)
13004 ElseIf (xdont(icrs) > xdont(ihigt(1)))
Then
13009 If (ndon <= icrs)
Then
13010 nord = min(nord, jhig + 1)
13011 If (nord >= 1) irngt(1) = ilowt(1)
13012 If (nord >= 2) irngt(2) = ihigt(1)
13013 If (nord >= 3) irngt(3) = ihigt(2)
13017 If (xdont(ndon) < xdont(ihigt(1)))
Then
13018 If (xdont(ndon) < xdont(ilowt(1)))
Then
13019 Do idcr = jhig, 1, -1
13020 ihigt(idcr + 1) = ihigt(idcr)
13022 ihigt(1) = ilowt(1)
13025 ElseIf (xdont(ndon) > xdont(ilowt(1)))
Then
13026 Do idcr = jhig, 1, -1
13027 ihigt(idcr + 1) = ihigt(idcr)
13032 ElseIf (xdont(ndon) > xdont(ihigt(1)))
Then
13037 If (ndon <= icrs + 1)
Then
13038 nord = min(nord, jhig + 1)
13039 If (nord >= 1) irngt(1) = ilowt(1)
13040 If (nord >= 2) irngt(2) = ihigt(1)
13041 If (nord >= 3) irngt(3) = ihigt(2)
13042 If (nord >= 4) irngt(4) = ihigt(3)
13049 xpiv = xdont(ilowt(ideb)) + int(real(2 * nord,
sp) / real(ndon + nord,
sp),
i4) * &
13050 (xdont(ihigt(3)) - xdont(ilowt(ideb)))
13051 If (xpiv >= xdont(ihigt(1)))
Then
13052 xpiv = xdont(ilowt(ideb)) + int(real(2 * nord,
sp) / real(ndon + nord,
sp),
i4) * &
13053 (xdont(ihigt(2)) - xdont(ilowt(ideb)))
13054 If (xpiv >= xdont(ihigt(1))) &
13055 xpiv = xdont(ilowt(ideb)) + int(real(2 * nord,
sp) / real(ndon + nord,
sp),
i4) * &
13056 (xdont(ihigt(1)) - xdont(ilowt(ideb)))
13071 If (xdont(ndon) > xpiv)
Then
13074 If (xdont(icrs) > xpiv)
Then
13075 If (icrs >= ndon)
Exit
13080 If (xdont(icrs) == xdont(ilowt(ilow))) cycle lowloop1
13084 If (jlow >= nord)
Exit
13091 If (icrs < ndon - 1)
Then
13094 If (xdont(icrs) <= xpiv)
Then
13097 Else If (icrs >= ndon)
Then
13109 lowloop2 :
Do icrs = icrs + 1, ndon - 1
13110 If (xdont(icrs) > xpiv)
Then
13115 If (xdont(icrs) == xdont(ilowt(ilow))) cycle lowloop2
13119 If (jlow >= nord)
Exit
13123 If (icrs < ndon - 1)
Then
13126 If (xdont(icrs) <= xpiv)
Then
13127 If (icrs >= ndon)
Exit
13140 if (jlow == nord)
Exit
13141 If (jlm2 == jlow .And. jhm2 == jhig)
Then
13146 If (nord > jlow)
Then
13147 xmin = xdont(ihigt(1))
13150 If (xdont(ihigt(icrs)) < xmin)
Then
13151 xmin = xdont(ihigt(icrs))
13157 ilowt(jlow) = ihigt(ihig)
13160 If (xdont(ihigt(icrs)) /= xmin)
then
13162 ihigt(ihig) = ihigt(icrs)
13170 If (xdont(ilowt(icrs)) > xmax)
Then
13190 IF (jlow + jhig < nord) nord = jlow + jhig
13191 Select Case (nord - jlow)
13206 ilowt(jlow) = ihigt(1)
13214 If (xdont(ihigt(1)) <= xdont(ihigt(2)))
Then
13216 ilowt(jlow) = ihigt(1)
13218 ilowt(jlow) = ihigt(2)
13219 ElseIf (xdont(ihigt(1)) == xdont(ihigt(2)))
Then
13221 ilowt(jlow) = ihigt(1)
13225 ilowt(jlow) = ihigt(2)
13227 ilowt(jlow) = ihigt(1)
13237 If (xdont(iwrk2) < xdont(iwrk1))
Then
13242 If (xdont(iwrk2) > xdont(iwrk3))
Then
13246 If (xdont(iwrk2) < xdont(ihigt(1)))
Then
13247 ihigt(2) = ihigt(1)
13253 ilowt(jlow) = ihigt(1)
13255 IF (xdont(ihigt(jhig)) /= xdont(ilowt(jlow)))
Then
13257 ilowt(jlow) = ihigt(jhig)
13260 IF (xdont(ihigt(jhig)) /= xdont(ilowt(jlow)))
Then
13262 ilowt(jlow) = ihigt(jhig)
13264 nord = min(jlow, nord)
13279 iwrk3 = ihigt(ifin)
13280 If (xdont(iwrk2) < xdont(iwrk1))
Then
13285 If (xdont(iwrk2) > xdont(iwrk3))
Then
13286 ihigt(ifin) = iwrk2
13289 If (xdont(iwrk2) < xdont(ihigt(1)))
Then
13290 ihigt(2) = ihigt(1)
13298 xpiv = xdont(iwrk1) + int(real(nwrk,
sp) / real(nord + nwrk,
sp),
i4) * &
13299 (xdont(ihigt(ifin)) - xdont(iwrk1))
13308 lowloop3 :
Do icrs = 1, ifin
13309 If (xdont(ihigt(icrs)) <= xpiv)
Then
13311 If (xdont(ihigt(icrs)) == xdont(ilowt(ilow))) &
13315 ilowt(jlow) = ihigt(icrs)
13316 If (jlow > nord)
Exit
13319 ihigt(jhig) = ihigt(icrs)
13323 Do icrs = icrs + 1, ifin
13324 If (xdont(ihigt(icrs)) <= xpiv)
Then
13326 ilowt(jlow) = ihigt(icrs)
13337 xmin = xdont(ihigt(1))
13340 If (xdont(ihigt(icrs)) < xmin)
Then
13341 xmin = xdont(ihigt(icrs))
13347 ilowt(jlow) = ihigt(ihig)
13364 irngt(1) = ilowt(1)
13368 Do idcr = icrs - 1, 1, - 1
13369 If (xwrk < xdont(irngt(idcr)))
Then
13370 irngt(idcr + 1) = irngt(idcr)
13375 irngt(idcr + 1) = iwrk
13378 xwrk1 = xdont(irngt(nord))
13379 insert1 :
Do icrs = nord + 1, jlow
13380 If (xdont(ilowt(icrs)) < xwrk1)
Then
13381 xwrk = xdont(ilowt(icrs))
13382 Do ilow = 1, nord - 1
13383 If (xwrk <= xdont(irngt(ilow)))
Then
13384 If (xwrk == xdont(irngt(ilow))) cycle insert1
13388 Do idcr = nord - 1, ilow, - 1
13389 irngt(idcr + 1) = irngt(idcr)
13391 irngt(idcr + 1) = ilowt(icrs)
13392 xwrk1 = xdont(irngt(nord))
13405 imil = min((jlow + ideb) / 2, nord)
13406 ifin = min(jlow, nord + 1)
13410 If (xdont(ilowt(imil)) < xdont(ilowt(ideb)))
Then
13412 ilowt(ideb) = ilowt(imil)
13415 If (xdont(ilowt(imil)) > xdont(ilowt(ifin)))
Then
13417 ilowt(ifin) = ilowt(imil)
13419 If (xdont(ilowt(imil)) < xdont(ilowt(ideb)))
Then
13421 ilowt(ideb) = ilowt(imil)
13425 If (ifin <= 3)
Exit
13427 xpiv = xdont(ilowt(ideb)) + int(real(nord,
sp) / real(jlow + nord,
sp),
i4) * &
13428 (xdont(ilowt(ifin)) - xdont(ilowt(1)))
13430 If (xpiv <= xpiv0) &
13431 xpiv = xpiv0 + int(real(2 * nord - jdeb,
sp) / real(jlow + nord,
sp),
i4) * &
13432 (xdont(ilowt(ifin)) - xpiv0)
13445 If (xdont(ilowt(ifin)) > xpiv)
Then
13449 If (xdont(ilowt(icrs)) > xpiv)
Then
13451 ihigt(jhig) = ilowt(icrs)
13452 If (icrs >= ifin)
Exit
13454 xwrk1 = xdont(ilowt(icrs))
13455 Do ilow = ideb, jlow
13456 If (xwrk1 == xdont(ilowt(ilow))) &
13460 ilowt(jlow) = ilowt(icrs)
13461 If (jlow >= nord)
Exit
13465 If (icrs < ifin)
Then
13468 If (xdont(ilowt(icrs)) <= xpiv)
Then
13470 ilowt(jlow) = ilowt(icrs)
13472 If (icrs >= ifin)
Exit
13477 lowloop5 :
Do icrs = ideb, ifin
13478 If (xdont(ilowt(icrs)) > xpiv)
Then
13480 ihigt(jhig) = ilowt(icrs)
13482 xwrk1 = xdont(ilowt(icrs))
13483 Do ilow = ideb, jlow
13484 If (xwrk1 == xdont(ilowt(ilow))) &
13488 ilowt(jlow) = ilowt(icrs)
13489 If (jlow >= nord)
Exit
13493 Do icrs = icrs + 1, ifin
13494 If (xdont(ilowt(icrs)) <= xpiv)
Then
13496 ilowt(jlow) = ilowt(icrs)
13509 irngt(1) = ilowt(1)
13513 Do idcr = icrs - 1, 1, - 1
13514 If (xwrk < xdont(irngt(idcr)))
Then
13515 irngt(idcr + 1) = irngt(idcr)
13520 irngt(idcr + 1) = iwrk
13525 End Subroutine i_unipar
13527 Subroutine d_unirnk (XVALT, IRNGT, NUNI)
13538 real(Kind =
dp),
Dimension (:),
Intent (In) :: xvalt
13539 Integer(kind = i4),
Dimension (:),
Intent (Out) :: IRNGT
13540 Integer(kind = i4),
Intent (Out) :: NUNI
13542 Integer(kind = i4),
Dimension (SIZE(IRNGT)) :: JWRKT
13543 Integer(kind = i4) :: LMTNA, LMTNC, IRNG, IRNG1, IRNG2
13544 Integer(kind = i4) :: NVAL, IIND, IWRKD, IWRK, IWRKF, JINDA, IINDA, IINDB
13545 real(Kind =
dp) :: xtst, xvala, xvalb
13548 nval = min(
SIZE(xvalt),
SIZE(irngt))
13563 Do iind = 2, nval, 2
13564 If (xvalt(iind - 1) < xvalt(iind))
Then
13565 irngt(iind - 1) = iind - 1
13568 irngt(iind - 1) = iind
13569 irngt(iind) = iind - 1
13572 If (modulo(nval, 2) /= 0)
Then
13585 If (nval <= 4)
Exit
13589 Do iwrkd = 0, nval - 1, 4
13590 If ((iwrkd + 4) > nval)
Then
13591 If ((iwrkd + 2) >= nval)
Exit
13595 If (xvalt(irngt(iwrkd + 2)) <= xvalt(irngt(iwrkd + 3)))
Exit
13599 If (xvalt(irngt(iwrkd + 1)) <= xvalt(irngt(iwrkd + 3)))
Then
13600 irng2 = irngt(iwrkd + 2)
13601 irngt(iwrkd + 2) = irngt(iwrkd + 3)
13602 irngt(iwrkd + 3) = irng2
13607 irng1 = irngt(iwrkd + 1)
13608 irngt(iwrkd + 1) = irngt(iwrkd + 3)
13609 irngt(iwrkd + 3) = irngt(iwrkd + 2)
13610 irngt(iwrkd + 2) = irng1
13617 If (xvalt(irngt(iwrkd + 2)) <= xvalt(irngt(iwrkd + 3))) cycle
13621 If (xvalt(irngt(iwrkd + 1)) <= xvalt(irngt(iwrkd + 3)))
Then
13622 irng2 = irngt(iwrkd + 2)
13623 irngt(iwrkd + 2) = irngt(iwrkd + 3)
13624 If (xvalt(irng2) <= xvalt(irngt(iwrkd + 4)))
Then
13626 irngt(iwrkd + 3) = irng2
13629 irngt(iwrkd + 3) = irngt(iwrkd + 4)
13630 irngt(iwrkd + 4) = irng2
13636 irng1 = irngt(iwrkd + 1)
13637 irng2 = irngt(iwrkd + 2)
13638 irngt(iwrkd + 1) = irngt(iwrkd + 3)
13639 If (xvalt(irng1) <= xvalt(irngt(iwrkd + 4)))
Then
13640 irngt(iwrkd + 2) = irng1
13641 If (xvalt(irng2) <= xvalt(irngt(iwrkd + 4)))
Then
13643 irngt(iwrkd + 3) = irng2
13646 irngt(iwrkd + 3) = irngt(iwrkd + 4)
13647 irngt(iwrkd + 4) = irng2
13651 irngt(iwrkd + 2) = irngt(iwrkd + 4)
13652 irngt(iwrkd + 3) = irng1
13653 irngt(iwrkd + 4) = irng2
13668 If (2 * lmtna >= nval)
Exit
13677 jinda = iwrkf + lmtna
13678 iwrkf = iwrkf + lmtnc
13679 If (iwrkf >= nval)
Then
13680 If (jinda >= nval)
Exit
13690 jwrkt(1 : lmtna) = irngt(iwrkd : jinda)
13691 xvala = xvalt(jwrkt(iinda))
13692 xvalb = xvalt(irngt(iindb))
13699 If (xvala > xvalb)
Then
13700 irngt(iwrk) = irngt(iindb)
13702 If (iindb > iwrkf)
Then
13704 irngt(iwrk + 1 : iwrkf) = jwrkt(iinda : lmtna)
13707 xvalb = xvalt(irngt(iindb))
13709 irngt(iwrk) = jwrkt(iinda)
13711 If (iinda > lmtna) exit
13712 xvala = xvalt(jwrkt(iinda))
13731 jwrkt(1 : lmtna) = irngt(1 : lmtna)
13732 If (iindb <= nval)
Then
13733 xtst =
nearless(min(xvalt(jwrkt(1)), xvalt(irngt(iindb))))
13741 If (iinda <= lmtna)
Then
13742 If (iindb <= nval)
Then
13743 If (xvalt(jwrkt(iinda)) > xvalt(irngt(iindb)))
Then
13744 irng = irngt(iindb)
13747 irng = jwrkt(iinda)
13754 irng = jwrkt(iinda)
13763 If (xvalt(irng) > xtst)
Then
13773 End Subroutine d_unirnk
13775 Subroutine r_unirnk (XVALT, IRNGT, NUNI)
13786 Real(kind =
sp),
Dimension (:),
Intent (In) :: xvalt
13787 Integer(kind = i4),
Dimension (:),
Intent (Out) :: IRNGT
13788 Integer(kind = i4),
Intent (Out) :: NUNI
13790 Integer(kind = i4),
Dimension (SIZE(IRNGT)) :: JWRKT
13791 Integer(kind = i4) :: LMTNA, LMTNC, IRNG, IRNG1, IRNG2
13792 Integer(kind = i4) :: NVAL, IIND, IWRKD, IWRK, IWRKF, JINDA, IINDA, IINDB
13793 Real(kind =
sp) :: xtst, xvala, xvalb
13796 nval = min(
SIZE(xvalt),
SIZE(irngt))
13811 Do iind = 2, nval, 2
13812 If (xvalt(iind - 1) < xvalt(iind))
Then
13813 irngt(iind - 1) = iind - 1
13816 irngt(iind - 1) = iind
13817 irngt(iind) = iind - 1
13820 If (modulo(nval, 2) /= 0)
Then
13833 If (nval <= 4)
Exit
13837 Do iwrkd = 0, nval - 1, 4
13838 If ((iwrkd + 4) > nval)
Then
13839 If ((iwrkd + 2) >= nval)
Exit
13843 If (xvalt(irngt(iwrkd + 2)) <= xvalt(irngt(iwrkd + 3)))
Exit
13847 If (xvalt(irngt(iwrkd + 1)) <= xvalt(irngt(iwrkd + 3)))
Then
13848 irng2 = irngt(iwrkd + 2)
13849 irngt(iwrkd + 2) = irngt(iwrkd + 3)
13850 irngt(iwrkd + 3) = irng2
13855 irng1 = irngt(iwrkd + 1)
13856 irngt(iwrkd + 1) = irngt(iwrkd + 3)
13857 irngt(iwrkd + 3) = irngt(iwrkd + 2)
13858 irngt(iwrkd + 2) = irng1
13865 If (xvalt(irngt(iwrkd + 2)) <= xvalt(irngt(iwrkd + 3))) cycle
13869 If (xvalt(irngt(iwrkd + 1)) <= xvalt(irngt(iwrkd + 3)))
Then
13870 irng2 = irngt(iwrkd + 2)
13871 irngt(iwrkd + 2) = irngt(iwrkd + 3)
13872 If (xvalt(irng2) <= xvalt(irngt(iwrkd + 4)))
Then
13874 irngt(iwrkd + 3) = irng2
13877 irngt(iwrkd + 3) = irngt(iwrkd + 4)
13878 irngt(iwrkd + 4) = irng2
13884 irng1 = irngt(iwrkd + 1)
13885 irng2 = irngt(iwrkd + 2)
13886 irngt(iwrkd + 1) = irngt(iwrkd + 3)
13887 If (xvalt(irng1) <= xvalt(irngt(iwrkd + 4)))
Then
13888 irngt(iwrkd + 2) = irng1
13889 If (xvalt(irng2) <= xvalt(irngt(iwrkd + 4)))
Then
13891 irngt(iwrkd + 3) = irng2
13894 irngt(iwrkd + 3) = irngt(iwrkd + 4)
13895 irngt(iwrkd + 4) = irng2
13899 irngt(iwrkd + 2) = irngt(iwrkd + 4)
13900 irngt(iwrkd + 3) = irng1
13901 irngt(iwrkd + 4) = irng2
13916 If (2 * lmtna >= nval)
Exit
13925 jinda = iwrkf + lmtna
13926 iwrkf = iwrkf + lmtnc
13927 If (iwrkf >= nval)
Then
13928 If (jinda >= nval)
Exit
13938 jwrkt(1 : lmtna) = irngt(iwrkd : jinda)
13939 xvala = xvalt(jwrkt(iinda))
13940 xvalb = xvalt(irngt(iindb))
13947 If (xvala > xvalb)
Then
13948 irngt(iwrk) = irngt(iindb)
13950 If (iindb > iwrkf)
Then
13952 irngt(iwrk + 1 : iwrkf) = jwrkt(iinda : lmtna)
13955 xvalb = xvalt(irngt(iindb))
13957 irngt(iwrk) = jwrkt(iinda)
13959 If (iinda > lmtna) exit
13960 xvala = xvalt(jwrkt(iinda))
13979 jwrkt(1 : lmtna) = irngt(1 : lmtna)
13980 If (iindb <= nval)
Then
13981 xtst =
nearless(min(xvalt(jwrkt(1)), xvalt(irngt(iindb))))
13989 If (iinda <= lmtna)
Then
13990 If (iindb <= nval)
Then
13991 If (xvalt(jwrkt(iinda)) > xvalt(irngt(iindb)))
Then
13992 irng = irngt(iindb)
13995 irng = jwrkt(iinda)
14002 irng = jwrkt(iinda)
14011 If (xvalt(irng) > xtst)
Then
14021 End Subroutine r_unirnk
14023 Subroutine i_unirnk (XVALT, IRNGT, NUNI)
14034 Integer(kind = i4),
Dimension (:),
Intent (In) :: XVALT
14035 Integer(kind = i4),
Dimension (:),
Intent (Out) :: IRNGT
14036 Integer(kind = i4),
Intent (Out) :: NUNI
14038 Integer(kind = i4),
Dimension (SIZE(IRNGT)) :: JWRKT
14039 Integer(kind = i4) :: LMTNA, LMTNC, IRNG, IRNG1, IRNG2
14040 Integer(kind = i4) :: NVAL, IIND, IWRKD, IWRK, IWRKF, JINDA, IINDA, IINDB
14041 Integer(kind = i4) :: XTST, XVALA, XVALB
14044 nval = min(
SIZE(xvalt),
SIZE(irngt))
14059 Do iind = 2, nval, 2
14060 If (xvalt(iind - 1) < xvalt(iind))
Then
14061 irngt(iind - 1) = iind - 1
14064 irngt(iind - 1) = iind
14065 irngt(iind) = iind - 1
14068 If (modulo(nval, 2) /= 0)
Then
14081 If (nval <= 4)
Exit
14085 Do iwrkd = 0, nval - 1, 4
14086 If ((iwrkd + 4) > nval)
Then
14087 If ((iwrkd + 2) >= nval)
Exit
14091 If (xvalt(irngt(iwrkd + 2)) <= xvalt(irngt(iwrkd + 3)))
Exit
14095 If (xvalt(irngt(iwrkd + 1)) <= xvalt(irngt(iwrkd + 3)))
Then
14096 irng2 = irngt(iwrkd + 2)
14097 irngt(iwrkd + 2) = irngt(iwrkd + 3)
14098 irngt(iwrkd + 3) = irng2
14103 irng1 = irngt(iwrkd + 1)
14104 irngt(iwrkd + 1) = irngt(iwrkd + 3)
14105 irngt(iwrkd + 3) = irngt(iwrkd + 2)
14106 irngt(iwrkd + 2) = irng1
14113 If (xvalt(irngt(iwrkd + 2)) <= xvalt(irngt(iwrkd + 3))) cycle
14117 If (xvalt(irngt(iwrkd + 1)) <= xvalt(irngt(iwrkd + 3)))
Then
14118 irng2 = irngt(iwrkd + 2)
14119 irngt(iwrkd + 2) = irngt(iwrkd + 3)
14120 If (xvalt(irng2) <= xvalt(irngt(iwrkd + 4)))
Then
14122 irngt(iwrkd + 3) = irng2
14125 irngt(iwrkd + 3) = irngt(iwrkd + 4)
14126 irngt(iwrkd + 4) = irng2
14132 irng1 = irngt(iwrkd + 1)
14133 irng2 = irngt(iwrkd + 2)
14134 irngt(iwrkd + 1) = irngt(iwrkd + 3)
14135 If (xvalt(irng1) <= xvalt(irngt(iwrkd + 4)))
Then
14136 irngt(iwrkd + 2) = irng1
14137 If (xvalt(irng2) <= xvalt(irngt(iwrkd + 4)))
Then
14139 irngt(iwrkd + 3) = irng2
14142 irngt(iwrkd + 3) = irngt(iwrkd + 4)
14143 irngt(iwrkd + 4) = irng2
14147 irngt(iwrkd + 2) = irngt(iwrkd + 4)
14148 irngt(iwrkd + 3) = irng1
14149 irngt(iwrkd + 4) = irng2
14164 If (2 * lmtna >= nval)
Exit
14173 jinda = iwrkf + lmtna
14174 iwrkf = iwrkf + lmtnc
14175 If (iwrkf >= nval)
Then
14176 If (jinda >= nval)
Exit
14186 jwrkt(1 : lmtna) = irngt(iwrkd : jinda)
14187 xvala = xvalt(jwrkt(iinda))
14188 xvalb = xvalt(irngt(iindb))
14195 If (xvala > xvalb)
Then
14196 irngt(iwrk) = irngt(iindb)
14198 If (iindb > iwrkf)
Then
14200 irngt(iwrk + 1 : iwrkf) = jwrkt(iinda : lmtna)
14203 xvalb = xvalt(irngt(iindb))
14205 irngt(iwrk) = jwrkt(iinda)
14207 If (iinda > lmtna) exit
14208 xvala = xvalt(jwrkt(iinda))
14227 jwrkt(1 : lmtna) = irngt(1 : lmtna)
14228 If (iindb <= nval)
Then
14229 xtst =
nearless(min(xvalt(jwrkt(1)), xvalt(irngt(iindb))))
14237 If (iinda <= lmtna)
Then
14238 If (iindb <= nval)
Then
14239 If (xvalt(jwrkt(iinda)) > xvalt(irngt(iindb)))
Then
14240 irng = irngt(iindb)
14243 irng = jwrkt(iinda)
14250 irng = jwrkt(iinda)
14259 If (xvalt(irng) > xtst)
Then
14269 End Subroutine i_unirnk
14272 Subroutine d_unista (XDONT, NUNI)
14279 real(kind =
dp),
Dimension (:),
Intent (InOut) :: xdont
14280 Integer(kind = i4),
Intent (Out) :: NUNI
14283 Integer(kind = i4),
Dimension (Size(XDONT)) :: IWRKT
14284 Logical,
Dimension (Size(XDONT)) :: IFMPTYT
14285 Integer(kind = i4) :: ICRS
14287 Call uniinv (xdont, iwrkt)
14290 Do icrs = 1,
Size(xdont)
14291 If (ifmptyt(iwrkt(icrs)))
Then
14292 ifmptyt(iwrkt(icrs)) = .false.
14294 xdont(nuni) = xdont(icrs)
14299 End Subroutine d_unista
14301 Subroutine r_unista (XDONT, NUNI)
14308 Real(kind =
sp),
Dimension (:),
Intent (InOut) :: xdont
14309 Integer(kind = i4),
Intent (Out) :: NUNI
14312 Integer(kind = i4),
Dimension (Size(XDONT)) :: IWRKT
14313 Logical,
Dimension (Size(XDONT)) :: IFMPTYT
14314 Integer(kind = i4) :: ICRS
14316 Call uniinv (xdont, iwrkt)
14319 Do icrs = 1,
Size(xdont)
14320 If (ifmptyt(iwrkt(icrs)))
Then
14321 ifmptyt(iwrkt(icrs)) = .false.
14323 xdont(nuni) = xdont(icrs)
14328 End Subroutine r_unista
14330 Subroutine i_unista (XDONT, NUNI)
14337 Integer(kind = i4),
Dimension (:),
Intent (InOut) :: XDONT
14338 Integer(kind = i4),
Intent (Out) :: NUNI
14341 Integer(kind = i4),
Dimension (Size(XDONT)) :: IWRKT
14342 Logical,
Dimension (Size(XDONT)) :: IFMPTYT
14343 Integer(kind = i4) :: ICRS
14345 Call uniinv (xdont, iwrkt)
14348 Do icrs = 1,
Size(xdont)
14349 If (ifmptyt(iwrkt(icrs)))
Then
14350 ifmptyt(iwrkt(icrs)) = .false.
14352 xdont(nuni) = xdont(icrs)
14357 End Subroutine i_unista
14359 Recursive Function d_valmed (XDONT)
Result (res_med)
14369 real(kind =
dp),
Dimension (:),
Intent (In) :: xdont
14370 real(kind =
dp) :: res_med
14372 real(kind =
dp),
Parameter :: xhuge = huge(xdont)
14373 real(kind =
dp),
Dimension (SIZE(XDONT) + 6) :: xwrkt
14374 real(kind =
dp) :: xwrk, xwrk1, xmed7
14376 Integer(kind = i4),
Dimension ((SIZE(XDONT) + 6) / 7) :: ISTRT, IENDT, IMEDT
14377 Integer(kind = i4) :: NDON, NTRI, NMED, NORD, NEQU, NLEQ, IMED, IDON, IDON1
14378 Integer(kind = i4) :: IDEB, IWRK, IDCR, ICRS, ICRS1, ICRS2, IMED1
14380 ndon =
SIZE (xdont)
14381 nmed = (ndon + 1) / 2
14386 If (ndon < 35)
Then
14391 If (xdont(1) < xdont(ndon))
Then
14393 xwrkt(idcr) = xdont(idcr)
14396 xwrkt(idcr) = xdont(1)
14398 Do iwrk = 1, ndon - 2
14400 xwrk1 = xdont(idcr)
14401 If (xwrk1 < xwrk)
Then
14405 xwrkt(idcr) = xwrk1
14416 If (xwrk >= xwrkt(idcr))
Exit
14417 xwrkt(idcr + 1) = xwrkt(idcr)
14420 xwrkt(idcr + 1) = xwrk
14425 Do icrs = nmed + 1, ndon
14427 If (xwrk < xwrkt(nmed))
Then
14430 If (xwrk >= xwrkt(idcr))
Exit
14431 xwrkt(idcr + 1) = xwrkt(idcr)
14434 xwrkt(idcr + 1) = xwrk
14437 res_med = xwrkt(nmed)
14447 DO ideb = 1, ndon - 6, 7
14449 If (xdont(ideb) < xdont(idcr))
Then
14451 xwrkt(idcr) = xdont(idcr)
14454 xwrkt(idcr) = xdont(ideb)
14458 xwrk1 = xdont(idcr)
14459 If (xwrk1 < xwrk)
Then
14463 xwrkt(idcr) = xwrk1
14467 Do icrs = ideb + 2, ideb + 6
14469 If (xwrk < xwrkt(icrs - 1))
Then
14470 xwrkt(icrs) = xwrkt(icrs - 1)
14472 xwrk1 = xwrkt(idcr - 1)
14474 If (xwrk >= xwrk1)
Exit
14475 xwrkt(idcr) = xwrk1
14477 xwrk1 = xwrkt(idcr - 1)
14487 ideb = 7 * (ndon / 7)
14489 If (ideb < ndon)
Then
14492 Do icrs = ideb + 1, ideb + 7
14493 If (icrs <= ndon)
Then
14494 xwrkt(icrs) = xdont(icrs)
14496 If (
ne(xwrk1, xhuge)) nmed = nmed + 1
14497 xwrkt(icrs) = xwrk1
14502 Do icrs = ideb + 2, ideb + 7
14504 Do idcr = icrs - 1, ideb + 1, - 1
14505 If (xwrk >= xwrkt(idcr))
Exit
14506 xwrkt(idcr + 1) = xwrkt(idcr)
14508 xwrkt(idcr + 1) = xwrk
14517 Do idon = 1, ntri, 7
14519 imedt(idon1) = idon + 3
14524 xmed7 = d_valmed(xwrkt(imedt))
14538 Do idon = 1, ntri, 7
14540 If (xwrkt(imed) > xmed7)
Then
14542 If (xwrkt(imed) > xmed7)
Then
14544 Else If (xwrkt(imed) < xmed7)
Then
14547 Else If (xwrkt(imed) < xmed7)
Then
14549 If (xwrkt(imed) > xmed7)
Then
14551 Else If (xwrkt(imed) < xmed7)
Then
14555 If (xwrkt(imed) > xmed7)
Then
14556 nleq = nleq + imed - idon
14557 iendt(idon1) = imed - 1
14558 istrt(idon1) = imed
14559 Else If (xwrkt(imed) < xmed7)
Then
14560 nleq = nleq + imed - idon + 1
14561 iendt(idon1) = imed
14562 istrt(idon1) = imed + 1
14564 nleq = nleq + imed - idon + 1
14566 iendt(idon1) = imed - 1
14567 Do imed1 = imed - 1, idon, -1
14568 If (
eq(xwrkt(imed1), xmed7))
Then
14570 iendt(idon1) = imed1 - 1
14575 istrt(idon1) = imed + 1
14576 Do imed1 = imed + 1, idon + 6
14577 If (
eq(xwrkt(imed1), xmed7))
Then
14580 istrt(idon1) = imed1 + 1
14593 If (nleq - nequ + 1 <= nmed)
Then
14594 If (nleq < nmed)
Then
14601 Do idon = 1, ntri, 7
14603 If (icrs2 < nord)
Then
14604 Do icrs = istrt(idon1), idon + 6
14605 If (xwrkt(icrs) < xwrk1)
Then
14607 Do idcr = icrs1 - 1, 1, - 1
14608 If (xwrk >= xwrkt(idcr))
Exit
14609 xwrkt(idcr + 1) = xwrkt(idcr)
14611 xwrkt(idcr + 1) = xwrk
14612 xwrk1 = xwrkt(icrs1)
14614 If (icrs2 < nord)
Then
14615 xwrkt(icrs1) = xwrkt(icrs)
14616 xwrk1 = xwrkt(icrs1)
14619 icrs1 = min(nord, icrs1 + 1)
14620 icrs2 = min(nord, icrs2 + 1)
14623 Do icrs = istrt(idon1), idon + 6
14624 If (xwrkt(icrs) >= xwrk1)
Exit
14626 Do idcr = icrs1 - 1, 1, - 1
14627 If (xwrk >= xwrkt(idcr))
Exit
14628 xwrkt(idcr + 1) = xwrkt(idcr)
14630 xwrkt(idcr + 1) = xwrk
14631 xwrk1 = xwrkt(icrs1)
14644 nord = nleq - nequ - nmed + 1
14648 Do idon = 1, ntri, 7
14650 If (icrs2 < nord)
Then
14652 Do icrs = idon, iendt(idon1)
14653 If (xwrkt(icrs) > xwrk1)
Then
14656 Do idcr = icrs1 - 1, 1, - 1
14657 If (xwrk <= xwrkt(idcr))
Exit
14658 xwrkt(idcr + 1) = xwrkt(idcr)
14660 xwrkt(idcr + 1) = xwrk
14661 xwrk1 = xwrkt(icrs1)
14663 If (icrs2 < nord)
Then
14664 xwrkt(icrs1) = xwrkt(icrs)
14665 xwrk1 = xwrkt(icrs1)
14668 icrs1 = min(nord, icrs1 + 1)
14669 icrs2 = min(nord, icrs2 + 1)
14672 Do icrs = iendt(idon1), idon, -1
14673 If (xwrkt(icrs) > xwrk1)
Then
14676 Do idcr = icrs1 - 1, 1, - 1
14677 If (xwrk <= xwrkt(idcr))
Exit
14678 xwrkt(idcr + 1) = xwrkt(idcr)
14680 xwrkt(idcr + 1) = xwrk
14681 xwrk1 = xwrkt(icrs1)
14693 End Function d_valmed
14695 Recursive Function r_valmed (XDONT)
Result (res_med)
14705 Real(kind =
sp),
Dimension (:),
Intent (In) :: xdont
14706 Real(kind =
sp) :: res_med
14708 Real(kind =
sp),
Parameter :: xhuge = huge(xdont)
14709 Real(kind =
sp),
Dimension (SIZE(XDONT) + 6) :: xwrkt
14710 Real(kind =
sp) :: xwrk, xwrk1, xmed7
14712 Integer(kind = i4),
Dimension ((SIZE(XDONT) + 6) / 7) :: ISTRT, IENDT, IMEDT
14713 Integer(kind = i4) :: NDON, NTRI, NMED, NORD, NEQU, NLEQ, IMED, IDON, IDON1
14714 Integer(kind = i4) :: IDEB, IWRK, IDCR, ICRS, ICRS1, ICRS2, IMED1
14716 ndon =
SIZE (xdont)
14717 nmed = (ndon + 1) / 2
14722 If (ndon < 35)
Then
14727 If (xdont(1) < xdont(ndon))
Then
14729 xwrkt(idcr) = xdont(idcr)
14732 xwrkt(idcr) = xdont(1)
14734 Do iwrk = 1, ndon - 2
14736 xwrk1 = xdont(idcr)
14737 If (xwrk1 < xwrk)
Then
14741 xwrkt(idcr) = xwrk1
14752 If (xwrk >= xwrkt(idcr))
Exit
14753 xwrkt(idcr + 1) = xwrkt(idcr)
14756 xwrkt(idcr + 1) = xwrk
14761 Do icrs = nmed + 1, ndon
14763 If (xwrk < xwrkt(nmed))
Then
14766 If (xwrk >= xwrkt(idcr))
Exit
14767 xwrkt(idcr + 1) = xwrkt(idcr)
14770 xwrkt(idcr + 1) = xwrk
14773 res_med = xwrkt(nmed)
14783 DO ideb = 1, ndon - 6, 7
14785 If (xdont(ideb) < xdont(idcr))
Then
14787 xwrkt(idcr) = xdont(idcr)
14790 xwrkt(idcr) = xdont(ideb)
14794 xwrk1 = xdont(idcr)
14795 If (xwrk1 < xwrk)
Then
14799 xwrkt(idcr) = xwrk1
14803 Do icrs = ideb + 2, ideb + 6
14805 If (xwrk < xwrkt(icrs - 1))
Then
14806 xwrkt(icrs) = xwrkt(icrs - 1)
14808 xwrk1 = xwrkt(idcr - 1)
14810 If (xwrk >= xwrk1)
Exit
14811 xwrkt(idcr) = xwrk1
14813 xwrk1 = xwrkt(idcr - 1)
14823 ideb = 7 * (ndon / 7)
14825 If (ideb < ndon)
Then
14828 Do icrs = ideb + 1, ideb + 7
14829 If (icrs <= ndon)
Then
14830 xwrkt(icrs) = xdont(icrs)
14832 If (
ne(xwrk1, xhuge)) nmed = nmed + 1
14833 xwrkt(icrs) = xwrk1
14838 Do icrs = ideb + 2, ideb + 7
14840 Do idcr = icrs - 1, ideb + 1, - 1
14841 If (xwrk >= xwrkt(idcr))
Exit
14842 xwrkt(idcr + 1) = xwrkt(idcr)
14844 xwrkt(idcr + 1) = xwrk
14853 Do idon = 1, ntri, 7
14855 imedt(idon1) = idon + 3
14860 xmed7 = r_valmed(xwrkt(imedt))
14874 Do idon = 1, ntri, 7
14876 If (xwrkt(imed) > xmed7)
Then
14878 If (xwrkt(imed) > xmed7)
Then
14880 Else If (xwrkt(imed) < xmed7)
Then
14883 Else If (xwrkt(imed) < xmed7)
Then
14885 If (xwrkt(imed) > xmed7)
Then
14887 Else If (xwrkt(imed) < xmed7)
Then
14891 If (xwrkt(imed) > xmed7)
Then
14892 nleq = nleq + imed - idon
14893 iendt(idon1) = imed - 1
14894 istrt(idon1) = imed
14895 Else If (xwrkt(imed) < xmed7)
Then
14896 nleq = nleq + imed - idon + 1
14897 iendt(idon1) = imed
14898 istrt(idon1) = imed + 1
14900 nleq = nleq + imed - idon + 1
14902 iendt(idon1) = imed - 1
14903 Do imed1 = imed - 1, idon, -1
14904 If (
eq(xwrkt(imed1), xmed7))
Then
14906 iendt(idon1) = imed1 - 1
14911 istrt(idon1) = imed + 1
14912 Do imed1 = imed + 1, idon + 6
14913 If (
eq(xwrkt(imed1), xmed7))
Then
14916 istrt(idon1) = imed1 + 1
14929 If (nleq - nequ + 1 <= nmed)
Then
14930 If (nleq < nmed)
Then
14937 Do idon = 1, ntri, 7
14939 If (icrs2 < nord)
Then
14940 Do icrs = istrt(idon1), idon + 6
14941 If (xwrkt(icrs) < xwrk1)
Then
14943 Do idcr = icrs1 - 1, 1, - 1
14944 If (xwrk >= xwrkt(idcr))
Exit
14945 xwrkt(idcr + 1) = xwrkt(idcr)
14947 xwrkt(idcr + 1) = xwrk
14948 xwrk1 = xwrkt(icrs1)
14950 If (icrs2 < nord)
Then
14951 xwrkt(icrs1) = xwrkt(icrs)
14952 xwrk1 = xwrkt(icrs1)
14955 icrs1 = min(nord, icrs1 + 1)
14956 icrs2 = min(nord, icrs2 + 1)
14959 Do icrs = istrt(idon1), idon + 6
14960 If (xwrkt(icrs) >= xwrk1)
Exit
14962 Do idcr = icrs1 - 1, 1, - 1
14963 If (xwrk >= xwrkt(idcr))
Exit
14964 xwrkt(idcr + 1) = xwrkt(idcr)
14966 xwrkt(idcr + 1) = xwrk
14967 xwrk1 = xwrkt(icrs1)
14980 nord = nleq - nequ - nmed + 1
14984 Do idon = 1, ntri, 7
14986 If (icrs2 < nord)
Then
14988 Do icrs = idon, iendt(idon1)
14989 If (xwrkt(icrs) > xwrk1)
Then
14992 Do idcr = icrs1 - 1, 1, - 1
14993 If (xwrk <= xwrkt(idcr))
Exit
14994 xwrkt(idcr + 1) = xwrkt(idcr)
14996 xwrkt(idcr + 1) = xwrk
14997 xwrk1 = xwrkt(icrs1)
14999 If (icrs2 < nord)
Then
15000 xwrkt(icrs1) = xwrkt(icrs)
15001 xwrk1 = xwrkt(icrs1)
15004 icrs1 = min(nord, icrs1 + 1)
15005 icrs2 = min(nord, icrs2 + 1)
15008 Do icrs = iendt(idon1), idon, -1
15009 If (xwrkt(icrs) > xwrk1)
Then
15012 Do idcr = icrs1 - 1, 1, - 1
15013 If (xwrk <= xwrkt(idcr))
Exit
15014 xwrkt(idcr + 1) = xwrkt(idcr)
15016 xwrkt(idcr + 1) = xwrk
15017 xwrk1 = xwrkt(icrs1)
15029 End Function r_valmed
15031 Recursive Function i_valmed (XDONT)
Result (res_med)
15041 Integer(kind = i4),
Dimension (:),
Intent (In) :: XDONT
15042 Integer(kind = i4) :: res_med
15044 Integer(kind = i4),
Parameter :: XHUGE = huge (xdont)
15045 Integer(kind = i4),
Dimension (SIZE(XDONT) + 6) :: XWRKT
15046 Integer(kind = i4) :: XWRK, XWRK1, XMED7
15048 Integer(kind = i4),
Dimension ((SIZE(XDONT) + 6) / 7) :: ISTRT, IENDT, IMEDT
15049 Integer(kind = i4) :: NDON, NTRI, NMED, NORD, NEQU, NLEQ, IMED, IDON, IDON1
15050 Integer(kind = i4) :: IDEB, IWRK, IDCR, ICRS, ICRS1, ICRS2, IMED1
15052 ndon =
SIZE (xdont)
15053 nmed = (ndon + 1) / 2
15058 If (ndon < 35)
Then
15063 If (xdont(1) < xdont(ndon))
Then
15065 xwrkt(idcr) = xdont(idcr)
15068 xwrkt(idcr) = xdont(1)
15070 Do iwrk = 1, ndon - 2
15072 xwrk1 = xdont(idcr)
15073 If (xwrk1 < xwrk)
Then
15077 xwrkt(idcr) = xwrk1
15088 If (xwrk >= xwrkt(idcr))
Exit
15089 xwrkt(idcr + 1) = xwrkt(idcr)
15092 xwrkt(idcr + 1) = xwrk
15097 Do icrs = nmed + 1, ndon
15099 If (xwrk < xwrkt(nmed))
Then
15102 If (xwrk >= xwrkt(idcr))
Exit
15103 xwrkt(idcr + 1) = xwrkt(idcr)
15106 xwrkt(idcr + 1) = xwrk
15109 res_med = xwrkt(nmed)
15119 DO ideb = 1, ndon - 6, 7
15121 If (xdont(ideb) < xdont(idcr))
Then
15123 xwrkt(idcr) = xdont(idcr)
15126 xwrkt(idcr) = xdont(ideb)
15130 xwrk1 = xdont(idcr)
15131 If (xwrk1 < xwrk)
Then
15135 xwrkt(idcr) = xwrk1
15139 Do icrs = ideb + 2, ideb + 6
15141 If (xwrk < xwrkt(icrs - 1))
Then
15142 xwrkt(icrs) = xwrkt(icrs - 1)
15144 xwrk1 = xwrkt(idcr - 1)
15146 If (xwrk >= xwrk1)
Exit
15147 xwrkt(idcr) = xwrk1
15149 xwrk1 = xwrkt(idcr - 1)
15159 ideb = 7 * (ndon / 7)
15161 If (ideb < ndon)
Then
15164 Do icrs = ideb + 1, ideb + 7
15165 If (icrs <= ndon)
Then
15166 xwrkt(icrs) = xdont(icrs)
15168 If (xwrk1 /= xhuge) nmed = nmed + 1
15169 xwrkt(icrs) = xwrk1
15174 Do icrs = ideb + 2, ideb + 7
15176 Do idcr = icrs - 1, ideb + 1, - 1
15177 If (xwrk >= xwrkt(idcr))
Exit
15178 xwrkt(idcr + 1) = xwrkt(idcr)
15180 xwrkt(idcr + 1) = xwrk
15189 Do idon = 1, ntri, 7
15191 imedt(idon1) = idon + 3
15196 xmed7 = i_valmed(xwrkt(imedt))
15210 Do idon = 1, ntri, 7
15212 If (xwrkt(imed) > xmed7)
Then
15214 If (xwrkt(imed) > xmed7)
Then
15216 Else If (xwrkt(imed) < xmed7)
Then
15219 Else If (xwrkt(imed) < xmed7)
Then
15221 If (xwrkt(imed) > xmed7)
Then
15223 Else If (xwrkt(imed) < xmed7)
Then
15227 If (xwrkt(imed) > xmed7)
Then
15228 nleq = nleq + imed - idon
15229 iendt(idon1) = imed - 1
15230 istrt(idon1) = imed
15231 Else If (xwrkt(imed) < xmed7)
Then
15232 nleq = nleq + imed - idon + 1
15233 iendt(idon1) = imed
15234 istrt(idon1) = imed + 1
15236 nleq = nleq + imed - idon + 1
15238 iendt(idon1) = imed - 1
15239 Do imed1 = imed - 1, idon, -1
15240 If (xwrkt(imed1) == xmed7)
Then
15242 iendt(idon1) = imed1 - 1
15247 istrt(idon1) = imed + 1
15248 Do imed1 = imed + 1, idon + 6
15249 If (xwrkt(imed1) == xmed7)
Then
15252 istrt(idon1) = imed1 + 1
15265 If (nleq - nequ + 1 <= nmed)
Then
15266 If (nleq < nmed)
Then
15273 Do idon = 1, ntri, 7
15275 If (icrs2 < nord)
Then
15276 Do icrs = istrt(idon1), idon + 6
15277 If (xwrkt(icrs) < xwrk1)
Then
15279 Do idcr = icrs1 - 1, 1, - 1
15280 If (xwrk >= xwrkt(idcr))
Exit
15281 xwrkt(idcr + 1) = xwrkt(idcr)
15283 xwrkt(idcr + 1) = xwrk
15284 xwrk1 = xwrkt(icrs1)
15286 If (icrs2 < nord)
Then
15287 xwrkt(icrs1) = xwrkt(icrs)
15288 xwrk1 = xwrkt(icrs1)
15291 icrs1 = min(nord, icrs1 + 1)
15292 icrs2 = min(nord, icrs2 + 1)
15295 Do icrs = istrt(idon1), idon + 6
15296 If (xwrkt(icrs) >= xwrk1)
Exit
15298 Do idcr = icrs1 - 1, 1, - 1
15299 If (xwrk >= xwrkt(idcr))
Exit
15300 xwrkt(idcr + 1) = xwrkt(idcr)
15302 xwrkt(idcr + 1) = xwrk
15303 xwrk1 = xwrkt(icrs1)
15316 nord = nleq - nequ - nmed + 1
15320 Do idon = 1, ntri, 7
15322 If (icrs2 < nord)
Then
15324 Do icrs = idon, iendt(idon1)
15325 If (xwrkt(icrs) > xwrk1)
Then
15328 Do idcr = icrs1 - 1, 1, - 1
15329 If (xwrk <= xwrkt(idcr))
Exit
15330 xwrkt(idcr + 1) = xwrkt(idcr)
15332 xwrkt(idcr + 1) = xwrk
15333 xwrk1 = xwrkt(icrs1)
15335 If (icrs2 < nord)
Then
15336 xwrkt(icrs1) = xwrkt(icrs)
15337 xwrk1 = xwrkt(icrs1)
15340 icrs1 = min(nord, icrs1 + 1)
15341 icrs2 = min(nord, icrs2 + 1)
15344 Do icrs = iendt(idon1), idon, -1
15345 If (xwrkt(icrs) > xwrk1)
Then
15348 Do idcr = icrs1 - 1, 1, - 1
15349 If (xwrk <= xwrkt(idcr))
Exit
15350 xwrkt(idcr + 1) = xwrkt(idcr)
15352 xwrkt(idcr + 1) = xwrk
15353 xwrk1 = xwrkt(icrs1)
15365 End Function i_valmed
15367 Function d_valnth (XDONT, NORD)
Result (valnth)
15382 real(Kind =
dp),
Dimension (:),
Intent (In) :: xdont
15384 Integer(kind = i4),
Intent (In) :: NORD
15386 real(Kind =
dp),
Dimension (SIZE(XDONT)) :: xlowt, xhigt
15387 real(Kind =
dp) :: xpiv, xwrk, xwrk1, xwrk2, xwrk3, xmin, xmax
15389 Integer(kind = i4) :: NDON, JHIG, JLOW, IHIG
15390 Integer(kind = i4) :: IMIL, IFIN, ICRS, IDCR, ILOW
15391 Integer(kind = i4) :: JLM2, JLM1, JHM2, JHM1, INTH
15393 ndon =
SIZE (xdont)
15394 inth = max(min(nord, ndon), 1)
15399 If (inth == 1)
valnth = xdont(1)
15406 If (xdont(2) < xdont(1))
Then
15407 xlowt(1) = xdont(2)
15408 xhigt(1) = xdont(1)
15410 xlowt(1) = xdont(1)
15411 xhigt(1) = xdont(2)
15415 If (inth == 1)
valnth = xlowt(1)
15416 If (inth == 2)
valnth = xhigt(1)
15420 If (xdont(3) < xhigt(1))
Then
15421 xhigt(2) = xhigt(1)
15422 If (xdont(3) < xlowt(1))
Then
15423 xhigt(1) = xlowt(1)
15424 xlowt(1) = xdont(3)
15426 xhigt(1) = xdont(3)
15429 xhigt(2) = xdont(3)
15433 If (inth == 1)
Then
15436 valnth = xhigt(inth - 1)
15441 If (xdont(ndon) < xhigt(1))
Then
15442 xhigt(3) = xhigt(2)
15443 xhigt(2) = xhigt(1)
15444 If (xdont(ndon) < xlowt(1))
Then
15445 xhigt(1) = xlowt(1)
15446 xlowt(1) = xdont(ndon)
15448 xhigt(1) = xdont(ndon)
15451 xhigt(3) = xdont(ndon)
15455 If (inth == 1)
Then
15458 valnth = xhigt(inth - 1)
15466 xpiv = xlowt(1) + real(2 * inth,
dp) / real(ndon + inth,
dp) * (xhigt(3) - xlowt(1))
15467 If (xpiv >= xhigt(1))
Then
15468 xpiv = xlowt(1) + real(2 * inth,
dp) / real(ndon + inth,
dp) * &
15469 (xhigt(2) - xlowt(1))
15470 If (xpiv >= xhigt(1)) &
15471 xpiv = xlowt(1) + real(2 * inth,
dp) / real(ndon + inth,
dp) * &
15472 (xhigt(1) - xlowt(1))
15483 If (xdont(ndon) > xpiv)
Then
15487 If (xdont(icrs) > xpiv)
Then
15488 If (icrs >= ndon)
Exit
15490 xhigt(jhig) = xdont(icrs)
15493 xlowt(jlow) = xdont(icrs)
15494 If (jlow >= inth)
Exit
15501 If (icrs < ndon - 1)
Then
15504 If (xdont(icrs) <= xpiv)
Then
15506 xlowt(jlow) = xdont(icrs)
15507 Else If (icrs >= ndon)
Then
15519 Do icrs = 4, ndon - 1
15520 If (xdont(icrs) > xpiv)
Then
15522 xhigt(jhig) = xdont(icrs)
15525 xlowt(jlow) = xdont(icrs)
15526 If (jlow >= inth)
Exit
15530 If (icrs < ndon - 1)
Then
15533 If (xdont(icrs) <= xpiv)
Then
15534 If (icrs >= ndon)
Exit
15536 xlowt(jlow) = xdont(icrs)
15547 If (jlm2 == jlow .And. jhm2 == jhig)
Then
15552 If (inth > jlow)
Then
15556 If (xhigt(icrs) < xmin)
Then
15563 xlowt(jlow) = xhigt(ihig)
15564 xhigt(ihig) = xhigt(jhig)
15571 If (xlowt(icrs) > xmax)
Then
15587 Select Case (inth - jlow)
15604 If (xhigt(1) <= xhigt(2))
Then
15606 xlowt(jlow) = xhigt(1)
15608 xlowt(jlow) = xhigt(2)
15611 xlowt(jlow) = xhigt(2)
15613 xlowt(jlow) = xhigt(1)
15623 If (xwrk2 < xwrk1)
Then
15628 If (xwrk2 > xwrk3)
Then
15632 If (xwrk2 < xhigt(1))
Then
15633 xhigt(2) = xhigt(1)
15638 Do icrs = jlow + 1, inth
15640 xlowt(icrs) = xhigt(jhig)
15656 xwrk3 = xhigt(ifin)
15657 If (xwrk2 < xwrk1)
Then
15662 If (xwrk2 > xwrk3)
Then
15663 xhigt(ifin) = xwrk2
15666 If (xwrk2 < xhigt(1))
Then
15667 xhigt(2) = xhigt(1)
15674 xlowt(jlow) = xwrk1
15675 xpiv = xwrk1 + 0.5 * (xhigt(ifin) - xwrk1)
15685 If (xhigt(icrs) <= xpiv)
Then
15687 xlowt(jlow) = xhigt(icrs)
15688 If (jlow >= inth)
Exit
15691 xhigt(jhig) = xhigt(icrs)
15695 Do icrs = icrs + 1, ifin
15696 If (xhigt(icrs) <= xpiv)
Then
15698 xlowt(jlow) = xhigt(icrs)
15711 If (xhigt(icrs) < xmin)
Then
15732 xhigt(1) = xlowt(1)
15733 ilow = 1 + inth - jlow
15736 Do idcr = icrs - 1, max(1, ilow), - 1
15737 If (xwrk < xhigt(idcr))
Then
15738 xhigt(idcr + 1) = xhigt(idcr)
15743 xhigt(idcr + 1) = xwrk
15747 xwrk1 = xhigt(inth)
15748 ilow = 2 * inth - jlow
15749 Do icrs = inth + 1, jlow
15750 If (xlowt(icrs) < xwrk1)
Then
15752 Do idcr = inth - 1, max(1, ilow), - 1
15753 If (xwrk >= xhigt(idcr))
Exit
15754 xhigt(idcr + 1) = xhigt(idcr)
15756 xhigt(idcr + 1) = xlowt(icrs)
15757 xwrk1 = xhigt(inth)
15771 imil = (jlow + 1) / 2
15776 If (xlowt(imil) < xlowt(1))
Then
15778 xlowt(1) = xlowt(imil)
15781 If (xlowt(imil) > xlowt(ifin))
Then
15783 xlowt(ifin) = xlowt(imil)
15785 If (xlowt(imil) < xlowt(1))
Then
15787 xlowt(1) = xlowt(imil)
15791 If (ifin <= 3)
Exit
15793 xpiv = xlowt(1) + real(inth,
dp) / real(jlow + inth,
dp) * &
15794 (xlowt(ifin) - xlowt(1))
15802 If (xlowt(ifin) > xpiv)
Then
15806 If (xlowt(icrs) > xpiv)
Then
15808 xhigt(jhig) = xlowt(icrs)
15809 If (icrs >= ifin)
Exit
15812 xlowt(jlow) = xlowt(icrs)
15813 If (jlow >= inth)
Exit
15817 If (icrs < ifin)
Then
15820 If (xlowt(icrs) <= xpiv)
Then
15822 xlowt(jlow) = xlowt(icrs)
15824 If (icrs >= ifin)
Exit
15830 If (xlowt(icrs) > xpiv)
Then
15832 xhigt(jhig) = xlowt(icrs)
15835 xlowt(jlow) = xlowt(icrs)
15836 If (jlow >= inth)
Exit
15840 Do icrs = icrs + 1, ifin
15841 If (xlowt(icrs) <= xpiv)
Then
15843 xlowt(jlow) = xlowt(icrs)
15854 valnth = maxval(xlowt(1 : inth))
15858 End Function d_valnth
15860 Function r_valnth (XDONT, NORD)
Result (valnth)
15875 Real(kind =
sp),
Dimension (:),
Intent (In) :: xdont
15877 Integer(kind = i4),
Intent (In) :: NORD
15879 Real(kind =
sp),
Dimension (SIZE(XDONT)) :: xlowt, xhigt
15880 Real(kind =
sp) :: xpiv, xwrk, xwrk1, xwrk2, xwrk3, xmin, xmax
15882 Integer(kind = i4) :: NDON, JHIG, JLOW, IHIG
15883 Integer(kind = i4) :: IMIL, IFIN, ICRS, IDCR, ILOW
15884 Integer(kind = i4) :: JLM2, JLM1, JHM2, JHM1, INTH
15886 ndon =
SIZE (xdont)
15887 inth = max(min(nord, ndon), 1)
15892 If (inth == 1)
valnth = xdont(1)
15899 If (xdont(2) < xdont(1))
Then
15900 xlowt(1) = xdont(2)
15901 xhigt(1) = xdont(1)
15903 xlowt(1) = xdont(1)
15904 xhigt(1) = xdont(2)
15908 If (inth == 1)
valnth = xlowt(1)
15909 If (inth == 2)
valnth = xhigt(1)
15913 If (xdont(3) < xhigt(1))
Then
15914 xhigt(2) = xhigt(1)
15915 If (xdont(3) < xlowt(1))
Then
15916 xhigt(1) = xlowt(1)
15917 xlowt(1) = xdont(3)
15919 xhigt(1) = xdont(3)
15922 xhigt(2) = xdont(3)
15926 If (inth == 1)
Then
15929 valnth = xhigt(inth - 1)
15934 If (xdont(ndon) < xhigt(1))
Then
15935 xhigt(3) = xhigt(2)
15936 xhigt(2) = xhigt(1)
15937 If (xdont(ndon) < xlowt(1))
Then
15938 xhigt(1) = xlowt(1)
15939 xlowt(1) = xdont(ndon)
15941 xhigt(1) = xdont(ndon)
15944 xhigt(3) = xdont(ndon)
15948 If (inth == 1)
Then
15951 valnth = xhigt(inth - 1)
15959 xpiv = xlowt(1) + real(2 * inth,
sp) / real(ndon + inth,
sp) * (xhigt(3) - xlowt(1))
15960 If (xpiv >= xhigt(1))
Then
15961 xpiv = xlowt(1) + real(2 * inth,
sp) / real(ndon + inth,
sp) * &
15962 (xhigt(2) - xlowt(1))
15963 If (xpiv >= xhigt(1)) &
15964 xpiv = xlowt(1) + real(2 * inth,
sp) / real(ndon + inth,
sp) * &
15965 (xhigt(1) - xlowt(1))
15976 If (xdont(ndon) > xpiv)
Then
15980 If (xdont(icrs) > xpiv)
Then
15981 If (icrs >= ndon)
Exit
15983 xhigt(jhig) = xdont(icrs)
15986 xlowt(jlow) = xdont(icrs)
15987 If (jlow >= inth)
Exit
15994 If (icrs < ndon - 1)
Then
15997 If (xdont(icrs) <= xpiv)
Then
15999 xlowt(jlow) = xdont(icrs)
16000 Else If (icrs >= ndon)
Then
16012 Do icrs = 4, ndon - 1
16013 If (xdont(icrs) > xpiv)
Then
16015 xhigt(jhig) = xdont(icrs)
16018 xlowt(jlow) = xdont(icrs)
16019 If (jlow >= inth)
Exit
16023 If (icrs < ndon - 1)
Then
16026 If (xdont(icrs) <= xpiv)
Then
16027 If (icrs >= ndon)
Exit
16029 xlowt(jlow) = xdont(icrs)
16040 If (jlm2 == jlow .And. jhm2 == jhig)
Then
16045 If (inth > jlow)
Then
16049 If (xhigt(icrs) < xmin)
Then
16056 xlowt(jlow) = xhigt(ihig)
16057 xhigt(ihig) = xhigt(jhig)
16064 If (xlowt(icrs) > xmax)
Then
16080 Select Case (inth - jlow)
16097 If (xhigt(1) <= xhigt(2))
Then
16099 xlowt(jlow) = xhigt(1)
16101 xlowt(jlow) = xhigt(2)
16104 xlowt(jlow) = xhigt(2)
16106 xlowt(jlow) = xhigt(1)
16116 If (xwrk2 < xwrk1)
Then
16121 If (xwrk2 > xwrk3)
Then
16125 If (xwrk2 < xhigt(1))
Then
16126 xhigt(2) = xhigt(1)
16131 Do icrs = jlow + 1, inth
16133 xlowt(icrs) = xhigt(jhig)
16149 xwrk3 = xhigt(ifin)
16150 If (xwrk2 < xwrk1)
Then
16155 If (xwrk2 > xwrk3)
Then
16156 xhigt(ifin) = xwrk2
16159 If (xwrk2 < xhigt(1))
Then
16160 xhigt(2) = xhigt(1)
16167 xlowt(jlow) = xwrk1
16168 xpiv = xwrk1 + 0.5 * (xhigt(ifin) - xwrk1)
16178 If (xhigt(icrs) <= xpiv)
Then
16180 xlowt(jlow) = xhigt(icrs)
16181 If (jlow >= inth)
Exit
16184 xhigt(jhig) = xhigt(icrs)
16188 Do icrs = icrs + 1, ifin
16189 If (xhigt(icrs) <= xpiv)
Then
16191 xlowt(jlow) = xhigt(icrs)
16204 If (xhigt(icrs) < xmin)
Then
16225 xhigt(1) = xlowt(1)
16226 ilow = 1 + inth - jlow
16229 Do idcr = icrs - 1, max(1, ilow), - 1
16230 If (xwrk < xhigt(idcr))
Then
16231 xhigt(idcr + 1) = xhigt(idcr)
16236 xhigt(idcr + 1) = xwrk
16240 xwrk1 = xhigt(inth)
16241 ilow = 2 * inth - jlow
16242 Do icrs = inth + 1, jlow
16243 If (xlowt(icrs) < xwrk1)
Then
16245 Do idcr = inth - 1, max(1, ilow), - 1
16246 If (xwrk >= xhigt(idcr))
Exit
16247 xhigt(idcr + 1) = xhigt(idcr)
16249 xhigt(idcr + 1) = xlowt(icrs)
16250 xwrk1 = xhigt(inth)
16264 imil = (jlow + 1) / 2
16269 If (xlowt(imil) < xlowt(1))
Then
16271 xlowt(1) = xlowt(imil)
16274 If (xlowt(imil) > xlowt(ifin))
Then
16276 xlowt(ifin) = xlowt(imil)
16278 If (xlowt(imil) < xlowt(1))
Then
16280 xlowt(1) = xlowt(imil)
16284 If (ifin <= 3)
Exit
16286 xpiv = xlowt(1) + real(inth,
sp) / real(jlow + inth,
sp) * &
16287 (xlowt(ifin) - xlowt(1))
16295 If (xlowt(ifin) > xpiv)
Then
16299 If (xlowt(icrs) > xpiv)
Then
16301 xhigt(jhig) = xlowt(icrs)
16302 If (icrs >= ifin)
Exit
16305 xlowt(jlow) = xlowt(icrs)
16306 If (jlow >= inth)
Exit
16310 If (icrs < ifin)
Then
16313 If (xlowt(icrs) <= xpiv)
Then
16315 xlowt(jlow) = xlowt(icrs)
16317 If (icrs >= ifin)
Exit
16323 If (xlowt(icrs) > xpiv)
Then
16325 xhigt(jhig) = xlowt(icrs)
16328 xlowt(jlow) = xlowt(icrs)
16329 If (jlow >= inth)
Exit
16333 Do icrs = icrs + 1, ifin
16334 If (xlowt(icrs) <= xpiv)
Then
16336 xlowt(jlow) = xlowt(icrs)
16347 valnth = maxval(xlowt(1 : inth))
16351 End Function r_valnth
16353 Function i_valnth (XDONT, NORD)
Result (valnth)
16368 Integer(kind = i4),
Dimension (:),
Intent (In) :: XDONT
16369 Integer(kind = i4) :: valnth
16370 Integer(kind = i4),
Intent (In) :: NORD
16372 Integer(kind = i4),
Dimension (SIZE(XDONT)) :: XLOWT, XHIGT
16373 Integer(kind = i4) :: XPIV, XWRK, XWRK1, XWRK2, XWRK3, XMIN, XMAX
16375 Integer(kind = i4) :: NDON, JHIG, JLOW, IHIG
16376 Integer(kind = i4) :: IMIL, IFIN, ICRS, IDCR, ILOW
16377 Integer(kind = i4) :: JLM2, JLM1, JHM2, JHM1, INTH
16379 ndon =
SIZE (xdont)
16380 inth = max(min(nord, ndon), 1)
16385 If (inth == 1)
valnth = xdont(1)
16392 If (xdont(2) < xdont(1))
Then
16393 xlowt(1) = xdont(2)
16394 xhigt(1) = xdont(1)
16396 xlowt(1) = xdont(1)
16397 xhigt(1) = xdont(2)
16401 If (inth == 1)
valnth = xlowt(1)
16402 If (inth == 2)
valnth = xhigt(1)
16406 If (xdont(3) < xhigt(1))
Then
16407 xhigt(2) = xhigt(1)
16408 If (xdont(3) < xlowt(1))
Then
16409 xhigt(1) = xlowt(1)
16410 xlowt(1) = xdont(3)
16412 xhigt(1) = xdont(3)
16415 xhigt(2) = xdont(3)
16419 If (inth == 1)
Then
16422 valnth = xhigt(inth - 1)
16427 If (xdont(ndon) < xhigt(1))
Then
16428 xhigt(3) = xhigt(2)
16429 xhigt(2) = xhigt(1)
16430 If (xdont(ndon) < xlowt(1))
Then
16431 xhigt(1) = xlowt(1)
16432 xlowt(1) = xdont(ndon)
16434 xhigt(1) = xdont(ndon)
16437 xhigt(3) = xdont(ndon)
16441 If (inth == 1)
Then
16444 valnth = xhigt(inth - 1)
16452 xpiv = xlowt(1) + int(real(2 * inth,
sp) / real(ndon + inth,
sp),
i4) * (xhigt(3) - xlowt(1))
16453 If (xpiv >= xhigt(1))
Then
16454 xpiv = xlowt(1) + int(real(2 * inth,
sp) / real(ndon + inth,
sp),
i4) * &
16455 (xhigt(2) - xlowt(1))
16456 If (xpiv >= xhigt(1)) &
16457 xpiv = xlowt(1) + int(real(2 * inth,
sp) / real(ndon + inth,
sp),
i4) * &
16458 (xhigt(1) - xlowt(1))
16469 If (xdont(ndon) > xpiv)
Then
16473 If (xdont(icrs) > xpiv)
Then
16474 If (icrs >= ndon)
Exit
16476 xhigt(jhig) = xdont(icrs)
16479 xlowt(jlow) = xdont(icrs)
16480 If (jlow >= inth)
Exit
16487 If (icrs < ndon - 1)
Then
16490 If (xdont(icrs) <= xpiv)
Then
16492 xlowt(jlow) = xdont(icrs)
16493 Else If (icrs >= ndon)
Then
16505 Do icrs = 4, ndon - 1
16506 If (xdont(icrs) > xpiv)
Then
16508 xhigt(jhig) = xdont(icrs)
16511 xlowt(jlow) = xdont(icrs)
16512 If (jlow >= inth)
Exit
16516 If (icrs < ndon - 1)
Then
16519 If (xdont(icrs) <= xpiv)
Then
16520 If (icrs >= ndon)
Exit
16522 xlowt(jlow) = xdont(icrs)
16533 If (jlm2 == jlow .And. jhm2 == jhig)
Then
16538 If (inth > jlow)
Then
16542 If (xhigt(icrs) < xmin)
Then
16549 xlowt(jlow) = xhigt(ihig)
16550 xhigt(ihig) = xhigt(jhig)
16557 If (xlowt(icrs) > xmax)
Then
16573 Select Case (inth - jlow)
16590 If (xhigt(1) <= xhigt(2))
Then
16592 xlowt(jlow) = xhigt(1)
16594 xlowt(jlow) = xhigt(2)
16597 xlowt(jlow) = xhigt(2)
16599 xlowt(jlow) = xhigt(1)
16609 If (xwrk2 < xwrk1)
Then
16614 If (xwrk2 > xwrk3)
Then
16618 If (xwrk2 < xhigt(1))
Then
16619 xhigt(2) = xhigt(1)
16624 Do icrs = jlow + 1, inth
16626 xlowt(icrs) = xhigt(jhig)
16642 xwrk3 = xhigt(ifin)
16643 If (xwrk2 < xwrk1)
Then
16648 If (xwrk2 > xwrk3)
Then
16649 xhigt(ifin) = xwrk2
16652 If (xwrk2 < xhigt(1))
Then
16653 xhigt(2) = xhigt(1)
16660 xlowt(jlow) = xwrk1
16661 xpiv = xwrk1 + (xhigt(ifin) - xwrk1) / 2
16671 If (xhigt(icrs) <= xpiv)
Then
16673 xlowt(jlow) = xhigt(icrs)
16674 If (jlow >= inth)
Exit
16677 xhigt(jhig) = xhigt(icrs)
16681 Do icrs = icrs + 1, ifin
16682 If (xhigt(icrs) <= xpiv)
Then
16684 xlowt(jlow) = xhigt(icrs)
16697 If (xhigt(icrs) < xmin)
Then
16718 xhigt(1) = xlowt(1)
16719 ilow = 1 + inth - jlow
16722 Do idcr = icrs - 1, max(1, ilow), - 1
16723 If (xwrk < xhigt(idcr))
Then
16724 xhigt(idcr + 1) = xhigt(idcr)
16729 xhigt(idcr + 1) = xwrk
16733 xwrk1 = xhigt(inth)
16734 ilow = 2 * inth - jlow
16735 Do icrs = inth + 1, jlow
16736 If (xlowt(icrs) < xwrk1)
Then
16738 Do idcr = inth - 1, max(1, ilow), - 1
16739 If (xwrk >= xhigt(idcr))
Exit
16740 xhigt(idcr + 1) = xhigt(idcr)
16742 xhigt(idcr + 1) = xlowt(icrs)
16743 xwrk1 = xhigt(inth)
16757 imil = (jlow + 1) / 2
16762 If (xlowt(imil) < xlowt(1))
Then
16764 xlowt(1) = xlowt(imil)
16767 If (xlowt(imil) > xlowt(ifin))
Then
16769 xlowt(ifin) = xlowt(imil)
16771 If (xlowt(imil) < xlowt(1))
Then
16773 xlowt(1) = xlowt(imil)
16777 If (ifin <= 3)
Exit
16779 xpiv = xlowt(1) + int(real(inth,
sp) / real(jlow + inth,
sp),
i4) * &
16780 (xlowt(ifin) - xlowt(1))
16788 If (xlowt(ifin) > xpiv)
Then
16792 If (xlowt(icrs) > xpiv)
Then
16794 xhigt(jhig) = xlowt(icrs)
16795 If (icrs >= ifin)
Exit
16798 xlowt(jlow) = xlowt(icrs)
16799 If (jlow >= inth)
Exit
16803 If (icrs < ifin)
Then
16806 If (xlowt(icrs) <= xpiv)
Then
16808 xlowt(jlow) = xlowt(icrs)
16810 If (icrs >= ifin)
Exit
16816 If (xlowt(icrs) > xpiv)
Then
16818 xhigt(jhig) = xlowt(icrs)
16821 xlowt(jlow) = xlowt(icrs)
16822 If (jlow >= inth)
Exit
16826 Do icrs = icrs + 1, ifin
16827 If (xlowt(icrs) <= xpiv)
Then
16829 xlowt(jlow) = xlowt(icrs)
16840 valnth = maxval(xlowt(1 : inth))
16844 End Function i_valnth
Random permutation ranking.
Find N-th value in array from insertion sort.
Median index of skewed-pivot with quicksort ranking.
Nth index of skewed-pivot with quicksort ranking.
Partial insertion sort ranking,.
Merge-sort ranking (unoptimized)
Multiplicity of array values.
Skewed-pivot with quicksort ranking (reversed).
Skewed-pivot with quicksort ranking (unoptimized).
Quicksort ranking, with insertion sort at last step (unoptimized)
Insertion sort ranking (unoptimized).
Skewed-pivot with quicksort ranking.
Gives the indeces that would sort an array in ascending order.
Sorts the input array in ascending order.
Merge-sort ranking, with removal of duplicate entries (reversed).
Partial quicksort/insertion sort ranking, with removal of duplicate entries.
Merge-sort ranking, with removal of duplicate entries.
Merge-sort unique inverse ranking.
Find median value of array.
Find N-th value in array from quicksort.
Comparison of real values.
Comparison of real values: a <= b.
Comparison of real values for inequality.
Define number representations.
integer, parameter sp
Single Precision Real Kind.
integer, parameter i4
4 Byte Integer Kind
integer, parameter dp
Double Precision Real Kind.
Sort and ranking routines.
General utilities for the CHS library.