1! Copyright (c) 2004, NVIDIA CORPORATION.  All rights reserved.
2!
3! Licensed under the Apache License, Version 2.0 (the "License");
4! you may not use this file except in compliance with the License.
5! You may obtain a copy of the License at
6!
7!     http://www.apache.org/licenses/LICENSE-2.0
8!
9! Unless required by applicable law or agreed to in writing, software
10! distributed under the License is distributed on an "AS IS" BASIS,
11! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12! See the License for the specific language governing permissions and
13! limitations under the License.
14!
15! test EOSHIFT and CSHIFT
16! one dimension out of two
17	program p
18	 implicit none
19	 integer, parameter :: N=5, M=6
20	 integer, dimension(N,M) :: src
21	 integer, dimension(N,M) :: eopc,eopv,cpc,cpv
22	 integer, dimension(N,M) :: eomc,eomv,cmc,cmv
23	 integer, dimension(N,M) :: eopcres,eopvres,cpcres,cpvres
24	 integer, dimension(N,M) :: eomcres,eomvres,cmcres,cmvres
25	 integer :: i,j,k
26        data eopcres/&
27        &   0,   0,   0,   0,   0,&
28        &   2,   3,   4,   5,   0,&
29        &   7,   8,   9,  10,   0,&
30        &  12,  13,  14,  15,   0,&
31        &  17,  18,  19,  20,   0,&
32        &  22,  23,  24,  25,   0/
33        data eopvres/&
34        &   0,   0,   0,   0,   0,&
35        &   2,   3,   4,   5,   0,&
36        &   7,   8,   9,  10,   0,&
37        &  12,  13,  14,  15,   0,&
38        &  17,  18,  19,  20,   0,&
39        &  22,  23,  24,  25,   0/
40        data eomcres/&
41        &   0,   0,   0,   0,   0,&
42        &   0,   1,   2,   3,   4,&
43        &   0,   6,   7,   8,   9,&
44        &   0,  11,  12,  13,  14,&
45        &   0,  16,  17,  18,  19,&
46        &   0,  21,  22,  23,  24/
47        data eomvres/&
48        &   0,   0,   0,   0,   0,&
49        &   0,   1,   2,   3,   4,&
50        &   0,   6,   7,   8,   9,&
51        &   0,  11,  12,  13,  14,&
52        &   0,  16,  17,  18,  19,&
53        &   0,  21,  22,  23,  24/
54        data  cpcres/&
55        &   0,   0,   0,   0,   0,&
56        &   2,   3,   4,   5,   1,&
57        &   7,   8,   9,  10,   6,&
58        &  12,  13,  14,  15,  11,&
59        &  17,  18,  19,  20,  16,&
60        &  22,  23,  24,  25,  21/
61        data  cpvres/&
62        &   0,   0,   0,   0,   0,&
63        &   2,   3,   4,   5,   1,&
64        &   7,   8,   9,  10,   6,&
65        &  12,  13,  14,  15,  11,&
66        &  17,  18,  19,  20,  16,&
67        &  22,  23,  24,  25,  21/
68        data  cmcres/&
69        &   0,   0,   0,   0,   0,&
70        &   5,   1,   2,   3,   4,&
71        &  10,   6,   7,   8,   9,&
72        &  15,  11,  12,  13,  14,&
73        &  20,  16,  17,  18,  19,&
74        &  25,  21,  22,  23,  24/
75        data  cmvres/&
76        &   0,   0,   0,   0,   0,&
77        &   5,   1,   2,   3,   4,&
78        &  10,   6,   7,   8,   9,&
79        &  15,  11,  12,  13,  14,&
80        &  20,  16,  17,  18,  19,&
81        &  25,  21,  22,  23,  24/
82	 logical,parameter :: doprint = .false.
83	 eopc = -10	! fill in with garbage
84	 eopv = -10
85	 eomc = -10
86	 eomv = -10
87	 cpc = -10
88	 cpv = -10
89	 cmc = -10
90	 cmv = -10
91	 call sub(j,k)	! j is positive, k is negative
92	 src=reshape((/(i,i=1,N*M)/),(/N,M/))	! initialize
93	 eopc=eoshift(eoshift(src,-1,dim=2), 1, dim=1)	! eoshift, positive, constant
94	 eopv=eoshift(eoshift(src,-1,dim=2), j, dim=1)	! eoshift, positive, variable
95	 eomc=eoshift(eoshift(src,-1,dim=2),-1, dim=1)	! eoshift, negative, constant
96	 eomv=eoshift(eoshift(src,-1,dim=2), k, dim=1)	! eoshift, negative, variable
97	  cpc= cshift(eoshift(src,-1,dim=2), 1, dim=1)	!  cshift, positive, constant
98	  cpv= cshift(eoshift(src,-1,dim=2), j, dim=1)	!  cshift, positive, variable
99	  cmc= cshift(eoshift(src,-1,dim=2),-1, dim=1)	!  cshift, negative, constant
100	  cmv= cshift(eoshift(src,-1,dim=2), k, dim=1)	!  cshift, negative, variable
101	 if( doprint )then
102	  print 10, ' src',src
103	  print 10, 'eopc',eopc
104	  print 10, 'eopv',eopv
105	  print 10, 'eomc',eomc
106	  print 10, 'eomv',eomv
107	  print 10, ' cpc', cpc
108	  print 10, ' cpv', cpv
109	  print 10, ' cmc', cmc
110	  print 10, ' cmv', cmv
11110	  format('        data ',a,'res/&'/'        &',5(5(i4,','),'&'/'        &'),&
112		& 4(i4,','),i4,'/')
113	 else
114	  call check(eopc,eopcres,N*M)
115	  call check(eopv,eopvres,N*M)
116	  call check(eomc,eomcres,N*M)
117	  call check(eomv,eomvres,N*M)
118	  call check(cpc,cpcres,N*M)
119	  call check(cpv,cpvres,N*M)
120	  call check(cmc,cmcres,N*M)
121	  call check(cmv,cmvres,N*M)
122	 endif
123	end
124	subroutine sub(j,k)
125	 j = 1
126	 k = -1
127	end
128