source: trunk/LMDZ.MARS/libf/phymars/getslopes.F90 @ 937

Last change on this file since 937 was 900, checked in by tnavarro, 12 years ago

added possibility to use the radiative slope scheme in the 3D-GCM

File size: 2.6 KB
Line 
1subroutine getslopes(geopot)
2   
3implicit none
4
5#include "dimensions.h"
6#include "dimphys.h"
7#include "slope.h"
8#include "comgeomfi.h"
9#include "comcstfi.h"
10
11
12! This routine computes slope inclination and orientation for the GCM (callslope=.true. in callphys.def)
13! It works fine with a non-regular grid for zoomed simulations.
14! slope inclination angle (deg)  0 == horizontal, 90 == vertical
15! slope orientation angle (deg)  0 == Northward,  90 == Eastward, 180 == Southward, 270 == Westward
16! TN 04/1013
17
18
19real geopot(ngridmx)     ! geopotential on phy grid
20real topogrid(iim,jjm+1) ! topography on lat/lon grid with poles and only one -180/180 point
21real latigrid(iim,jjm+1),longgrid(iim,jjm+1) ! meshgrid of latitude and longitude values (radians)
22real theta_val ! slope inclination
23real psi_val   ! slope orientation
24real gradx(iim,jjm+1) ! x: latitude-wise topography gradient,  increasing northward
25real grady(iim,jjm+1) ! y: longitude-wise topography gradient, increasing westward
26integer i,j,ig0
27
28
29! rearrange topography on a 2d array
30do j=2,jjm
31   ig0= 1+(j-2)*iim
32   do i=1,iim
33      topogrid(i,j)=geopot(ig0+i)/g
34      latigrid(i,j)=lati(ig0+i)
35      longgrid(i,j)=long(ig0+i)
36   enddo
37enddo
38!poles :
39topogrid(:,1) = geopot(1)/g
40latigrid(:,1) = lati(1)
41longgrid(:,1) = long(1)
42topogrid(:,jjm+1) = geopot(ngridmx)/g
43latigrid(:,jjm+1) = lati(ngridmx)
44longgrid(:,jjm+1) = long(ngridmx)
45
46
47
48! compute topography gradient
49! topogrid and rad are both in meters
50do j=2,jjm
51   do i=1,iim
52     gradx(i,j) = (topogrid(i,j+1) - topogrid(i,j-1)) / (latigrid(i,j+1)-latigrid(i,j-1))
53     gradx(i,j) = gradx(i,j) / rad
54   enddo
55   grady(1,j) = (topogrid(2,j) - topogrid(iim,j)) / (2*pi+longgrid(2,j)-longgrid(iim,j))
56   grady(1,j) = grady(1,j) / rad
57   grady(iim,j) = (topogrid(1,j) - topogrid(iim-1,j)) / (2*pi+longgrid(1,j)-longgrid(iim-1,j))
58   grady(iim,j) = grady(iim,j) / rad
59   do i=2,iim-1
60     grady(i,j) = (topogrid(i+1,j) - topogrid(i-1,j)) / (longgrid(i+1,j)-longgrid(i-1,j))
61     grady(i,j) = grady(i,j) / rad
62   enddo
63enddo
64! poles :
65gradx(:,1) = 0.
66grady(:,1) = 0.
67gradx(:,jjm+1) = 0.
68grady(:,jjm+1) = 0.
69
70
71
72! compute slope inclination and orientation :
73theta_sl(:) = 0.
74psi_sl(:)   = 0.
75do j=2,jjm
76   do i=1,iim
77   
78     ig0= 1+(j-2)*iim
79   
80     theta_val=atan(sqrt( (gradx(i,j))**2 + (grady(i,j))**2 ))
81     
82     psi_val=0.
83     if (gradx(i,j) .ne. 0.) psi_val= -pi/2. - atan(grady(i,j)/gradx(i,j))
84     if (gradx(i,j) .ge. 0.) psi_val= psi_val - pi
85     psi_val = 3*pi/2. - psi_val
86     psi_val = psi_val*180./pi
87     psi_val = MODULO(psi_val,360.)
88     
89     theta_sl(ig0+i) = theta_val
90     psi_sl(ig0+i)   = psi_val
91         
92   enddo
93enddo
94
95
96
97end subroutine getslopes
Note: See TracBrowser for help on using the repository browser.