fm_update_fields_newstep Subroutine

private subroutine fm_update_fields_newstep(self)

Update the fields using the new fields

Type Bound

fieldmat_type

Arguments

Type IntentOptional Attributes Name
class(fieldmat_type), intent(in) :: self

Contents


Source Code

  subroutine fm_update_fields_newstep(self)
    use fields_arrays, only: phi,apar,bpar,phinew,aparnew,bparnew
    use run_parameters, only: has_phi, has_apar, has_bpar
    use kt_grids, only: kwork_filter
    use mp, only: proc0
    use array_utils, only: copy
    implicit none
    class(fieldmat_type), intent(in) ::  self
    integer :: ik,it,is,ic

    !If we're proc0 then we need to do full array (for diagnostics)
    if(proc0) then
       if(has_phi) call copy(phinew, phi)
       if(has_apar) call copy(aparnew,apar)
       if(has_bpar) call copy(bparnew, bpar)
       return
    endif

    !Now loop over cells and calculate field equation as required
    !$OMP PARALLEL DO DEFAULT(none) &
    !$OMP PRIVATE(ik, is, ic, it) &
    !$OMP SHARED(self, kwork_filter, has_phi, has_apar, has_bpar, &
    !$OMP phi, apar, bpar, phinew, aparnew, bparnew) &
    !$OMP SCHEDULE(static)
    do ik=1,self%naky
       !Skip not local cells
       if(.not.self%kyb(ik)%is_local) cycle
       do is=1,self%kyb(ik)%nsupercell
          if(.not.self%kyb(ik)%supercells(is)%is_local) cycle
          do ic=1,self%kyb(ik)%supercells(is)%ncell
             if(.not.self%kyb(ik)%supercells(is)%cells(ic)%is_local) cycle

             it=self%kyb(ik)%supercells(is)%cells(ic)%it_ind

             if(kwork_filter(it,ik)) cycle

             !Increment fields 
             if(has_phi) phi(:,it,ik)=phinew(:,it,ik)
             if(has_apar) apar(:,it,ik)=aparnew(:,it,ik)
             if(has_bpar) bpar(:,it,ik)=bparnew(:,it,ik)
         enddo
       enddo
    enddo
    !OMP END PARALLEL DO
  end subroutine fm_update_fields_newstep