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

Last change on this file since 1047 was 1047, checked in by emillour, 11 years ago

Mars GCM:

  • IMPORTANT CHANGE: Removed all reference/use of ngridmx (dimphys.h) in routines (necessary prerequisite to using parallel dynamics); in most cases this just means adding 'ngrid' as routine argument, and making local saved variables allocatable (and allocated at first call). In the process, had to convert many *.h files to equivalent modules: yomaer.h => yomaer_h.F90 , surfdat.h => surfdat_h.F90 , comsaison.h => comsaison_h.F90 , yomlw.h => yomlw_h.F90 , comdiurn.h => comdiurn_h.F90 , dimradmars.h => dimradmars_mod.F90 , comgeomfi.h => comgeomfi_h.F90, comsoil.h => comsoil_h.F90 , slope.h => slope_mod.F90
  • Also updated EOF routines, everything is now in eofdump_mod.F90
  • Removed unused routine lectfux.F (in dyn3d)

EM

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