subroutine aptrins (imin, imax, iran) ccbeg. cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc c c SUBROUTINE APTRINS c c call aptrins (imin, imax, iran) c c Version: aptrins Updated 1990 December 11 15:20. c aptrins Originated 1990 December 11 15:20. c c Author: Arthur L. Edwards, LLNL, L-298, Telephone (925) 422-4123. c c c Purpose: To randomly sample an integer from imin to imax, where each c integer has an equal probability, and store in iran. c c Input: imin, imax. c c Output: iran. c c Glossary: c c imin Input The minimum integer to be sampled. May be negative. c c imax Input The maximum integer to be sampled. May be negative. c c iran Output The randomly sampled integer. c cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc ccend. c.... Local variables. c---- Floating point result. common /laptrins/ fran cbugc***DEBUG begins. cbug 9901 format (/ 'aptrins sampling from integers.', cbug & ' imin=',i6,' imax=',i6) cbug write ( 3, 9901) imin, imax cbugc***DEBUG ends. c.... Randomly sample an integer. if (imin .le. imax) then fran = imin + ranf( ) * (imax - imin + 1) else fran = imax + ranf( ) * (imin - imax + 1) endif if (fran .lt. 0.0) fran = fran - 1.0 iran = fran cbugc***DEBUG begins. cbug 9904 format (/ 'aptrins results: iran=',i6) cbug write ( 3, 9904) iran cbugc***DEBUG ends. return c.... End of subroutine aptrins. (+1 line.) end UCRL-WEB-209832