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

Last change on this file since 1009 was 998, checked in by tnavarro, 11 years ago

a trick to compile testphys1d with debug option

File size: 2.7 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
27integer id2,idm1 ! a trick to compile testphys1d with debug option
28
29id2  = 2
30idm1 = iim-1
31
32! rearrange topography on a 2d array
33do j=2,jjm
34   ig0= 1+(j-2)*iim
35   do i=1,iim
36      topogrid(i,j)=geopot(ig0+i)/g
37      latigrid(i,j)=lati(ig0+i)
38      longgrid(i,j)=long(ig0+i)
39   enddo
40enddo
41!poles :
42topogrid(:,1) = geopot(1)/g
43latigrid(:,1) = lati(1)
44longgrid(:,1) = long(1)
45topogrid(:,jjm+1) = geopot(ngridmx)/g
46latigrid(:,jjm+1) = lati(ngridmx)
47longgrid(:,jjm+1) = long(ngridmx)
48
49
50
51! compute topography gradient
52! topogrid and rad are both in meters
53do j=2,jjm
54   do i=1,iim
55     gradx(i,j) = (topogrid(i,j+1) - topogrid(i,j-1)) / (latigrid(i,j+1)-latigrid(i,j-1))
56     gradx(i,j) = gradx(i,j) / rad
57   enddo
58   grady(1,j) = (topogrid(id2,j) - topogrid(iim,j)) / (2*pi+longgrid(id2,j)-longgrid(iim,j))
59   grady(1,j) = grady(1,j) / rad
60   grady(iim,j) = (topogrid(1,j) - topogrid(idm1,j)) / (2*pi+longgrid(1,j)-longgrid(idm1,j))
61   grady(iim,j) = grady(iim,j) / rad
62   do i=2,iim-1
63     grady(i,j) = (topogrid(i+1,j) - topogrid(i-1,j)) / (longgrid(i+1,j)-longgrid(i-1,j))
64     grady(i,j) = grady(i,j) / rad
65   enddo
66enddo
67! poles :
68gradx(:,1) = 0.
69grady(:,1) = 0.
70gradx(:,jjm+1) = 0.
71grady(:,jjm+1) = 0.
72
73
74
75! compute slope inclination and orientation :
76theta_sl(:) = 0.
77psi_sl(:)   = 0.
78do j=2,jjm
79   do i=1,iim
80   
81     ig0= 1+(j-2)*iim
82   
83     theta_val=atan(sqrt( (gradx(i,j))**2 + (grady(i,j))**2 ))
84     
85     psi_val=0.
86     if (gradx(i,j) .ne. 0.) psi_val= -pi/2. - atan(grady(i,j)/gradx(i,j))
87     if (gradx(i,j) .ge. 0.) psi_val= psi_val - pi
88     psi_val = 3*pi/2. - psi_val
89     psi_val = psi_val*180./pi
90     psi_val = MODULO(psi_val,360.)
91     
92     theta_sl(ig0+i) = theta_val
93     psi_sl(ig0+i)   = psi_val
94         
95   enddo
96enddo
97
98
99
100end subroutine getslopes
Note: See TracBrowser for help on using the repository browser.