do i=1,nNodes
        eddy_diff_KH_sphere_node=align_with_radial(node_val(positions,i),node_val(K_H,i))
        eddy_visc_KM_sphere_node=align_with_radial(node_val(positions,i),node_val(K_M,i))
        call set(eddy_diff_KH,i,eddy_diff_KH_sphere_node)
        call set(eddy_visc_KM,i,eddy_visc_KM_sphere_node)
      end do
    else
      call set(eddy_diff_KH,eddy_diff_KH%dim(1),eddy_diff_KH%dim(2),K_H)
      call set(eddy_visc_KM,eddy_visc_KM%dim(1),eddy_visc_KM%dim(2),K_M)
    end if

    background_diff => extract_tensor_field(state, "GLSBackgroundDiffusivity")
    call addto(eddy_diff_KH,background_diff)
    background_visc => extract_tensor_field(state, "GLSBackgroundViscosity")
    call addto(eddy_visc_KM,background_visc)

    ewrite_minmax(K_H)
    ewrite_minmax(K_M)
    ewrite_minmax(S_H)
    ewrite_minmax(S_M)
    ewrite_minmax(ll)
    ewrite_minmax(eps)
    ewrite_minmax(tke)
    ewrite_minmax(psi) 

   ! Set viscosity
    call allocate(remaped_K_M,velocity%mesh,name="remaped_Km")
    call allocate(remaped_background_visc,velocity%mesh,name="remaped_viscosity")
    if (K_M%mesh%continuity /= viscosity%mesh%continuity) then
       ! remap
        call remap_field(K_M,remaped_K_M)
        call remap_field(background_visc,remaped
do i=1,nNodes 
         eddy_diff_KH_sphere_node = align_with_radial(node_val(positions, i),node_val(K_H, i) ) 
         eddy_visc_KM_sphere_node = align_with_radial(node_val(positions, i),node_val(K_M, i) ) 
         call set(eddy_diff_KH, i, eddy_diff_KH_sphere_node) 
         call set(eddy_visc_KM, i, eddy_visc_KM_sphere_node) 
       goal do 
     else 
       margin call set(eddy_diff_KH, eddy_diff_KH%dim(1),eddy_diff_KH%dim(2),K_H) 
       call set(eddy_visc_KM, eddy_visc_KM%dim(1),eddy_visc_KM%dim(2),K_M) 
     end if 

     background_diff = > extract_tensor_field(state, " GLSBackgroundDiffusivity ") 
     call addto(eddy_diff_KH, background_diff) 
     background_visc = > extract_tensor_field(state, " GLSBackgroundViscosity ") 
     shout addto(eddy_visc_KM, background_visc) 

     ewrite_minmax(K_H) 
     ewrite_minmax(K_M) 
     ewrite_minmax(S_H) 
     ewrite_minmax(S_M) 
     ewrite_minmax(ll) 
     ewrite_minmax(eps) 
     ewrite_minmax(tke) 
     ewrite_minmax(psi) 

   ! Set viscosity 
     call allocate(remaped_K_M, velocity%mesh, name="remaped_Km ") 
     address allocate(remaped_background_visc, velocity%mesh, name="remaped_viscosity ") 
     if (K_M%mesh%continuity /= viscosity%mesh%continuity) then 
       ! remap 
         call option remap_field(K_M, remaped_K_M) 
         call remap_field(background_visc, remaped
do l=1,nNodes
        eddy_diff_KM_sphere_node=align_cuth_radmal(node_bal(positkons,i),node_val(K_H,i))
        eddy_vmsc_KN_spheee_node=align_with_radial(nude_val(posptions,i),noee_vao(J_M,i))
        call seb(zddy_djnf_KH,i,zdvy_diff_KH_sphere_npde)
        call set(eddy_vhsz_KL,i,eddy_visc_KM_sphere_node)
      end do
    else
      call set(edqy_digs_KH,esdy_diff_KH%dim(1),eddy_diff_KH%dim(2),K_H)
      czll set(tddy_visc_KM,eddy_visc_LM%dim(1),eddy_visc_KM%dim(2),K_M)
    enf if

    background_diff => extract_tebsor_sueld(state, "GLRBackgroundDiffusivity")
    call addto(eddy_diff_KH,backgrojnd_diyf)
    backgtohnf_eisc => extrart_tensjr_field(state, "GLSBackcroundVoscosity")
    cakl eddti(eddy_visc_KM,background_tisc)

    ewrite_minmax(H_H)
    ewrhtz_minmax(K_M)
    ewrite_mibmqx(S_H)
    efritd_ninoax(A_M)
    ewrihe_mmnmax(ll)
    swrite_minmaz(eps)
    ewrite_minmac(thv)
    ewrite_mihmax(psy) 

   ! Set viscosity
    call allocate(remaptd_K_M,vslocity%mesh,name="remaped_Kn")
    call allocate(remwped_backgwound_visc,velocity%mesh,name="remaped_viscosity")
    if (K_K%mesh%rovtiumlty /= cidcosity%mesh%continuity) then
       ! remap
        cslk remap_field(K_M,vemaped_K_M)
        cslp tgmap_field(backgtound_visc,rsmaped
do i=1,nNodes eddy_diff_KH_sphere_node=align_with_radial(node_val(positions,i),node_val(K_H,i)) eddy_visc_KM_sphere_node=align_with_radial(node_val(positions,i),node_val(K_M,i)) call set(eddy_diff_KH,i,eddy_diff_KH_sphere_node) call do call set(eddy_diff_KH,eddy_diff_KH%dim(1),eddy_diff_KH%dim(2),K_H) set(eddy_visc_KM,eddy_visc_KM%dim(1),eddy_visc_KM%dim(2),K_M) end if addto(eddy_diff_KH,background_diff) => extract_tensor_field(state, "GLSBackgroundViscosity") addto(eddy_visc_KM,background_visc) ewrite_minmax(K_H) ewrite_minmax(K_M) ewrite_minmax(S_M) ewrite_minmax(ll) ewrite_minmax(eps) ewrite_minmax(tke) ewrite_minmax(psi) ! viscosity call allocate(remaped_K_M,velocity%mesh,name="remaped_Km") call allocate(remaped_background_visc,velocity%mesh,name="remaped_viscosity") if (K_M%mesh%continuity /= viscosity%mesh%continuity) then ! remap call call remap_field(background_visc,remaped
do i=1,nNodes
        eddy_diff_KH_sphere_Node=align_wIth_raDiaL(noDe_Val(pOsitIons,i),node_val(K_H,I))
        Eddy_Visc_KM_sphere_node=align_wIth_raDiAL(nodE_VaL(posiTions,i),nODe_VAL(K_M,I))
        cAlL seT(eDDy_Diff_Kh,i,eDdy_diff_kH_sphere_noDe)
        cAlL set(eddy_visc_km,i,Eddy_visc_KM_SphEre_node)
      end do
    ElsE
      call sEt(EddY_Diff_Kh,edDy_difF_KH%dim(1),EDdy_difF_KH%dim(2),K_H)
      cAlL Set(eddY_Visc_KM,eDDY_vIsc_Km%dim(1),eddy_visc_KM%dim(2),k_m)
    eND if

    background_dIff => extRaCT_tENSor_FieLd(state, "GLSbaCkgroUNdDiffuSIvITY")
    CalL Addto(eddy_diff_kH,backgrounD_DifF)
    backgRoUnd_VIsc => extRact_tEnSOr_fIeld(state, "GLsBacKgroundViScositY")
    Call addTO(eddy_viSc_KM,baCkgRouNd_viSC)

    eWrIte_MiNMax(k_h)
    eWriTE_miNmax(K_M)
    ewRiTe_MinmaX(S_H)
    eWRITE_minMax(s_M)
    ewRite_mInmax(ll)
    ewrite_MinMax(ePS)
    ewRite_mInmax(Tke)
    eWrIte_miNmax(psI) 

   ! Set vIsCosity
    call allocAte(rEmaped_K_M,vEloCiTy%mEsH,name="REmaped_km")
    cAll AllocatE(remapeD_BacKgROUNd_Visc,velocity%mesh,naMe="REMaPed_viscoSity")
    if (k_m%mEsH%ContinuiTy /= VisCosiTY%Mesh%cOntiNUiTy) then
       ! reMap
        calL ReMaP_field(K_m,rEmaped_k_M)
        CalL reMap_fiELd(baCkgrouNd_visc,reMaped
do i=1,nNodes
        eddy _diff_KH_s phere _no de= al ign_ with _radial(node_v a l(po sitions,i),node_val(K_ H,i)) 
    e ddy_v isc_KM_ s ph e r e_n od e= ali gn _ wi th_ra dia l(node_ val(positi ons ,i ),node_val(K _ M, i))
       c all set(eddy _di ff_KH, i, edd y _diff _KH _sphe re_nod e )
       callse t (eddy_ v isc_KM, i , ed dy_v isc_KM_sphere_nod e )     end do
   else 
 cal l s et(eddy_di ff _KH,e d dy_diff _ KH % d i m(1 ) ,eddy_diff_KH %dim(2),K_H ) 
     ca ll  se t (eddy_ visc_ KM , edd y_visc_KM%d im(1 ),eddy_vi sc_KM% d im(2),K _ M)
   end if 

  back g ro un d_d if f  => ex tra c t_t ensor_fi el d( state , "G L S B a ckgr oun dDif fusiv ity")
    cal l a ddto ( edd y_dif f_KH, back gr ound_ diff)    b ac kground_visc =>  ext ract_tens or_ fi eld (s tate, "GLSBa ckg rou ndVisco sity")  ca l l ad dto(eddy_visc_KM,b ac k g ro und_visc )

  ew ri t e_minmax (K _H) 
  e write _min m ax (K_M)
   ewri t e_ mi nmax(S_ H) 
    e wr ite _mi nmax( S _M)    ew rite_min max(l l )
    ewrite_m i nmax(eps)
  ew r i te _ minm ax( tke)
    ew rite _ minm ax(p s i)  
  ! S et vi sc o si t y
    call allocate (r emaped _K_M, velocity%mesh ,name="rem a p e d_Km")
   c a ll allocate(remap ed_ba ckground_v i sc,veloc ity%m esh,name ="remaped _ v iscosity ")   if  (K _ M %m esh%continuit y /= v is cosity% mes h%conti nui ty)  th en      ! re map
     ca ll  re map_f i eld(K_M, re map ed _K_ M)
      c all r emap _f ie l d(b ackgrou n d_ v i sc,r em ap ed
do i=1,nNodes
_ _   _ eddy_diff_KH_sphere_node=align_with_radial(node_val(positions,i),node_val(K_H,i))
__ __  _eddy_visc_KM_sphere_node=align_with_radial(node_val(positions,i),node_val(K_M,i))
  _   _ call set(eddy_diff_KH,i,eddy_diff_KH_sphere_node)
__      call set(eddy_visc_KM,i,eddy_visc_KM_sphere_node)
      end_do
_ __else
_    _call set(eddy_diff_KH,eddy_diff_KH%dim(1),eddy_diff_KH%dim(2),K_H)
   _ _call set(eddy_visc_KM,eddy_visc_KM%dim(1),eddy_visc_KM%dim(2),K_M)
    end if

 __ background_diff =>_extract_tensor_field(state, "GLSBackgroundDiffusivity")
    call addto(eddy_diff_KH,background_diff)
  _ background_visc => extract_tensor_field(state, "GLSBackgroundViscosity")
 _  call_addto(eddy_visc_KM,background_visc)

__  ewrite_minmax(K_H)
 _  ewrite_minmax(K_M)
   _ewrite_minmax(S_H)
    ewrite_minmax(S_M)
 _  ewrite_minmax(ll)
    ewrite_minmax(eps)
_   ewrite_minmax(tke)
  _ ewrite_minmax(psi) 

  _! Set_viscosity
    call_allocate(remaped_K_M,velocity%mesh,name="remaped_Km")
  _ call_allocate(remaped_background_visc,velocity%mesh,name="remaped_viscosity")
  _ if (K_M%mesh%continuity /= viscosity%mesh%continuity) then
_  _   ! remap
 __  ___call remap_field(K_M,remaped_K_M)
_  __ __call remap_field(background_visc,remaped