source: branches/jerome/src_flexwrf_v3.1/centerofmass.f90 @ 16

Last change on this file since 16 was 16, checked in by jebri, 10 years ago

sources for flexwrf v3.1

File size: 4.4 KB
Line 
1!***********************************************************************
2!* Copyright 2012,2013                                                *
3!* Jerome Brioude, Delia Arnold, Andreas Stohl, Wayne Angevine,       *
4!* John Burkhart, Massimo Cassiani, Adam Dingwell, Richard C Easter, Sabine Eckhardt,*
5!* Stephanie Evan, Jerome D Fast, Don Morton, Ignacio Pisso,          *
6!* Petra Seibert, Gerard Wotawa, Caroline Forster, Harald Sodemann,   *
7!* This file is part of FLEXPART WRF                                   *
8!*                                                                     *
9!* FLEXPART is free software: you can redistribute it and/or modify    *
10!* it under the terms of the GNU General Public License as published by*
11!* the Free Software Foundation, either version 3 of the License, or   *
12!* (at your option) any later version.                                 *
13!*                                                                     *
14!* FLEXPART is distributed in the hope that it will be useful,         *
15!* but WITHOUT ANY WARRANTY; without even the implied warranty of      *
16!* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the       *
17!* GNU General Public License for more details.                        *
18!*                                                                     *
19!* You should have received a copy of the GNU General Public License   *
20!* along with FLEXPART.  If not, see <http://www.gnu.org/licenses/>.   *
21!***********************************************************************
22      subroutine centerofmass(xl,yl,n,xcenter,ycenter)
23!                             i  i  i    o       o
24!*******************************************************************************
25!                                                                              *
26!     Note:  This is the FLEXPART_WRF version of subroutine assignland.        *
27!            The computational grid is the WRF x-y grid rather than lat-lon.   *
28!                                                                              *
29!   This routine calculates the center of mass of n points on the Earth.       *
30!   Input are the longitudes (xl) and latitudes (yl) of the individual         *
31!   points, output is the longitude and latitude of the centre of mass.        *
32!                                                                              *
33!     Author: A. Stohl                                                         *
34!                                                                              *
35!     24 January 2002                                                          *
36!                                                                              *
37!    26 Oct 2005, R. Easter - changes associated with WRF horizontal grid.     *
38!                             Since x & y coords are in meters,                *
39!                             so just sum/average the xl & yl.                 *
40!                                                                              *
41!*******************************************************************************
42
43  use par_mod
44
45  implicit none
46
47  integer :: n,l
48  real :: xl(n),yl(n),xll,yll,xav,yav,zav,x,y,z,xcenter,ycenter
49
50
51  xav=0.
52  yav=0.
53  zav=0.
54
55  do l=1,n
56
57! Convert longitude and latitude from degrees to radians
58!*******************************************************
59
60! for FLEXPART_WRF, x & y coords are in meters,
61! so just sum/average the xl & yl
62!       xll=xl(l)*pi180
63!       yll=yl(l)*pi180
64
65! Calculate 3D coordinates from longitude and latitude
66!*****************************************************
67
68! for FLEXPART_WRF, this isn't necessary
69!       x = cos(yll)*sin(xll)
70!       y = -1.*cos(yll)*cos(xll)
71!       z = sin(yll)
72
73
74! Find the mean location in Cartesian coordinates
75!************************************************
76
77!       xav=xav+x
78!       yav=yav+y
79!       zav=zav+z
80        xav=xav+xl(l)
81        yav=yav+yl(l)
82
83    enddo
84
85      xav=xav/real(n)
86      yav=yav/real(n)
87!     zav=zav/float(n)
88
89
90! Project the point back onto Earth's surface
91!********************************************
92
93! for FLEXPART_WRF, this isn't necessary
94!     xcenter=atan2(xav,-1.*yav)
95!     ycenter=atan2(zav,sqrt(xav*xav+yav*yav))
96
97! Convert back to degrees
98!************************
99
100! for FLEXPART_WRF, this isn't necessary
101!     xcenter=xcenter/pi180
102!     ycenter=ycenter/pi180
103      xcenter=xav
104      ycenter=yav
105
106end subroutine centerofmass
107
Note: See TracBrowser for help on using the repository browser.
hosted by ZAMG