/[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.4 - (show annotations) (download)
Thu Nov 6 22:00:31 2003 UTC (20 years, 6 months ago) by heimbach
Branch: MAIN
CVS Tags: checkpoint57t_post, checkpoint53f_post, checkpoint54a_pre, checkpoint55c_post, checkpoint53b_pre, checkpoint57o_post, checkpoint57m_post, checkpoint57i_post, checkpoint52e_pre, hrcube4, checkpoint57v_post, checkpoint52n_post, checkpoint52j_post, checkpoint57f_post, checkpoint52e_post, checkpoint57s_post, checkpoint57j_post, checkpoint57b_post, checkpoint52d_pre, checkpoint53c_post, checkpoint53d_post, checkpoint57f_pre, checkpoint57k_post, checkpoint55d_pre, checkpoint57d_post, checkpoint57g_post, checkpoint57c_pre, checkpoint55j_post, checkpoint56b_post, checkpoint57h_pre, checkpoint52j_pre, checkpoint54a_post, branch-netcdf, checkpoint52l_post, checkpoint55h_post, checkpoint52k_post, checkpoint52b_pre, checkpoint57g_pre, checkpoint54b_post, checkpoint57e_post, checkpoint54d_post, checkpoint52l_pre, checkpoint56c_post, checkpoint54e_post, checkpoint55b_post, checkpoint57h_post, checkpoint52m_post, checkpoint55, checkpoint53a_post, checkpoint55a_post, checkpoint57a_post, hrcube5, checkpoint55g_post, checkpoint55f_post, checkpoint57r_post, checkpoint57a_pre, checkpoint54, checkpoint57, checkpoint56, checkpoint53, checkpoint52, checkpoint52d_post, checkpoint52a_post, checkpoint57h_done, checkpoint52b_post, checkpoint53g_post, checkpoint52f_post, checkpoint57n_post, checkpoint52c_post, checkpoint57w_post, checkpoint57p_post, checkpint57u_post, checkpoint57q_post, ecco_c52_e35, checkpoint54f_post, checkpoint55e_post, eckpoint57e_pre, checkpoint57c_post, checkpoint53b_post, checkpoint52a_pre, checkpoint52i_post, checkpoint53d_pre, checkpoint55i_post, checkpoint54c_post, checkpoint57l_post, checkpoint52i_pre, checkpoint51u_post, checkpoint52h_pre, checkpoint52f_pre, hrcube_1, hrcube_2, hrcube_3, checkpoint56a_post, checkpoint55d_post
Branch point for: netcdf-sm0
Changes since 1.3: +3 -0 lines
merging from ecco-branch

1 C $Header: $
2 C $Name: $
3
4 #include "CPP_OPTIONS.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 COMMON /GlobalLo/ mpi_myXGlobalLo, mpi_myYGlobalLo
21 INTEGER mpi_myXGlobalLo(nPx*nPy)
22 INTEGER mpi_myYGlobalLo(nPx*nPy)
23
24 _RL temp(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
25 INTEGER istatus(MPI_STATUS_SIZE), ierr
26 INTEGER lbuff, idest, itag, npe, ready_to_receive
27 #endif /* ALLOW_USE_MPI */
28
29 C-- Make everyone wait except for master thread.
30 _BARRIER
31 _BEGIN_MASTER( myThid )
32
33 #ifndef ALLOW_USE_MPI
34
35 DO bj=1,nSy
36 DO bi=1,nSx
37 DO j=1,sNy
38 DO i=1,sNx
39 iG = myXGlobalLo-1+(bi-1)*sNx+i
40 jG = myYGlobalLo-1+(bj-1)*sNy+j
41 global(iG,jG) = local(i,j,bi,bj)
42 ENDDO
43 ENDDO
44 ENDDO
45 ENDDO
46
47 #else /* ALLOW_USE_MPI */
48
49 lbuff = (sNx+2*OLx)*nSx*(sNy+2*OLy)*nSy
50 idest = 0
51 itag = 0
52 ready_to_receive = 0
53
54 IF( mpiMyId .EQ. 0 ) THEN
55
56 C-- Process 0 fills-in its local data
57 npe = 0
58 DO bj=1,nSy
59 DO bi=1,nSx
60 DO j=1,sNy
61 DO i=1,sNx
62 iG = mpi_myXGlobalLo(npe+1)-1+(bi-1)*sNx+i
63 jG = mpi_myYGlobalLo(npe+1)-1+(bj-1)*sNy+j
64 global(iG,jG) = local(i,j,bi,bj)
65 ENDDO
66 ENDDO
67 ENDDO
68 ENDDO
69
70 C-- Process 0 polls and receives data from each process in turn
71 DO npe = 1, numberOfProcs-1
72 CALL MPI_SEND (ready_to_receive, 1, MPI_INTEGER,
73 & npe, itag, MPI_COMM_MODEL, ierr)
74 CALL MPI_RECV (temp, lbuff, MPI_DOUBLE_PRECISION,
75 & npe, itag, MPI_COMM_MODEL, istatus, ierr)
76
77 C-- Process 0 gathers the local arrays into a global array.
78 DO bj=1,nSy
79 DO bi=1,nSx
80 DO j=1,sNy
81 DO i=1,sNx
82 iG = mpi_myXGlobalLo(npe+1)-1+(bi-1)*sNx+i
83 jG = mpi_myYGlobalLo(npe+1)-1+(bj-1)*sNy+j
84 global(iG,jG) = temp(i,j,bi,bj)
85 ENDDO
86 ENDDO
87 ENDDO
88 ENDDO
89 ENDDO
90
91 ELSE
92
93 C-- All proceses except 0 wait to be polled then send local array
94 CALL MPI_RECV (ready_to_receive, 1, MPI_INTEGER,
95 & idest, itag, MPI_COMM_MODEL, istatus, ierr)
96 CALL MPI_SEND (local, lbuff, MPI_DOUBLE_PRECISION,
97 & idest, itag, MPI_COMM_MODEL, ierr)
98
99 ENDIF
100
101 #endif /* ALLOW_USE_MPI */
102
103 _END_MASTER( myThid )
104 _BARRIER
105
106 RETURN
107 END

  ViewVC Help
Powered by ViewVC 1.1.22