C $Header: /home/ubuntu/mnt/e9_copy/MITgcm/eesupp/src/exch_xyz_rx.template,v 1.2 2001/05/29 14:01:36 adcroft Exp $ C $Name: $ #include "CPP_EEOPTIONS.h" SUBROUTINE EXCH_XYZ_RX( U phi, I myThid ) C /==========================================================\ C | SUBROUTINE EXCH_XYZ_RX | C | o Handle exchanges for _RX , three-dimensional arrays. | C |==========================================================| C | Do true shared-memory data transfers and "messaging" | C | tranfers for blocking case of data transfers. | C | Applications call this routine using | C | CALL EXCH..( x, myThid ) | C | where x is a three-dimensional array with overlaps. | C | This routine does true-shared-memory copies for blocks | C | within a thread. It will also do MPI meesaging between | C | different processes. | C | Note: | C | ===== | C | If it is used, "asynchronous" messaging in which | C | communication overlaps computation is handled elsewhere | C | - see recv.F and send.F. | C | In practice MPI implementations may not be completely | C | thread safe. In principle this code is correct even for | C | mixed MPI and multi-threaded execution. | C | In multi-thread execution data managed by other threads | C | is only automatically visible to another thread if it | C | existed before the thread was created. This means that | C | for Fortran we declare arrays with overlap regions in | C | COMMON blocks. | C \==========================================================/ IMPLICIT NONE C === Global data === #include "SIZE.h" #include "EEPARAMS.h" #include "EESUPPORT.h" C === Routine arguments === C phi - Array with overlap regions are to be exchanged C myThid - My thread id. _RX phi(1-OLx:sNx+OLx,1-OLy:sNy+OLy,1:Nr,nSx,nSy) INTEGER myThid C == Local variables == C OL[wens] - Overlap extents in west, east, north, south. C exchWidth[XY] - Extent of regions that will be exchanged. INTEGER OLw, OLe, OLn, OLs, exchWidthX, exchWidthY, myNz OLw = OLx OLe = OLx OLn = OLy OLs = OLy exchWidthX = OLx exchWidthY = OLy myNz = Nr C ** NOTE ** The exchange routine we use here does not C require the preceeding and following barriers. C However, the slow, simple exchange interface C that is calling it here is meant to ensure C that threads are synchronised before exchanges C begine. IF (useCubedSphereExchange) THEN CALL EXCH_RX_CUBE( phi, I OLw, OLe, OLs, OLn, myNz, I exchWidthX, exchWidthY, I FORWARD_SIMULATION, EXCH_UPDATE_CORNERS, myThid ) ELSE CALL EXCH_RX( phi, I OLw, OLe, OLs, OLn, myNz, I exchWidthX, exchWidthY, I FORWARD_SIMULATION, EXCH_UPDATE_CORNERS, myThid ) ENDIF RETURN END