UPP  V11.0.0
 All Data Structures Files Functions Pages
GETNEMSNDSCATTER.f
1  subroutine getnemsandscatter(me,nfile,im,jm,jsta,jsta_2l &
2  ,jend_2u,mpi_comm_comp,icnt,idsp,spval,varname,vcoordname &
3  ,l,impf,jmpf,nframe,buf)
4 !
5  use nemsio_module, only: nemsio_gfile, nemsio_readrecvw34
6  implicit none
7  type(nemsio_gfile),intent(inout) :: nfile
8  include "mpif.h"
9 !
10  character(len=20),intent(in) :: varname,vcoordname
11  real,intent(in) :: spval
12  integer,intent(in) :: me,im,jm,jsta_2l,jend_2u,jsta, &
13  mpi_comm_comp,l,impf,jmpf,nframe
14  integer,intent(in) :: icnt(0:1023), idsp(0:1023)
15  real,intent(out) :: buf(im,jsta_2l:jend_2u)
16  integer :: iret,i,j,idiff,jj
17  real dummy(im,jm)
18 ! real dummy2(impf,jmpf)
19  real, allocatable:: dum1d(:)
20 
21  if(me == 0) then
22 ! nframe=nframed2*2
23  allocate(dum1d((impf)*(jmpf)))
24  idiff = (impf-im)/2
25  call nemsio_readrecvw34(nfile,trim(varname) &
26  ,trim(vcoordname),l,data=dum1d,nframe=nframe,iret=iret)
27 ! if(trim(VarName)=='tmp')print*,'in getnems debug: ',impf,jmpf, &
28 ! nframe,trim(VarName),trim(VcoordName),l
29  if (iret /= 0) then
30  print*,varname,vcoordname,l," not found in NEMS file-Assigned missing values"
31 !$omp parallel do private(i,j)
32  do j=1,jm
33  do i=1,im
34  dummy(i,j) = spval
35  enddo
36  enddo
37  else
38 !$omp parallel do private(i,j,jj)
39  do j=1,jm
40  jj= (j-1)*impf + idiff
41  do i=1,im
42  dummy(i,j) = dum1d(jj+i)
43  if(dummy(i,j) >= 9.9e20) dummy(i,j) = spval
44 
45 ! if(trim(VarName)=='tmp' .and. j==72)print*, &
46 ! 'T before scatter',i,j,dummy(i,j)
47 ! dummy(i,j)=dummy2(i+nframed2,j+nframed2)
48 
49  end do
50  end do
51  end if
52  deallocate(dum1d)
53  end if
54 
55  call mpi_scatterv(dummy(1,1),icnt,idsp,mpi_real &
56  ,buf(1,jsta),icnt(me),mpi_real,0,mpi_comm_comp,iret)
57 
58  RETURN
59  END