Changeset 153 for codes/icosagcm/trunk/src/spherical_geom.f90
- Timestamp:
- 05/17/13 18:21:50 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
codes/icosagcm/trunk/src/spherical_geom.f90
r15 r153 34 34 35 35 lat=asin(xyzn(3)) 36 coslat=cos(lat) 37 IF (abs(coslat)<1e-15) THEN 38 lon=0. 39 ELSE 40 lon=acos(MAX(MIN((xyzn(1)/coslat),1.),-1.)) 41 IF (xyzn(2)/coslat<0) lon=-lon 42 ENDIF 43 36 lon=atan2(xyzn(2),xyzn(1)) 44 37 END SUBROUTINE xyz2lonlat 38 39 ! lat/lon with respect to a displaced pole (rotated basis) : 40 ! ( cos(lon0)*sin(lat0), sin(lon0)*sin(lat0), -cos(lat0)) 41 ! (-sin(lon0), cos(lon0), 0) 42 ! ( cos(lon0)*cos(lat0), sin(lon0)*cos(lat0), sin(lat0)) 43 44 SUBROUTINE lonlat2xyz_relative(lon,lat,lon0,lat0, xyz) 45 IMPLICIT NONE 46 REAL(rstd),INTENT(IN) :: lon0, lat0, lon,lat 47 REAL(rstd),INTENT(OUT) :: xyz(3) 48 REAL(rstd) :: xx,yy,zz 49 xx = cos(lon)*cos(lat) 50 yy = sin(lon)*cos(lat) 51 zz = sin(lat) 52 xyz(1) = cos(lon0)*(sin(lat0)*xx+cos(lat0)*zz)-sin(lon0)*yy 53 xyz(2) = sin(lon0)*(sin(lat0)*yy+cos(lat0)*zz)+cos(lon0)*yy 54 xyz(3) = sin(lat0)*zz-cos(lat0)*xx 55 END SUBROUTINE lonlat2xyz_relative 56 57 SUBROUTINE xyz2lonlat_relative(xyz,lon0,lat0, lon,lat) 58 IMPLICIT NONE 59 REAL(rstd),INTENT(IN) :: xyz(3), lon0, lat0 60 REAL(rstd),INTENT(OUT) :: lon,lat 61 REAL(rstd) :: xx,yy,zz 62 xx = sin(lat0)*(xyz(1)*cos(lon0)+xyz(2)*sin(lon0))-cos(lat0)*xyz(3) 63 yy = xyz(2)*cos(lon0)-xyz(1)*sin(lon0) 64 zz = cos(lat0)*(xyz(1)*cos(lon0)+xyz(2)*sin(lon0))+sin(lat0)*xyz(3) 65 lon = atan2(yy,xx) 66 lat = asin(zz) 67 END SUBROUTINE xyz2lonlat_relative 68 45 69 46 70
Note: See TracChangeset
for help on using the changeset viewer.