/[MITgcm]/MITgcm_contrib/dgoldberg/streamice/streamice_velmask_upd.F
ViewVC logotype

Diff of /MITgcm_contrib/dgoldberg/streamice/streamice_velmask_upd.F

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

revision 1.3 by dgoldberg, Wed Jan 9 21:56:18 2013 UTC revision 1.4 by dgoldberg, Sat Apr 6 17:43:41 2013 UTC
# Line 22  C     === Global variables === Line 22  C     === Global variables ===
22  #include "EEPARAMS.h"  #include "EEPARAMS.h"
23  #include "PARAMS.h"  #include "PARAMS.h"
24  #include "STREAMICE.h"  #include "STREAMICE.h"
25    #ifdef ALLOW_USE_MPI
26    # include "EESUPPORT.h"
27    #endif
28  ! #include "STREAMICE_ADV.h"  ! #include "STREAMICE_ADV.h"
29    
30        INTEGER myThid        INTEGER myThid
# Line 30  C     === Global variables === Line 33  C     === Global variables ===
33    
34        INTEGER i, j, bi, bj, ki, kj        INTEGER i, j, bi, bj, ki, kj
35        INTEGER maskFlag        INTEGER maskFlag
36          CHARACTER*(MAX_LEN_MBUF) msgBuf
37    #ifdef ALLOW_USE_MPI
38          integer mpiRC, mpiMyWid
39    #endif
40    #ifdef ALLOW_PETSC
41          _RS DoFCount
42          integer n_dofs_proc_loc (0:nPx*nPy-1)
43          integer n_dofs_cum_sum (0:nPx*nPy-1)
44    #endif
45    
46        _EXCH_XY_RL( H_streamice, myThid )        _EXCH_XY_RL( H_streamice, myThid )
47        _EXCH_XY_RL( area_shelf_streamice, myThid )        _EXCH_XY_RL( area_shelf_streamice, myThid )
# Line 173  C     === Global variables === Line 185  C     === Global variables ===
185        CALL WRITE_FLD_XY_RL ("ufacemask","",STREAMICE_ufacemask,0,myThid)        CALL WRITE_FLD_XY_RL ("ufacemask","",STREAMICE_ufacemask,0,myThid)
186        CALL WRITE_FLD_XY_RL ("vfacemask","",STREAMICE_vfacemask,0,myThid)        CALL WRITE_FLD_XY_RL ("vfacemask","",STREAMICE_vfacemask,0,myThid)
187    
188    #ifdef ALLOW_PETSC
189    
190          DO bj = myByLo(myThid), myByHi(myThid)
191           DO bi = myBxLo(myThid), myBxHi(myThid)
192            DO j=1,sNy
193             DO i=1,sNx
194               streamice_petsc_dofs_u (i,j,bi,bj) = -2.0
195               streamice_petsc_dofs_v (i,j,bi,bj) = -2.0
196             ENDDO
197            ENDDO
198           ENDDO
199          ENDDO
200    
201          DoFCount = -1.0
202          DO bj = myByLo(myThid), myByHi(myThid)
203           DO bi = myBxLo(myThid), myBxHi(myThid)
204            DO j=1,sNy
205             DO i=1,sNx
206    
207    
208    C   DOFS ARE NUMBERED AS FOLLOWS ON PROCESSOR DOMAIN:
209    C    grid is stepped through in order bj, bi, j, i
210    C    1) if umask(i,j,bi,bj)==1, the counter is updated by 1;
211    C        streamice_petsc_dofs_u is assigned the counter;
212    C        o/w  streamice_petsc_dofs_u is assigned -1
213    C    2) if vmask(i,j,bi,bj)==1, the counter is updated by 1;
214    C        streamice_petsc_dofs_v is assigned the counter;
215    C        o/w  streamice_petsc_dofs_v is assigned -1
216    C    NOTE THESE NUMBERING ARRAYS ARE USED TO CONSTRUCT PETSC VECTORS AND MATRIX
217    
218              if (STREAMICE_umask (i,j,bi,bj).eq.1) THEN
219               DoFCount = DoFCount + 1.0
220               streamice_petsc_dofs_u (i,j,bi,bj) = DoFCount
221              else
222               streamice_petsc_dofs_u (i,j,bi,bj) = -1.0
223              endif
224    
225              if (STREAMICE_vmask (i,j,bi,bj).eq.1) THEN
226               DoFCount = DoFCount + 1.0
227               streamice_petsc_dofs_v (i,j,bi,bj) = DoFCount
228              else
229               streamice_petsc_dofs_v (i,j,bi,bj) = -1.0
230              endif
231    
232             ENDDO
233            ENDDO
234           ENDDO
235          ENDDO
236    
237    #ifdef ALLOW_USE_MPI
238    
239          DO i=0,nPx*nPy-1
240           n_dofs_proc_loc (i) = 0
241          ENDDO
242    
243          CALL MPI_COMM_RANK( MPI_COMM_WORLD, mpiMyWId, mpiRC )
244    
245          n_dofs_proc_loc (mpiMyWId) = INT(DoFCount)+1
246    
247          CALL MPI_Allreduce(n_dofs_proc_loc,n_dofs_process,nPx*nPy,
248         &       MPI_INTEGER, MPI_SUM,MPI_COMM_MODEL,mpiRC)
249    
250          n_dofs_cum_sum(0) = 0
251    
252          DO i=1,nPx*nPy-1
253           n_dofs_cum_sum(i) = n_dofs_cum_sum(i-1)+
254         &                     n_dofs_process(i-1)
255          ENDDO
256    
257    #else /* ALLOW_USE_MPI */
258    
259          n_dofs_process (0) = INT(DoFCount)+1
260          n_dofs_cum_sum (0) = INT(DoFCount)+1
261    
262    #endif /* ALLOW_USE_MPI */
263    
264          DO bj = myByLo(myThid), myByHi(myThid)
265           DO bi = myBxLo(myThid), myBxHi(myThid)
266            DO j=1,sNy
267             DO i=1,sNx
268              IF (streamice_petsc_dofs_u(i,j,bi,bj).ge.0 ) THEN
269               streamice_petsc_dofs_u(i,j,bi,bj) =
270         &      streamice_petsc_dofs_u(i,j,bi,bj) +
271         &      n_dofs_cum_sum(mpimywid)
272              ENDIF
273              IF (streamice_petsc_dofs_v(i,j,bi,bj).ge.0 ) THEN
274               streamice_petsc_dofs_v(i,j,bi,bj) =
275         &      streamice_petsc_dofs_v(i,j,bi,bj) +
276         &      n_dofs_cum_sum(mpimywid)
277              ENDIF
278             ENDDO
279            ENDDO
280           ENDDO
281          ENDDO
282    
283          _EXCH_XY_RS(streamice_petsc_dofs_u,myThid)
284          _EXCH_XY_RS(streamice_petsc_dofs_v,myThid)
285    
286    
287    #endif /* ALLOW_PETSC */
288    
289    
290  #endif  #endif

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

  ViewVC Help
Powered by ViewVC 1.1.22