subroutine read_oneblock(filename)
use mod_global_parameters
character(len=*), intent(in) :: filename
character(len=1024) :: outfilehead
integer :: nctot, ix1,ix2,ix3, ixp1,ixp2,&
ixp3
double precision :: time
integer :: idim
integer,dimension(3) :: sendbuff
if (mype == 0) write(*,*) 'mod_oneblock: reading ',nw,' variables on unit:',&
unit
!----------------------------------------
! Root does the reading:
!----------------------------------------
if (mype == 0) then
open(unit,file=filename,status='unknown')
! The header information:
read(unit,'(A)') outfilehead
read(unit,*) nctot,nc1,nc2,nc3
read(unit,*) time
! Allocate and read the grid and variables:
allocate(xoneblock(nc1,nc2,nc3,1:3))
allocate(woneblock(nc1,nc2,nc3,1:nw))
do ix3=1,nc3
do ix2=1,nc2
do ix1=1,nc1
read(unit,*) xoneblock(ix1,ix2,ix3,1:3), woneblock(ix1,ix2,ix3,1:nw)
end do
end do
end do
! Close the file
close(unit)
end if! mype==0
!----------------------------------------
! Broadcast what mype=0 read:
!----------------------------------------
if (npe>1) then
sendbuff(1)=nc1;sendbuff(2)=nc2;sendbuff(3)=nc3;
call MPI_BCAST(sendbuff,3,MPI_INTEGER,0,icomm,ierrmpi)
if (mype .ne. 0) then
nc1=sendbuff(1);nc2=sendbuff(2);nc3=sendbuff(3);
! Allocate the grid and variables:
allocate(xoneblock(nc1,nc2,nc3,1:3))
allocate(woneblock(nc1,nc2,nc3,1:nw))
end if
call MPI_BCAST(xoneblock,nc1*nc2*nc3*3,MPI_DOUBLE_PRECISION,0,icomm,&
ierrmpi)
call MPI_BCAST(woneblock,nc1*nc2*nc3*nw,MPI_DOUBLE_PRECISION,0,icomm,&
ierrmpi)
end if! npe>1
end subroutine read_oneblock