PROGRAM gradient
implicit none

! Declarations
integer i,j
integer,parameter :: im=3,jm=2

real, dimension(im,jm) :: champ
real, dimension(im,jm-1) :: grady
real :: dy=2.

! Initialisation du champ
do j=1,jm
   do i=1,im
      champ(i,j)=sqrt(j*(2.*j+i))
   enddo
enddo
print*,'Le champ dont ont prend le gradient'
write(*,'(3f10.2)'),champ(:,1)
write(*,'(3f10.2)'),champ(:,2)

! Premier calcul de gradient
do j=1,jm-1
   do i=1,im
      grady(i,j)=(champ(i,j+1)-champ(i,j))/dy
   enddo
enddo
print*,'premier calcul du gradient en y'
print*,grady

! Second calcul
do j=1,jm-1
   grady(:,j)=(champ(:,j+1)-champ(:,j))/dy
enddo
print*,'premier calcul du gradient en y'
print*,grady

! Troisieme calcul
grady(:,1:jm-1)=(champ(:,2:jm)-champ(:,1:jm-1))/dy
print*,'premier calcul du gradient en y'
print*,grady

end PROGRAM gradient
