iploc.f 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. *DECK IPLOC
  2. INTEGER FUNCTION IPLOC (LOC, SX, IX)
  3. C***BEGIN PROLOGUE IPLOC
  4. C***SUBSIDIARY
  5. C***PURPOSE Subsidiary to SPLP
  6. C***LIBRARY SLATEC
  7. C***TYPE SINGLE PRECISION (IPLOC-S, IDLOC-D)
  8. C***KEYWORDS RELATIVE ADDRESS DETERMINATION FUNCTION, SLATEC
  9. C***AUTHOR Hanson, R. J., (SNLA)
  10. C Wisniewski, J. A., (SNLA)
  11. C***DESCRIPTION
  12. C
  13. C Given a "virtual" location, IPLOC returns the relative working
  14. C address of the vector component stored in SX, IX. Any necessary
  15. C page swaps are performed automatically for the user in this
  16. C function subprogram.
  17. C
  18. C LOC is the "virtual" address of the data to be retrieved.
  19. C SX ,IX represent the matrix where the data is stored.
  20. C
  21. C***SEE ALSO SPLP
  22. C***ROUTINES CALLED PRWPGE, XERMSG
  23. C***REVISION HISTORY (YYMMDD)
  24. C 810306 DATE WRITTEN
  25. C 890531 Changed all specific intrinsics to generic. (WRB)
  26. C 890606 Restructured to match double precision version. (WRB)
  27. C 890606 REVISION DATE from Version 3.2
  28. C 891214 Prologue converted to Version 4.0 format. (BAB)
  29. C 900315 CALLs to XERROR changed to CALLs to XERMSG. (THJ)
  30. C 910731 Added code to set IPLOC to 0 if LOC is non-positive. (WRB)
  31. C***END PROLOGUE IPLOC
  32. REAL SX(*)
  33. INTEGER IX(*)
  34. C***FIRST EXECUTABLE STATEMENT IPLOC
  35. IF (LOC.LE.0) THEN
  36. CALL XERMSG ('SLATEC', 'IPLOC',
  37. + 'A value of LOC, the first argument, .LE. 0 was encountered',
  38. + 55, 1)
  39. IPLOC = 0
  40. RETURN
  41. ENDIF
  42. C
  43. C Two cases exist: (1.LE.LOC.LE.K) .OR. (LOC.GT.K).
  44. C
  45. K = IX(3) + 4
  46. LMX = IX(1)
  47. LMXM1 = LMX - 1
  48. IF (LOC.LE.K) THEN
  49. IPLOC = LOC
  50. RETURN
  51. ENDIF
  52. C
  53. C Compute length of the page, starting address of the page, page
  54. C number and relative working address.
  55. C
  56. LPG = LMX-K
  57. ITEMP = LOC - K - 1
  58. IPAGE = ITEMP/LPG + 1
  59. IPLOC = MOD(ITEMP,LPG) + K + 1
  60. NP = ABS(IX(LMXM1))
  61. C
  62. C Determine if a page fault has occurred. If so, write page NP
  63. C and read page IPAGE. Write the page only if it has been
  64. C modified.
  65. C
  66. IF (IPAGE.NE.NP) THEN
  67. IF (SX(LMX).EQ.1.0) THEN
  68. SX(LMX) = 0.0
  69. KEY = 2
  70. CALL PRWPGE (KEY, NP, LPG, SX, IX)
  71. ENDIF
  72. KEY = 1
  73. CALL PRWPGE (KEY, IPAGE, LPG, SX, IX)
  74. ENDIF
  75. RETURN
  76. END