idloc.f 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. *DECK IDLOC
  2. INTEGER FUNCTION IDLOC (LOC, SX, IX)
  3. C***BEGIN PROLOGUE IDLOC
  4. C***SUBSIDIARY
  5. C***PURPOSE Subsidiary to DSPLP
  6. C***LIBRARY SLATEC
  7. C***TYPE DOUBLE PRECISION (IPLOC-S, IDLOC-D)
  8. C***KEYWORDS RELATIVE ADDRESS DETERMINATION FUNCTION, SLATEC
  9. C***AUTHOR Boland, W. Robert, (LANL)
  10. C Nicol, Tom, (University of British Columbia)
  11. C***DESCRIPTION
  12. C
  13. C Given a "virtual" location, IDLOC 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 DSPLP
  22. C***ROUTINES CALLED DPRWPG, XERMSG
  23. C***REVISION HISTORY (YYMMDD)
  24. C 890606 DATE WRITTEN
  25. C 890606 REVISION DATE from Version 3.2
  26. C 891214 Prologue converted to Version 4.0 format. (BAB)
  27. C 900315 CALLs to XERROR changed to CALLs to XERMSG. (THJ)
  28. C 910731 Added code to set IDLOC to 0 if LOC is non-positive. (WRB)
  29. C***END PROLOGUE IDLOC
  30. DOUBLE PRECISION SX(*)
  31. INTEGER IX(*)
  32. C***FIRST EXECUTABLE STATEMENT IDLOC
  33. IF (LOC.LE.0) THEN
  34. CALL XERMSG ('SLATEC', 'IDLOC',
  35. + 'A value of LOC, the first argument, .LE. 0 was encountered',
  36. + 55, 1)
  37. IDLOC = 0
  38. RETURN
  39. ENDIF
  40. C
  41. C Two cases exist: (1.LE.LOC.LE.K) .OR. (LOC.GT.K).
  42. C
  43. K = IX(3) + 4
  44. LMX = IX(1)
  45. LMXM1 = LMX - 1
  46. IF (LOC.LE.K) THEN
  47. IDLOC = LOC
  48. RETURN
  49. ENDIF
  50. C
  51. C Compute length of the page, starting address of the page, page
  52. C number and relative working address.
  53. C
  54. LPG = LMX-K
  55. ITEMP = LOC - K - 1
  56. IPAGE = ITEMP/LPG + 1
  57. IDLOC = MOD(ITEMP,LPG) + K + 1
  58. NP = ABS(IX(LMXM1))
  59. C
  60. C Determine if a page fault has occurred. If so, write page NP
  61. C and read page IPAGE. Write the page only if it has been
  62. C modified.
  63. C
  64. IF (IPAGE.NE.NP) THEN
  65. IF (SX(LMX).EQ.1.0) THEN
  66. SX(LMX) = 0.0
  67. KEY = 2
  68. CALL DPRWPG (KEY, NP, LPG, SX, IX)
  69. ENDIF
  70. KEY = 1
  71. CALL DPRWPG (KEY, IPAGE, LPG, SX, IX)
  72. ENDIF
  73. RETURN
  74. END