source: branches/GRISLIv3/SOURCES/slope_surf.f90 @ 483

Last change on this file since 483 was 467, checked in by aquiquet, 5 months ago

Cleaning branch: continuing module3D cleaning

File size: 2.7 KB
Line 
1!> \file slope_surf.f90
2!!  File to compute the surface slope by finite difference
3!<
4
5!> SUBROUTINE:  slope_surf
6!! Compute the surface slope by finite difference
7!! \author Catritz
8!! \date ...
9!! @note Used module
10!! @note   - use module3D_phy
11!<
12
13subroutine slope_surf
14
15  use module3D_phy, only: sdx,sdy,S,slope,slope2mx,slope2my,debug_3D
16  use geography, only: nx,ny,dx,dy
17  !$ USE OMP_LIB
18 
19  implicit none
20
21  real,dimension(nx,ny) :: SDXMY        !< slope selon x moy selon y '^' remplace SDMX
22  real,dimension(nx,ny) :: SDYMX        !< slope selon y moy selon x '>' remplace SDMY
23
24  real :: inv_4dx        ! inverse de dx pour eviter les divisions =1/(4*dx)
25  integer :: i,j
26
27  inv_4dx = 1./(4.*dx)
28
29
30  !$OMP PARALLEL
31  !$OMP DO
32  do j=1,ny                                 ! slope along x on node >
33     do i=2,nx
34        sdx(i,j)=(s(i,j)-s(i-1,j))/dx
35     end do
36  end do
37  !$OMP END DO
38
39  !$OMP DO
40  do j=2,ny                                 ! slope along y on node ^
41     do i=1,nx
42        sdy(i,j)=(s(i,j)-s(i,j-1))/dy
43     end do
44  end do
45  !$OMP END DO
46
47  !$OMP DO
48  do j=2,ny-1                               ! slope amplitude on node o
49     do i=2,nx-1
50        slope(i,j)=(s(i+1,j)-s(i-1,j))**2 + (s(i,j+1)-s(i,j-1))**2
51        slope(i,j)=slope(i,j)**0.5 / dx /2.
52     end do
53  end do
54  !$OMP END DO
55 
56  !$OMP DO
57  do j=2,ny                                 ! slope along x on node ^ (average)
58     do i=2,nx-1
59        sdxmy(i,j)= ((s(i+1,j)-s(i-1,j))+s(i+1,j-1)-s(i-1,j-1))*inv_4dx
60     end do
61  end do
62  !$OMP END DO
63
64  !$OMP DO
65  do j=2,ny-1                               ! slope along y on node > (average)
66     do i=2,nx
67        sdymx(i,j)= ((s(i,j+1)-s(i,j-1))+s(i-1,j+1)-s(i-1,j-1))*inv_4dx
68     enddo
69  enddo
70  !$OMP END DO
71
72  !$OMP WORKSHARE
73  slope2mx(:,:)=sdx(:,:)**2+sdymx(:,:)**2   ! slope amplitude on node  >
74  slope2my(:,:)=sdy(:,:)**2+sdxmy(:,:)**2   ! slope amplitude on node  ^
75
76  ! conditions on the grid boundaries
77
78  slope(1,:)    =  0.
79  slope(:,1)    =  0.
80  slope(nx,:)   =  0.
81  slope(:,ny)   =  0.
82
83  slope2mx(1,:) =  0.
84  slope2mx(:,1) =  0.
85  slope2mx(:,ny) = 0.
86
87  slope2my(1,:) =  0.
88  slope2my(:,1) =  0.
89  slope2my(nx,:) = 0.
90
91
92  ! limitation to 2e-2
93  sdx(:,:)=max(sdx(:,:),-2.e-2)
94  sdx(:,:)=min(sdx(:,:),2.e-2)
95  sdxmy(:,:)=max(sdxmy(:,:),-2.e-2)
96  sdxmy(:,:)=min(sdxmy(:,:),2.e-2)
97  slope2mx(:,:)=min(slope2mx(:,:),4.e-4)
98
99  sdy(:,:)=max(sdy(:,:),-2.e-2)
100  sdy(:,:)=min(sdy(:,:),2.e-2)
101  sdymx(:,:)=max(sdymx(:,:),-2.e-2)
102  sdymx(:,:)=min(sdymx(:,:),2.e-2)
103  slope2my(:,:)=min(slope2my(:,:),4.e-4)
104
105  slope(:,:)=min(slope(:,:),2.e-2)
106
107
108  debug_3D(:,:,21)=sdx(:,:)
109  debug_3D(:,:,22)=sdy(:,:)
110  !$OMP END WORKSHARE
111  !$OMP END PARALLEL
112 
113end subroutine slope_surf
Note: See TracBrowser for help on using the repository browser.