forked from NASA-LIS/LISF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompute_grid_coord_polar.F90
137 lines (123 loc) · 3.88 KB
/
compute_grid_coord_polar.F90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
!-----------------------BEGIN NOTICE -- DO NOT EDIT-----------------------
! NASA Goddard Space Flight Center
! Land Information System Framework (LISF)
! Version 7.4
!
! Copyright (c) 2022 United States Government as represented by the
! Administrator of the National Aeronautics and Space Administration.
! All Rights Reserved.
!-------------------------END NOTICE -- DO NOT EDIT-----------------------
!BOP
!
! !ROUTINE: compute_grid_coord_polar
! \label{compute_grid_coord_polar}
!
! !REVISION HISTORY:
! 04-10-96 Mark Iredell; Initial Specification
! 07-15-05 Sujay Kumar; Modified verision with floating point arithmetic.
! 07-25-06 Sujay Kumar; Updated version to include Map Utils routines
!
! !INTERFACE:
subroutine compute_grid_coord_polar(gridDesc,npts,fill,xpts,ypts,&
rlon,rlat,nret)
use map_utils
implicit none
! !ARGUMENTS:
real :: gridDesc(20)
integer :: npts
real :: fill
real :: xpts(npts),ypts(npts)
real :: rlat(npts)
real :: rlon(npts)
integer :: nret
! !DESCRIPTION:
! This subroutine computes the grid coordinates of
! the specified domain for a polar stereographic projection.
! This routine is based on the grid
! decoding routines in the NCEP interoplation package.
!
! \begin{description}
! \item[gridDesc]
! grid description parameters
! \item[npts]
! integer maximum number of coordinates
! \item[fill]
! fill value to set invalid output data
! \item[xpts]
! output grid x point coordinates
! \item[ypts]
! output grid y point coordinates
! \item[rlat]
! input latitudes in degrees
! \item[rlon]
! input longitudes in degrees
! \end{description}
!
! The routines invoked are:
! \begin{description}
! \item[latlonTopolar](\ref{latlonTopolar}) \newline
! Converts lat, lons to polar coordinates
! \item[map\_set](\ref{map_set}) \newline
! Determines projection type for grid structure fill
! \item[latlon\_to\_ij](\ref{latlon_to_ij}) \newline
! Converts the input lat/lon values to the Cartesian
! (i,j) value for the projection type.
! \end{description}
!EOP
!- Using Map Utils routines to obtain the grid structure
! and the grid xpts and ypts information
type(proj_info) :: proj
integer :: i
real, parameter:: RERTH=6.3712E3
real, parameter:: PI=3.14159265358979,DPR=180./PI
integer :: im, jm,n
real :: rlat1,rlon1,dx,dy,orient,h
real :: xmin,xmax,ymin,ymax
real :: xr,yr
if(griddesc(1).eq.5) then
if(gridDesc(13).ne.1 ) then
call map_set(PROJ_PS,gridDesc(4),gridDesc(5),&
gridDesc(8)*1000,gridDesc(11),gridDesc(10),0.0,&
nint(gridDesc(2)),nint(gridDesc(3)),proj)
do i=1,npts
call latlon_to_ij(proj,rlat(i),rlon(i),xpts(i),ypts(i))
enddo
elseif(gridDesc(13).eq.1) then
im=gridDesc(2)
jm=gridDesc(3)
rlat1=gridDesc(4)
rlon1=gridDesc(5)
orient=gridDesc(7)
dx=gridDesc(8)
dy=gridDesc(9)
if(gridDesc(10).eq.0) then
h = 1.0
else
h = -1.0
endif
xmin=0
xmax=im+1
ymin=0
ymax=jm+1
nret=0
do n=1,npts
if(abs(rlon(n)).le.360.and.abs(rlat(n)).le.90.and.&
h*rlat(n).ne.-90) then
call latlonTopolar(rlat(n),rlon(n),dx,orient,xr,yr)
xpts(n) = xr+(xmax-1)/2+1
ypts(n) = yr+(ymax-1)/2+1
if(xpts(n).ge.xmin.and.xpts(n).le.xmax.and. &
ypts(n).ge.ymin.and.ypts(n).le.ymax) then
nret=nret+1
else
xpts(n)=fill
ypts(n)=fill
endif
else
xpts(n)=fill
ypts(n)=fill
endif
enddo
endif
endif
end subroutine compute_grid_coord_polar