Advertisement
Guest User

Untitled

a guest
Feb 3rd, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. # --------------------------------------------------------------------------------------------
  2. ### code from star_maker8.C and star_maker9.C to assign initial positions for new particles
  3. xpos = *xstart + ((float) i - 0.5)*(*dx);
  4. ypos = *ystart + ((float) j - 0.5)*(*dx);
  5. zpos = *zstart + ((float) k - 0.5)*(*dx);
  6. # ---------------------------------------------------------------------------------------------
  7.  
  8. #
  9. # analogous Fortran code looks the same, using (i - 0.5)*dx ...
  10. # However, I believe the C code should be using (i + 0.5)*dx
  11. # instead because of the offset in the loop counters as copied below:
  12.  
  13. # -----------------------------------------------------------------------------
  14. ### the for loops looping over grid cells in star_maker8.C and star_maker9.C
  15. ### indices start at ibuff
  16. for (k = *ibuff; k < *nz-*ibuff; k++) {
  17. for (j = *ibuff; j < *ny-*ibuff; j++) {
  18. index = (k * (*ny) + j) * (*nx) + (*ibuff);
  19. for (i = *ibuff; i < *nx-*ibuff; i++, index++)
  20. # --------------------------------------------------------------------------------
  21.  
  22. # -----------------------------------------------------------------------------------
  23. ### corresponding code from one of the Fortran star_maker codes.
  24. ### indices start at ibuff + 1
  25. do k=1+ibuff,nz-ibuff
  26. do j=1+ibuff,ny-ibuff
  27. do i=1+ibuff,nx-ibuff
  28. # --------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement