randomize_field Subroutine

public subroutine randomize_field(field, klev, ampl, ir, ihl, jhl)

Uses

  • proc~~randomize_field~~UsesGraph proc~randomize_field randomize_field decomp_2d decomp_2d proc~randomize_field->decomp_2d module~modglobal modglobal proc~randomize_field->module~modglobal

Arguments

Type IntentOptional Attributes Name
real :: field(ib-ihl:ie+ihl,jb-jhl:je+jhl,kb-kh:ke+kh)
integer :: klev
real :: ampl
integer(kind=selected_int_kind(6)) :: ir
integer :: ihl
integer :: jhl

Calls

proc~~randomize_field~~CallsGraph proc~randomize_field randomize_field zstart zstart proc~randomize_field->zstart

Called by

proc~~randomize_field~~CalledByGraph proc~randomize_field randomize_field proc~readinitfiles readinitfiles proc~readinitfiles->proc~randomize_field program~udales uDALES program~udales->proc~readinitfiles

Source Code

   subroutine randomize_field(field, klev, ampl, ir, ihl, jhl)

      use decomp_2d, only: zstart
      use modglobal, only: ib, ie, jb, je, kb, ke, kh, itot, jtot
      integer(KIND=selected_int_kind(6)):: imm, ia, ic, ir
      integer ihl, jhl
      integer i, j, klev
      integer iglob, jglob
      integer(KIND=selected_int_kind(12)) :: linear_id, state
      real ran, ampl
      real field(ib - ihl:ie + ihl, jb - jhl:je + jhl, kb - kh:ke + kh)
      parameter(imm=134456, ia=8121, ic=28411)
      do j = jb, je
         jglob = j + zstart(2) - 1
         do i = ib, ie
            iglob = i + zstart(1) - 1
            ! Use the global cell index so the perturbation field is
            ! identical regardless of the MPI decomposition.
            linear_id = int(iglob, kind(linear_id)) &
                        + int(itot, kind(linear_id)) * int(jglob - 1, kind(linear_id)) &
                        + int(itot, kind(linear_id)) * int(jtot, kind(linear_id)) * int(klev - 1, kind(linear_id))
            state = mod(int(ir, kind(state)) + linear_id, int(imm, kind(state)))
            state = mod(state * int(ia, kind(state)) + int(ic, kind(state)), int(imm, kind(state)))
            ran = real(state)/real(imm)
            field(i, j, klev) = field(i, j, klev) + (ran - 0.5)*2.0*ampl
         end do
      end do

      return
   end subroutine randomize_field