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

Last change on this file since 1266 was 1266, checked in by aslmd, 11 years ago

LMDZ.MARS
IMPORTANT CHANGE

  • Remove all reference/use of nlayermx and dimphys.h
  • Made use of automatic arrays whenever arrays are needed with dimension nlayer
  • Remove lots of obsolete reference to dimensions.h
  • Converted iono.h and param_v4.h into corresponding modules

(with embedded subroutine to allocate arrays)
(no arrays allocated if thermosphere not used)

  • Deleted param.h and put contents into module param_v4_h
  • Adapted testphys1d, newstart, etc...
  • Made DATA arrays in param_read to be initialized by subroutine

fill_data_thermos in module param_v4_h

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