c ====================================================================== c usage: partdemo0 c c Generates some particle data in sdf form. c c Specifically, generates particles randomly distributed on c surface of sphere, and outputs x 5 data where 2 fcns c associated with (x,y,z) data are c c 1) max(abs(xj),abs(yj),abs(zj)) c 2) min(abs(xj),abs(yj),abs(zj)) c ====================================================================== program partdemo0 implicit none character*9 cdnm parameter ( cdnm = 'partdemo0' ) integer iargc, i4arg integer np integer npmax parameter ( npmax = 10 000 000 ) real*8 r(npmax,6) real*8 t if( iargc() .ne. 1 ) go to 900 np = i4arg(1,-1) if( np .eq. -1 ) go to 900 if( np .lt. 1 .or. np .gt. npmax ) then write(0,*) 'cdnm: np=', np write(0,*) 'cdnm: Exceeds range 1 to ', npmax go to 900 end if call genpart(r,np) t = 0.0d0 call gft_out_part_xyzf('partdemo0',t,r,np,3) stop 900 continue write(0,*) 'usage: '//cdnm//' ' stop end subroutine genpart(r,np) implicit none real*8 drand48 integer np real*8 r(np,6) integer j real*8 xj, yj, zj, nrm call srand(np) do j = 1 , np xj = (2.0d0 * drand48() - 1.0d0) yj = (2.0d0 * drand48() - 1.0d0) zj = (2.0d0 * drand48() - 1.0d0) nrm = 1.0d0 / sqrt(xj**2 + yj**2 + zj**2) xj = nrm * xj yj = nrm * yj zj = nrm * zj r(j,1) = xj r(j,2) = yj r(j,3) = zj r(j,4) = max(abs(xj),abs(yj),abs(zj)) r(j,5) = min(abs(xj),abs(yj),abs(zj)) r(j,6) = max(abs(xj) - abs(yj),abs(xj) - abs(zj), & abs(yj) - abs(zj)) end do return end