Construct Morton-order as a global recursive lexicographic ordering.
subroutine amr_Morton_order use mod_forest use mod_global_parameters use mod_comm_lib, only: mpistop integer :: ig1,ig2,ig3, Morton_no, isfc Morton_no=0 nglev1=ng1(1)*ng2(1)*ng3(1) do isfc=1,nglev1 ig1=sfc_iglevel1(1,isfc) ig2=sfc_iglevel1(2,isfc) ig3=sfc_iglevel1(3,isfc) call get_Morton_number(tree_root(ig1,ig2,ig3)) end do !FIXME: why does this fail with Cray even if the values are equal? Different types somehow? #ifndef _CRAYFTN if (Morton_no/=nleafs) then call mpistop("error in amr_Morton_order: Morton_no/=nleafs") end if #endif contains recursive subroutine get_Morton_number(tree) type(tree_node_ptr) :: tree integer :: ic1,ic2,ic3 if (tree%node%leaf) then Morton_no=Morton_no+1 sfc(1,Morton_no)=tree%node%igrid sfc(2,Morton_no)=tree%node%ipe if (tree%node%active) then sfc(3,Morton_no)=1 else sfc(3,Morton_no)=0 end if if(tree%node%ipe==mype) igrid_to_sfc(tree%node%igrid)=Morton_no else do ic3=1,2 do ic2=1,2 do ic1=1,2 call get_Morton_number(tree%node%child(ic1,ic2,ic3)) end do end do end do end if end subroutine get_Morton_number end subroutine amr_Morton_order