*ID GBCGF406
*/ U.M. 4.6 unix / source code change form / header   version 06/01/99
*/ CODE WRITERS MUST READ THE ACCOMPANYING INSTRUCTIONS FOR THIS BUILD:
*/  - See http://fr0800/umdoc/hegui/t3e4.6.html#chgfinst
*/ 
*/SOC: Improved swap bounds with no internal copies
*/
*/ Has an entry been lodged in the Problem Reporting System? [N]      
*/
*/ THIS CODE IS INTENDED FOR INCLUSION IN THE 4.6 BUILD      [Y]
*/ .....................................................................
*/   Author[s]:-> E-mail:-> bcarruthers@meto.gov.uk 
*/ Reviewer[s]:-> E-mail:-> @meto.gov.uk
*/
*/    "I have checked this change. When provided, the advance design 
*/  specification was agreed and adequate, and the new code conforms to
*/  Unified Model standards."
*/
*/  DESIGN SPEC. WAS REVIEWED ON: ......      REVIEWER[S] SIGNATURES
*/                                            ----------------------
*/    DATE CODE REVIEWED: ......
*/  .....................................................................
*/
*/  WILL CHANGES AFFECT ANCILLARY FILES?         [N]
*/  ARE ANY CHANGES TO STASHMASTER FILES NEEDED? [N] 
*/  USER INTERFACE ACTION REQUIRED?              [N]
*/ 
*/  TESTED IN CONFIGURATIONS:-> Global Climate Model
*/  TESTS RUN BY [PERSON]:-> Bob Carruthers
*/ 
*/  WILL THE CHANGES SLOW DOWN THE MODEL?        [N]
*/  -> Further details
*/  CHANGES WILL INCREASE MEMORY CONSUMPTION?    [N]   
*/  -> Further details
*/
*/ | Re-start dumps bit compare with those created without the change 
*/ V MARK [Y| ] BELOW; leave rest of lines untouched.
*/
*/   Control Code    loses bit comparison
*/   Atmosphere (assuming same science options chosen)   loses b.c.
*/   Ocean       loses bit comparison
*/   Wave        loses bit comparison
*/   Reconfiguration   loses bit comparison
*/   Diagnostics      lose bit comparison
*/ For Y2K compliance checking:  
*/ DOES THIS CHANGE INTERACT WITH DATE CALCULATIONS IN ANY WAY? [Y|N]   
*/ 
*/  SECTIONS (TO BE) CHANGED:
*/
*/  SECTIONS (TO BE) DELETED? 
*/
*/  NEW SECTIONS?  Fill in form http://www-hc/~hadmk/STASHmaster_change.html,
*/  and give section numbers below:
*/  
*/  *DEFS ADDED OR REMOVED: 
*/
*/  **Existing** decks being changed [with *I, *D, *B directives]
*/ ->
*/  OSWAP1D
*/
*/  Decks being created or purged [with *DECK, *COMDECK, *PURGEDK]
*/ *......K  Deck name   Section#.vr
*/ -> 
*/ ......................................................................
*/ ANY REFERENCES TO EXTERNAL DOCUMENTS-> instead of design spec.
*/  ...OR ... ADVANCE DESIGN SPECIFICATION (optional) 
*/ ->    
*//////////////////////////////////////////////////////////////////////// 
*/
*/
*DC OSWAP1D
*C OSWAP1D
*I OSWAP1D.48
!
!   4.6   15/02/99   Removed Buffer copies, and implemented straight
!                    GET's from the user field, after swapping addresses
!                    and field dimensions.
!                      Author: Bob Carruthers, SGI/Cray Research
*D OSWAP1D.60
      REAL FIELD(X_SIZE*Y_SIZE)
*D OSWAP1D.69
*I OSWAP1D.71

      integer my_remote_ptr, my_remote_x_size, my_remote_y_size
      integer                   remote_x_size,    remote_y_size

      real remote_field(1)
      pointer (remote_ptr, remote_field)

      common/shmem_swap_1d/my_remote_ptr, my_remote_x_size,
     & my_remote_y_size, remote_ptr, remote_x_size, remote_y_size
*D OSWAP1D.80,OSWAP1D.134
      call barrier()

      my_remote_ptr=loc(field)
      my_remote_x_size=x_size
      my_remote_y_size=y_size

      call barrier()

! Note: in the ocean, PNorth actually refers to
! the sothern neighbour and PSouth to the northern
! neighbour. This is a peculiarity caused by the
! fact that the control code which sets up these values
! was written with the atmosphere in mind (the atmosphere
! works north to south, whereas the ocean works south to
! north!!)


! Receive from Southern neighbour

      IF (neighbour(PNorth) .NE. NoDomain) THEN

        call shmem_get(remote_ptr, my_remote_ptr, 3,
     &   neighbour(PNorth))

        call shmem_get(FIELD(1),
     &   REMOTE_FIELD(remote_x_size*(remote_y_size-2)+1),
     &   x_size,neighbour(PNorth))

      ENDIF

! Receive from Northern neighbour

      IF (neighbour(PSouth) .NE. NoDomain) THEN

        call shmem_get(remote_ptr, my_remote_ptr, 3,
     &   neighbour(PSouth))

        call shmem_get(FIELD(x_size*(y_size-1)+1),
     &   REMOTE_FIELD(remote_x_size+1),
     &   x_size,neighbour(PSouth))

      ENDIF
