00001 !
00002 ! $Id: exchange_2d_tile.h,v 1.2 2003/12/17 13:56:01 pmarches Exp $
00003 !
00004 subroutine exchange_2d_tile (Istr,Iend,Jstr,Jend, A)
00005 !
00006 ! Set periodic boundary conditions (if any) for a two-dimensional
00007 ! field A of ZETA-, U-, V- or PSI-type. This file is designed to
00008 ! generate four different subroutines, by redefining (via CPP) the
00009 ! name of the subroutine exchange_2d_tile above and the starting
00010 ! indices ISTART = [Istr for U-,PSI-type; IstrR for V-,ZETA-type]
00011 ! and JSTART = [Jstr for V-,PSI-type; JstrR for U-,ZETA-type]
00012 ! below. See also mounting file exchange.F
00013 !
00014 implicit none
00015 #include "param.h"
00016 #include "scalars.h"
00017 real A(GLOBAL_2D_ARRAY)
00018 integer Istr,Iend,Jstr,Jend, i,j
00019 !
00020 #include "compute_auxiliary_bounds.h"
00021 !
00022
00023 #ifdef EW_PERIODIC
00024 # ifdef NS_PERIODIC
00025 # define J_RANGE Jstr,Jend
00026 # else
00027 # define J_RANGE JSTART,JendR
00028 # endif
00029 # ifdef MPI
00030 if (NP_XI.eq.1) then
00031 # endif
00032 if (WESTERN_EDGE) then
00033 do j=J_RANGE
00034 A(Lm+1,j)=A(1,j)
00035 A(Lm+2,j)=A(2,j)
00036 enddo
00037 endif
00038 if (EASTERN_EDGE) then
00039 do j=J_RANGE
00040 A(-1,j)=A(Lm-1,j)
00041 A( 0,j)=A(Lm ,j)
00042 enddo
00043 endif
00044 # ifdef MPI
00045 endif
00046 # endif
00047 # undef J_RANGE
00048 #endif
00049
00050 #ifdef NS_PERIODIC
00051 # ifdef EW_PERIODIC
00052 # define I_RANGE Istr,Iend
00053 # else
00054 # define I_RANGE ISTART,IendR
00055 # endif
00056 # ifdef MPI
00057 if (NP_ETA.eq.1) then
00058 # endif
00059 if (SOUTHERN_EDGE) then
00060 do i=I_RANGE
00061 A(i,Mm+1)=A(i,1)
00062 A(i,Mm+2)=A(i,2)
00063 enddo
00064 endif
00065 if (NORTHERN_EDGE) then
00066 do i=I_RANGE
00067 A(i,-1)=A(i,Mm-1)
00068 A(i, 0)=A(i,Mm )
00069 enddo
00070 endif
00071 # ifdef MPI
00072 endif
00073 # endif
00074 # undef I_RANGE
00075 #endif
00076
00077 #if defined EW_PERIODIC && defined NS_PERIODIC
00078 # ifdef MPI
00079 if (NP_XI.eq.1 .and. NP_ETA.eq.1) then
00080 # endif
00081 if (WESTERN_EDGE .and. SOUTHERN_EDGE) then
00082 A(Lm+1,Mm+1)=A(1,1)
00083 A(Lm+1,Mm+2)=A(1,2)
00084 A(Lm+2,Mm+1)=A(2,1)
00085 A(Lm+2,Mm+2)=A(2,2)
00086 endif
00087 if (EASTERN_EDGE .and. SOUTHERN_EDGE) then
00088 A(-1,Mm+1)=A(Lm-1,1)
00089 A( 0,Mm+1)=A(Lm ,1)
00090 A(-1,Mm+2)=A(Lm-1,2)
00091 A( 0,Mm+2)=A(Lm ,2)
00092 endif
00093 if (WESTERN_EDGE .and. NORTHERN_EDGE) then
00094 A(Lm+1,-1)=A(1,Mm-1)
00095 A(Lm+1, 0)=A(1,Mm )
00096 A(Lm+2,-1)=A(2,Mm-1)
00097 A(Lm+2, 0)=A(2,Mm )
00098 endif
00099 if (EASTERN_EDGE .and. NORTHERN_EDGE) then
00100 A(-1,-1)=A(Lm-1,Mm-1)
00101 A( 0,-1)=A(Lm ,Mm-1)
00102 A(-1, 0)=A(Lm-1,Mm )
00103 A( 0, 0)=A(Lm ,Mm )
00104 endif
00105 # ifdef MPI
00106 endif
00107 # endif
00108 #endif
00109 #ifdef MPI
00110 call MessPass2D_tile (Istr,Iend,Jstr,Jend, A)
00111 #endif
00112 return
00113 end
00114
00115