Hello,
I have the following code which generates a 3-d grid between 0 and nmax (usually the three nmax's are around 100):
program Mesh
implicit none
integer, parameter :: npts=64
integer::ntot,n,n1,n2,n3,nmax(3), nstart(3),tmp(3),k(3,npts)
nmax(1)=4; nmax(2)=4; nmax(3)=4
nstart(1)=1; nstart(2)=1; nstart(3)=1
ntot=nmax(1)*nmax(2)*nmax(3)
do n1=nstart(1),nmax(1)
do n2=nstart(2),nmax(2)
do n3=nstart(3),nmax(3)
n=(n1-1)*nmax(2)*nmax(3)+(n2-1)*nmax(3)+n3
k(1,n)=n1-1
k(2,n)=n2-1
k(3,n)=n3-1
enddo
enddo
enddo
do n=1,ntot
print*, n, k(1,n), k(2,n), k(3,n)
enddo
END
The printout for the first 10 lines is:
1 0 0 0
2 0 0 1
3 0 0 2
4 0 0 3
5 0 1 0
6 0 1 1
7 0 1 2
8 0 1 3
9 0 2 0
10 0 2 1
What I need to print out is:
1 0 0 0
2 0 0 1
3 0 0 2
4 0 0 3
5 0 1 3
6 0 1 2
7 0 1 1
8 0 1 0
9 0 2 0
10 0 2 1
Here, the last column shows a continuous increase and then decrease so the numbers change smoothly. I would need to apply this change for columns 2 to 4.
I would appreciate any hints as to how to make this change.
Thank you,
Vahid
I have the following code which generates a 3-d grid between 0 and nmax (usually the three nmax's are around 100):
program Mesh
implicit none
integer, parameter :: npts=64
integer::ntot,n,n1,n2,n3,nmax(3), nstart(3),tmp(3),k(3,npts)
nmax(1)=4; nmax(2)=4; nmax(3)=4
nstart(1)=1; nstart(2)=1; nstart(3)=1
ntot=nmax(1)*nmax(2)*nmax(3)
do n1=nstart(1),nmax(1)
do n2=nstart(2),nmax(2)
do n3=nstart(3),nmax(3)
n=(n1-1)*nmax(2)*nmax(3)+(n2-1)*nmax(3)+n3
k(1,n)=n1-1
k(2,n)=n2-1
k(3,n)=n3-1
enddo
enddo
enddo
do n=1,ntot
print*, n, k(1,n), k(2,n), k(3,n)
enddo
END
The printout for the first 10 lines is:
1 0 0 0
2 0 0 1
3 0 0 2
4 0 0 3
5 0 1 0
6 0 1 1
7 0 1 2
8 0 1 3
9 0 2 0
10 0 2 1
What I need to print out is:
1 0 0 0
2 0 0 1
3 0 0 2
4 0 0 3
5 0 1 3
6 0 1 2
7 0 1 1
8 0 1 0
9 0 2 0
10 0 2 1
Here, the last column shows a continuous increase and then decrease so the numbers change smoothly. I would need to apply this change for columns 2 to 4.
I would appreciate any hints as to how to make this change.
Thank you,
Vahid