read_oneblock Subroutine

public subroutine read_oneblock(filename)

Uses

  • proc~~read_oneblock~~UsesGraph proc~read_oneblock read_oneblock module~mod_global_parameters mod_global_parameters proc~read_oneblock->module~mod_global_parameters module~mod_basic_types mod_basic_types module~mod_global_parameters->module~mod_basic_types module~mod_connectivity mod_connectivity module~mod_global_parameters->module~mod_connectivity module~mod_constants mod_constants module~mod_global_parameters->module~mod_constants module~mod_physicaldata mod_physicaldata module~mod_global_parameters->module~mod_physicaldata module~mod_variables mod_variables module~mod_global_parameters->module~mod_variables mpi mpi module~mod_global_parameters->mpi module~mod_variables->module~mod_basic_types

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: filename

Calls

proc~~read_oneblock~~CallsGraph proc~read_oneblock read_oneblock mpi_bcast mpi_bcast proc~read_oneblock->mpi_bcast

Source Code

  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