/[MITgcm]/MITgcm/eesupp/src/gather_2d.F
ViewVC logotype

Contents of /MITgcm/eesupp/src/gather_2d.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.6 - (show annotations) (download)
Wed Nov 9 19:50:03 2005 UTC (18 years, 7 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint58l_post, checkpoint58e_post, checkpoint58b_post, checkpoint58m_post, checkpoint57y_post, checkpoint58g_post, checkpoint57x_post, checkpoint58n_post, checkpoint58h_post, checkpoint58j_post, checkpoint57y_pre, checkpoint58, checkpoint58f_post, checkpoint58d_post, checkpoint58a_post, checkpoint58i_post, checkpoint58o_post, checkpoint57z_post, checkpoint58c_post, checkpoint58k_post, checkpoint58p_post
Changes since 1.5: +2 -2 lines
only needs CPP_EEOPTIONS.h

1 C $Header: /u/gcmpack/MITgcm/eesupp/src/gather_2d.F,v 1.5 2005/11/05 00:51:06 jmc Exp $
2 C $Name: $
3
4 #include "CPP_EEOPTIONS.h"
5
6 SUBROUTINE GATHER_2D( global, local, myThid )
7 C Gather elements of a 2-D array from all mpi processes to process 0.
8 IMPLICIT NONE
9 #include "SIZE.h"
10 #include "EEPARAMS.h"
11 #include "EESUPPORT.h"
12 C mythid - thread number for this instance of the routine.
13 C global,local - working arrays used to transfer 2-D fields
14 INTEGER mythid
15 Real*8 global(Nx,Ny)
16 _RL local(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
17
18 INTEGER iG,jG, i, j, bi, bj
19 #ifdef ALLOW_USE_MPI
20 _RL temp(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
21 INTEGER istatus(MPI_STATUS_SIZE), ierr
22 INTEGER lbuff, idest, itag, npe, ready_to_receive
23 #endif /* ALLOW_USE_MPI */
24
25 C-- Make everyone wait except for master thread.
26 _BARRIER
27 _BEGIN_MASTER( myThid )
28
29 #ifndef ALLOW_USE_MPI
30
31 DO bj=1,nSy
32 DO bi=1,nSx
33 DO j=1,sNy
34 DO i=1,sNx
35 iG = myXGlobalLo-1+(bi-1)*sNx+i
36 jG = myYGlobalLo-1+(bj-1)*sNy+j
37 global(iG,jG) = local(i,j,bi,bj)
38 ENDDO
39 ENDDO
40 ENDDO
41 ENDDO
42
43 #else /* ALLOW_USE_MPI */
44
45 lbuff = (sNx+2*OLx)*nSx*(sNy+2*OLy)*nSy
46 idest = 0
47 itag = 0
48 ready_to_receive = 0
49
50 IF( mpiMyId .EQ. 0 ) THEN
51
52 C-- Process 0 fills-in its local data
53 npe = 0
54 DO bj=1,nSy
55 DO bi=1,nSx
56 DO j=1,sNy
57 DO i=1,sNx
58 iG = mpi_myXGlobalLo(npe+1)-1+(bi-1)*sNx+i
59 jG = mpi_myYGlobalLo(npe+1)-1+(bj-1)*sNy+j
60 global(iG,jG) = local(i,j,bi,bj)
61 ENDDO
62 ENDDO
63 ENDDO
64 ENDDO
65
66 C-- Process 0 polls and receives data from each process in turn
67 DO npe = 1, numberOfProcs-1
68 CALL MPI_SEND (ready_to_receive, 1, MPI_INTEGER,
69 & npe, itag, MPI_COMM_MODEL, ierr)
70 CALL MPI_RECV (temp, lbuff, MPI_DOUBLE_PRECISION,
71 & npe, itag, MPI_COMM_MODEL, istatus, ierr)
72
73 C-- Process 0 gathers the local arrays into a global array.
74 DO bj=1,nSy
75 DO bi=1,nSx
76 DO j=1,sNy
77 DO i=1,sNx
78 iG = mpi_myXGlobalLo(npe+1)-1+(bi-1)*sNx+i
79 jG = mpi_myYGlobalLo(npe+1)-1+(bj-1)*sNy+j
80 global(iG,jG) = temp(i,j,bi,bj)
81 ENDDO
82 ENDDO
83 ENDDO
84 ENDDO
85 ENDDO
86
87 ELSE
88
89 C-- All proceses except 0 wait to be polled then send local array
90 CALL MPI_RECV (ready_to_receive, 1, MPI_INTEGER,
91 & idest, itag, MPI_COMM_MODEL, istatus, ierr)
92 CALL MPI_SEND (local, lbuff, MPI_DOUBLE_PRECISION,
93 & idest, itag, MPI_COMM_MODEL, ierr)
94
95 ENDIF
96
97 #endif /* ALLOW_USE_MPI */
98
99 _END_MASTER( myThid )
100 _BARRIER
101
102 RETURN
103 END

  ViewVC Help
Powered by ViewVC 1.1.22