60 '$Id: ODPS_CoordinateMapping.f90 60152 2015-08-13 19:19:13Z paul.vandelst@noaa.gov $' 156 Temperature, & ! Output
158 User_Level_LnPressure, & ! Output
159 Ref_Level_LnPressure, & ! Output
160 Secant_Zenith, & ! Output
166 REAL(fp) ,
INTENT(OUT) :: temperature(:)
167 REAL(fp) ,
INTENT(OUT) :: absorber(:,:)
168 REAL(fp) ,
INTENT(OUT) :: user_level_lnpressure(0:)
169 REAL(fp) ,
INTENT(OUT) :: ref_level_lnpressure(0:)
170 REAL(fp) ,
INTENT(OUT) :: secant_zenith(:)
171 INTEGER ,
INTENT(OUT) :: h2o_idx
175 REAL(fp) :: tolerance
177 REAL(fp) :: odps_sfc_fraction, z_offset, s
178 REAL(fp) :: z(0:tc%n_layers)
179 REAL(fp) :: acc_weighting(atm%n_layers, tc%n_layers)
180 INTEGER :: interp_index(2, tc%n_layers)
181 REAL(fp) :: ref_lnpressure(tc%n_layers)
182 REAL(fp) :: user_lnpressure(atm%n_layers)
183 REAL(fp) :: surface_altitude, sensor_zenith_radian
185 INTEGER :: idx_map(tc%n_absorbers)
186 INTEGER :: j, jj, k, n_odps_layers, n_user_layers, odps_sfc_idx
189 tolerance = epsilon(
one)
191 n_odps_layers = tc%n_Layers
192 n_user_layers = atm%n_layers
194 ref_lnpressure = log(tc%Ref_Pressure)
195 user_lnpressure = log(atm%Pressure(1:n_user_layers))
196 ref_level_lnpressure = log(tc%Ref_Level_Pressure)
197 IF(atm%Level_Pressure(0) <=
zero)
THEN 199 user_level_lnpressure(0) = log(atm%Level_Pressure(1)/
two)
201 user_level_lnpressure(0) = log(atm%Level_Pressure(0))
203 user_level_lnpressure(1:n_user_layers) = log(atm%Level_Pressure(1:n_user_layers))
208 odps_sfc_idx = n_odps_layers
209 odps_sfc_fraction =
zero 210 IF(tc%Ref_Level_Pressure(n_odps_layers) > atm%Level_Pressure(n_user_layers))
THEN 211 DO k = n_odps_layers, 0, -1
212 IF(tc%Ref_Level_Pressure(k) < atm%Level_Pressure(n_user_layers))
THEN 214 odps_sfc_fraction = (ref_level_lnpressure(odps_sfc_idx) - &
215 user_level_lnpressure(n_user_layers)) /&
216 (ref_level_lnpressure(odps_sfc_idx) - &
217 ref_level_lnpressure(k))
225 surface_altitude = surface_altitude, &
226 trans_zenith_radian = sensor_zenith_radian )
237 DO k = 1, n_odps_layers
238 temperature(k) = sum(acc_weighting(interp_index(1,k):interp_index(2,k), k) &
239 * atm%Temperature(interp_index(1,k):interp_index(2,k)) )
245 DO j = 1,tc%n_Absorbers
247 DO jj=1, atm%n_Absorbers
248 IF( atm%Absorber_ID(jj) == tc%Absorber_ID(j) )
THEN 256 IF(tc%Absorber_ID(j) ==
h2o_id)
THEN 259 IF(idx_map(j) > 0)
THEN 261 DO k = 1, n_odps_layers
262 absorber(k,j) = sum(acc_weighting(interp_index(1,k):interp_index(2,k), k) &
263 * atm%Absorber(interp_index(1,k):interp_index(2,k), idx_map(j)) )
266 DO k=1, n_odps_layers
268 IF (absorber(k,j) <= tolerance ) absorber(k,j) = tolerance
269 IF (absorber(k,j) < tc%Min_Absorber(k,j) ) absorber(k,j) = tc%Min_Absorber(k,j)
270 IF (absorber(k,j) > tc%Max_Absorber(k,j) ) absorber(k,j) = tc%Max_Absorber(k,j)
274 absorber(:, j) = tc%Ref_Absorber(:, j)
284 tc%Ref_Temperature, &
285 tc%Ref_Absorber(:, h2o_idx), &
291 IF(tc%Ref_Level_Pressure(n_odps_layers) >= atm%Level_Pressure(n_user_layers))
THEN 292 z_offset = -(z(odps_sfc_idx) + odps_sfc_fraction*(z(odps_sfc_idx-1)-z(odps_sfc_idx))) &
298 z_offset =
cc*tc%Ref_Temperature(n_odps_layers) &
299 *log(1013.0_fp / tc%Ref_Level_Pressure(n_odps_layers))
303 s = (
earth_radius + surface_altitude)*sin(sensor_zenith_radian)
305 DO k = 1, n_odps_layers
307 secant_zenith(k) =
one / sqrt(
one - sineang*sineang)
311 pafv%Temperature = temperature
312 pafv%Absorber = absorber
313 pafv%interp_index = interp_index
314 pafv%Acc_Weighting= acc_weighting
315 pafv%idx_map = idx_map
316 pafv%H2O_idx = h2o_idx
317 pafv%Ref_LnPressure = ref_lnpressure
318 pafv%User_LnPressure = user_lnpressure
376 Temperature_TL, & ! Output
377 Absorber_TL, & ! Output
381 REAL(fp) ,
INTENT(OUT) :: temperature_tl(:)
382 REAL(fp) ,
INTENT(OUT) :: absorber_tl(:,:)
386 REAL(fp) :: tolerance
388 INTEGER :: idx_map(tc%n_absorbers), h2o_idx
389 INTEGER :: j, k, n_odps_layers
392 tolerance = epsilon(
one)
394 n_odps_layers = tc%n_Layers
399 DO k = 1, n_odps_layers
400 temperature_tl(k) = &
401 sum(pafv%Acc_Weighting(pafv%interp_index(1,k):pafv%interp_index(2,k), k) &
402 * atm_tl%Temperature(pafv%interp_index(1,k):pafv%interp_index(2,k)) )
408 h2o_idx = pafv%H2O_idx
409 idx_map = pafv%Idx_map
411 DO j = 1,tc%n_Absorbers
412 IF(idx_map(j) > 0)
THEN 414 DO k = 1, n_odps_layers
416 sum(pafv%Acc_Weighting(pafv%interp_index(1,k):pafv%interp_index(2,k), k) &
417 * atm_tl%Absorber(pafv%interp_index(1,k):pafv%interp_index(2,k), idx_map(j)) )
420 DO k=1, n_odps_layers
421 IF(pafv%Absorber(k,j) <= tolerance ) absorber_tl(k,j) =
zero 425 absorber_tl(:, j) =
zero 483 Temperature_AD, & ! Input
484 Absorber_AD, & ! Input
489 REAL(fp) ,
INTENT(INOUT) :: temperature_ad(:)
490 REAL(fp) ,
INTENT(INOUT) :: absorber_ad(:,:)
495 REAL(fp) :: tolerance
497 INTEGER :: idx_map(tc%n_absorbers), h2o_idx
498 INTEGER :: j, k, n_odps_layers
501 tolerance = epsilon(
one)
507 n_odps_layers = tc%n_Layers
509 h2o_idx = pafv%H2O_idx
510 idx_map = pafv%Idx_map
515 DO j = tc%n_Absorbers, 1, -1
516 IF(idx_map(j) > 0)
THEN 518 DO k=1, n_odps_layers
519 IF(pafv%Absorber(k,j) <= tolerance ) absorber_ad(k,j) =
zero 522 DO k = n_odps_layers, 1, -1
523 atm_ad%Absorber(pafv%interp_index(1,k):pafv%interp_index(2,k), idx_map(j)) = &
524 atm_ad%Absorber(pafv%interp_index(1,k):pafv%interp_index(2,k), idx_map(j)) &
525 + pafv%Acc_Weighting(pafv%interp_index(1,k):pafv%interp_index(2,k), k) &
530 absorber_ad(:, j) =
zero 538 DO k = n_odps_layers, 1, -1
539 atm_ad%Temperature(pafv%interp_index(1,k):pafv%interp_index(2,k)) = &
540 atm_ad%Temperature(pafv%interp_index(1,k):pafv%interp_index(2,k)) &
541 + pafv%Acc_Weighting(pafv%interp_index(1,k):pafv%interp_index(2,k), k) &
546 temperature_ad =
zero 610 Temperature, & ! Input
611 Water_Vapor, & ! Input
612 Surface_Height, & ! input
616 REAL(fp),
INTENT(IN) :: Level_Pressure(0:)
617 REAL(fp),
INTENT(IN) :: Temperature(:)
618 REAL(fp),
INTENT(IN) :: Water_Vapor(:)
619 REAL(fp),
INTENT(IN) :: Surface_Height
620 REAL(fp),
INTENT(OUT) :: Level_Height(0:)
624 INTEGER :: k, n_Layers
626 n_layers =
SIZE(temperature)
627 level_height(n_layers) = surface_height
628 DO k = n_layers, 1, -1
631 tv = temperature(k)*(
one +
c*water_vapor(k))
633 level_height(k-1) = level_height(k) + h*log(level_pressure(k)/level_pressure(k-1))
707 INTEGER,
DIMENSION(:,:),
INTENT(IN) :: interp_index
708 REAL(fp),
DIMENSION(:),
INTENT(IN) :: y
709 REAL(fp),
DIMENSION(:),
INTENT(IN) :: x
710 REAL(fp),
DIMENSION(:),
INTENT(IN) :: u
711 REAL(fp),
DIMENSION(:),
INTENT(OUT) :: y_int
713 INTEGER :: i, n, k1, k2
715 n =
SIZE(interp_index, dim=2)
717 k1 = interp_index(1, i)
718 k2 = interp_index(2, i)
722 CALL interp_linear(y(k1), x(k1), y(k2), x(k2), u(i), y_int(i))
801 INTEGER,
DIMENSION(:,:),
INTENT(IN) :: interp_index
802 REAL(fp),
DIMENSION(:),
INTENT(IN) :: x
803 REAL(fp),
DIMENSION(:),
INTENT(IN) :: u
804 REAL(fp),
DIMENSION(:),
INTENT(IN) :: y_tl
805 REAL(fp),
DIMENSION(:),
INTENT(OUT) :: y_int_tl
807 INTEGER :: i, n, k1, k2
809 n =
SIZE(interp_index, dim=2)
811 k1 = interp_index(1, i)
812 k2 = interp_index(2, i)
814 y_int_tl(i) = y_tl(k1)
896 INTEGER,
DIMENSION(:,:),
INTENT(IN) :: interp_index
897 REAL(fp),
DIMENSION(:),
INTENT(IN) :: x
898 REAL(fp),
DIMENSION(:),
INTENT(IN) :: u
899 REAL(fp),
DIMENSION(:),
INTENT(IN OUT) :: y_int_ad
900 REAL(fp),
DIMENSION(:),
INTENT(IN OUT) :: y_ad
902 INTEGER :: i, n, k1, k2
904 n =
SIZE(interp_index, dim=2)
906 k1 = interp_index(1, i)
907 k2 = interp_index(2, i)
909 y_ad(k1) = y_ad(k1) + y_int_ad(i)
967 REAL(fp),
DIMENSION(:),
INTENT(IN) :: x
968 REAL(fp),
DIMENSION(:),
INTENT(IN) :: u
969 INTEGER,
DIMENSION(:,:),
INTENT(OUT) :: interp_index
971 INTEGER :: nx, nu, ix, iu, j, k1, k2
978 lessthan_loop:
DO iu = 1, nu
980 interp_index(1, iu) = 1
981 interp_index(2, iu) = 1
990 greaterthan_loop:
DO iu = nu, k1, -1
991 IF(u(iu) > x(nx))
THEN 992 interp_index(1, iu) = nx
993 interp_index(2, iu) = nx
996 EXIT greaterthan_loop
998 END DO greaterthan_loop
1003 outer_loop:
DO iu = k1, k2
1004 inner_loop:
DO ix = j, nx-1
1005 IF(u(iu) >= x(ix) .AND. u(iu) <= x(ix+1))
THEN 1006 interp_index(1, iu) = ix
1007 interp_index(2, iu) = ix+1
1021 REAL(fp),
INTENT(IN) :: y1, x1, y2, x2, x
1022 REAL(fp),
INTENT(OUT) :: y
1023 y = y1 + (y2-y1)*(x - x1)/(x2 - x1)
1028 REAL(fp),
INTENT(IN) :: x1, x2, x, y1_TL, y2_TL
1029 REAL(fp),
INTENT(OUT) :: y_TL
1030 y_tl = y1_tl + (y2_tl-y1_tl)*(x - x1)/(x2 - x1)
1035 REAL(fp),
INTENT(IN) :: x1, x2, x
1036 REAL(fp),
INTENT(IN OUT) :: y_AD
1037 REAL(fp),
INTENT(IN OUT) :: y1_AD, y2_AD
1040 fac = (x - x1)/(x2 - x1)
1041 y1_ad = y1_ad + (
one - fac)*y_ad
1042 y2_ad = y2_ad + fac*y_ad
1110 SUBROUTINE layeravg( PX1,PX2,PZ,interp_index)
1111 REAL(fp),
DIMENSION(:),
INTENT(IN) :: PX1(:)
1112 REAL(fp),
DIMENSION(:),
INTENT(IN) :: PX2(:)
1113 REAL(fp),
DIMENSION(:,:),
INTENT(OUT) :: PZ(:, :)
1114 INTEGER,
DIMENSION(:,:),
INTENT(OUT) :: interp_index
1117 INTEGER :: KN1,KN2, ibot,itop,ii,istart,iend, J,IC,ISKIP,KI
1118 REAL(fp) :: z1,z2,z3,zw1,zw2,zsum
1119 REAL(fp) :: y1,y2,d,w10,w20,dz,dx,dy,dzd,dxd
1140 if (z3 > px2(kn2)) z3=px2(kn2)
1143 if (z2 >= px2(kn2))
then 1154 if (px2(j) > z3)
go to 1000
1156 if (px2(j) <= z2 .and. px2(j+1) > z1)
then 1161 if (px2(j) > z1)
then 1166 if (px2(j+1) < z2)
then 1172 if (px2(j) > z2)
then 1177 if (px2(j+1) < z1)
then 1188 write(6,*)
'SUBLAYER: ERROR: dz is <=0. dz = ',dz
1189 write(6,*)
'z1,z2,z3 = ',z1,z2,z3
1190 write(6,*)
'px2(j),px2(j+1) = ',px2(j),px2(j+1)
1199 dx=(px2(j+1)-px2(j))
1201 write(6,*)
'SUBLAYER: ERROR: dx is <=0. dx = ',dx
1202 write(6,*)
'z1,z2,z3 = ',z1,z2,z3
1203 write(6,*)
'px2(j),px2(j+1) = ',px2(j),px2(j+1)
1210 if (z1 < z3 .and. ibot == 0)
then 1213 else if (z1 > z3 .and. itop == 0)
then 1217 pz(j,ki)=pz(j,ki)+zw1
1218 pz(j+1,ki)=pz(j+1,ki)+zw2
1222 if (px2(j) < z3 .and. px2(j+1) >= z2 .and. iskip == 0)
then 1227 if (px2(j) > z3)
then 1232 if (px2(j+1) < z2)
then 1238 if (px2(j) > z2)
then 1243 if (px2(j+1) < z3)
then 1254 write(6,*)
'SUBLAYER: ERROR: dz is <=0. dz = ',dz
1255 write(6,*)
'z3,z2,z1 = ',z3,z2,z1
1256 write(6,*)
'px2(j),px2(j+1) = ',px2(j),px2(j+1)
1265 dx=(px2(j+1)-px2(j))
1267 write(6,*)
'SUBLAYER: ERROR: dx is <=0. dx = ',dx
1268 write(6,*)
'z3,z2,z1 = ',z3,z2,z1
1269 write(6,*)
'px2(j),px2(j+1) = ',px2(j),px2(j+1)
1276 if (z3 < z1 .and. ibot == 0)
then 1279 else if (z3 > z1 .and. itop == 0)
then 1283 pz(j,ki)=pz(j,ki)+zw1
1284 pz(j+1,ki)=pz(j+1,ki)+zw2
1290 if (ic == 0) pz(j,ki)=
one 1296 if(pz(ii,ki) /=
zero)
then 1297 interp_index(1, ki)=ii
1301 istart=interp_index(1, ki)
1303 interp_index(2,ki)=kn2
1305 do ii=interp_index(1, ki)+1,kn2
1306 if(pz(ii,ki) ==
zero)
then 1307 interp_index(2,ki)=ii-1
1311 iend=interp_index(2,ki)
1313 zsum=sum(pz(interp_index(1, ki):interp_index(2,ki),ki))
1314 pz(interp_index(1,ki):interp_index(2,ki),ki)= &
1315 pz(interp_index(1,ki):interp_index(2, ki),ki)/zsum
subroutine geopotential_height(Level_Pressure, Temperature, Water_Vapor, Surface_Height, Level_Height)
real(fp), parameter, public zero
integer, parameter, public fp
character(*), parameter, private module_rcs_id
real(fp), parameter, public r_dryair
integer, parameter, public h2o_id
subroutine layeravg(PX1, PX2, PZ, interp_index)
real(fp), parameter, public earth_radius
subroutine, public map_input_tl(TC, Atm_TL, Temperature_TL, Absorber_TL, PAFV)
subroutine interp_linear_f1_tl(x1, x2, x, y1_TL, y2_TL, y_TL)
real(fp), parameter smalldiff
real(fp), parameter, public one
subroutine, public interpolate_profile_f1_tl(interp_index, x, u, y_TL, y_int_TL)
subroutine, public map_input_ad(TC, Temperature_AD, Absorber_AD, Atm_AD, PAFV)
elemental logical function, public pafv_associated(self)
real(fp), parameter, public two
subroutine, public compute_interp_index(x, u, interp_index)
subroutine interp_linear(y1, x1, y2, x2, x, y)
subroutine, public map_input(Atm, TC, GeoInfo, Temperature, Absorber, User_Level_LnPressure, Ref_Level_LnPressure, Secant_Zenith, H2O_idx, PAFV)
real(fp), parameter, public degrees_to_radians
real(fp), parameter, public eps
subroutine, public interpolate_profile(interp_index, y, x, u, y_int)
subroutine, public interpolate_profile_f1_ad(interp_index, x, u, y_int_AD, y_AD)
subroutine interp_linear_f1_ad(x1, x2, x, y_AD, y1_AD, y2_AD)
elemental subroutine, public crtm_geometryinfo_getvalue(gInfo, Geometry, iFOV, Longitude, Latitude, Surface_Altitude, Sensor_Scan_Angle, Sensor_Zenith_Angle, Sensor_Azimuth_Angle, Source_Zenith_Angle, Source_Azimuth_Angle, Flux_Zenith_Angle, Year, Month, Day, Distance_Ratio, Sensor_Scan_Radian, Sensor_Zenith_Radian, Sensor_Azimuth_Radian, Secant_Sensor_Zenith, Cosine_Sensor_Zenith, Source_Zenith_Radian, Source_Azimuth_Radian, Secant_Source_Zenith, Flux_Zenith_Radian, Secant_Flux_Zenith, Trans_Zenith_Radian, Secant_Trans_Zenith, AU_ratio2)