OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
global_model_grids.f90
Go to the documentation of this file.
2 
3  implicit none
4 
5  real :: ice_grid( 0:719, 0:359, 1)
6  real :: ozn_grid(0:359, 0:180, 1)
7 
8 
9  logical :: grids_are_read
10  logical :: icec_is_read
11  logical :: nise_is_read
12  logical :: snow_stats_are_read = .false.
13 
15 
16  real, dimension(:), allocatable :: mixr_profile
17  real, dimension(:), allocatable :: temp_profile
18  real, dimension(:), allocatable :: height_profile
19  real, dimension(:), allocatable :: pressure_profile
20  real, dimension(:), allocatable :: o3_profile
21 
22 
23  real :: wind_speed
24  real :: ts
25  real :: ps
26  real :: col_o3
27 
28  real :: seaice_fraction
29  real :: snow_fraction
30 
31  integer*1 :: surface_level
32  integer*1 :: trop_level
33  integer*1 :: lsm
34 
35  end type ancillary_type
36 
37 contains
38 
39  subroutine get_model_idx(lat, lon, i, j)
40 
41 
42  real, intent(in) :: lat, lon
43  integer, intent(inout ) :: i,j
44 
45  real :: x,y, x0, dx, y0, dy
46 
47  x = min( max( lon, -179.99 ), 179.99 )
48  if( x > -999. .and. x < 0.0 ) x = lon+ 360.0
49  x0 = 0.0
50  dx = 1.0
51  i = int( ( x - x0 + 0.5*dx ) / dx )
52 
53  if( i .eq. 360 ) i = 0
54 
55  y = min( max( lat, -89.99 ), 89.99 )
56  y0 = 90.0
57  dy = -1.0
58  j = int( ( y - y0 + 0.5*dy ) / dy )
59 
60  i = i+1
61  j = j+1
62 
63 
64  end subroutine get_model_idx
65 
66 
67  subroutine get_model_idx_geos5(grid_xstart, grid_ystart, lat, lon, model_i, model_j)
68 
69  integer, intent(in) :: grid_xstart, grid_ystart
70  real, intent(in) :: lat, lon
71  integer, intent(inout) :: model_i, model_j
72 
73  real :: minLat, maxLat, minLon, maxLon
74  real, parameter :: dlon = 0.625 ! 5/8
75  real, parameter :: dlat = 0.5
76 
77  model_i = int((lon + 180) / dlon ) - grid_xstart
78  model_j = int((lat + 90) / dlat + 1 ) - grid_ystart
79 
80  if (model_i < 1) model_i = 1
81  if (model_j < 1) model_j = 1
82 
83  end subroutine get_model_idx_geos5
84 
85  subroutine find_geos5_bounds(istart, iend, jstart, jend, lat, lon)
86 
87  integer, intent(inout) :: istart, iend, jstart, jend
88  real, dimension(:,:), intent(in) :: lat, lon
89 
90  real :: minLat, maxLat, minLon, maxLon
91  real, parameter :: dlon = 5./8.
92  real, parameter :: dlat = 0.5
93 
94 
95  minlat = minval( lat, mask = ( (lat >= -90.0000 .and. lat <= 90.00000) ) )
96  maxlat = maxval( lat, mask = ( (lat >= -90.0000 .and. lat <= 90.00000) ) )
97 
98  minlon = minval( lon, mask = ( (lon >= -180.000 .and. lon <= 180.0000) ) )
99  maxlon = maxval( lon, mask = ( (lon >= -180.000 .and. lon <= 180.0000) ) )
100 
101  istart = int((minlon + 180) / dlon )
102  if (istart < 0) istart = 0
103  iend = int((maxlon + 180) / dlon )
104  if (iend > (360/dlon-1)) iend = 360/dlon - 1
105 
106  jstart = int((minlat + 90) / dlat )
107  jend = int((maxlat + 90) / dlat )
108 
109 
110  end subroutine find_geos5_bounds
111 
112  real function get_W(RH, T, P)
113 
114 ! After Rogers and Yau.
115 
116  real*8, intent(in) :: rh, t, p
117 
118  real, parameter :: c = 4187.
119  real, parameter :: cpv = 1870.
120  real, parameter :: l0 = 2.501e6
121  real, parameter :: t0 = 273.
122 
123  real :: l
124  real :: esat
125  real :: ws
126  real :: w
127 
128  if (t < 235.) then
129  l = 2.83e6 ! latent heat of ice, doesn't change very much
130  else
131  l = l0 - (c - cpv) * (t - t0) ! latent heat of water
132  endif
133 
134  esat = 6.11657*exp((l/461.51)*(1/273. - 1/t) ) ! saturation vapor pressure in mb
135 
136  ws = esat * 0.622 / (p - esat) ! saturation mixing ratio in kg/kg
137 
138  w = rh / 100. * ws ! mixing ratio in kg/kg
139 
140  get_w = w * 1000. ! mixing ratio in g/kg
141 
142 
143 
144  end function get_w
145 
146 
147 
148 end module global_model_grids
subroutine get_model_idx_geos5(grid_xstart, grid_ystart, lat, lon, model_i, model_j)
subroutine get_model_idx(lat, lon, i, j)
real, dimension(0:359, 0:180, 1) ozn_grid
#define real
Definition: DbAlgOcean.cpp:26
subroutine find_geos5_bounds(istart, iend, jstart, jend, lat, lon)
#define max(A, B)
Definition: main_biosmap.c:61
#define min(A, B)
Definition: main_biosmap.c:62
real, dimension(0:719, 0:359, 1) ice_grid
real function get_w(RH, T, P)