53 '$Id: SOI_Module.f90 60152 2015-08-13 19:19:13Z paul.vandelst@noaa.gov $' 67 SUBROUTINE crtm_soi(n_Layers, & ! Input number of atmospheric layers
68 w, & ! Input layer scattering albedo
69 T_OD, & ! Input layer optical depth
70 cosmic_background, & ! Input cosmic background radiance
71 emissivity, & ! Input surface emissivity
72 reflectivity, & ! Input surface reflectivity matrix
73 Index_Sat_Angle, & ! Input satellite angle index
87 INTEGER,
INTENT(IN) :: n_layers
88 REAL (fp),
INTENT(IN),
DIMENSION( : ) :: w, t_od
89 REAL (fp),
INTENT(IN) :: cosmic_background
90 REAL (fp),
INTENT(IN),
DIMENSION( : ) :: emissivity
91 REAL (fp),
INTENT(IN),
DIMENSION( :,: ) :: reflectivity
92 INTEGER,
INTENT( IN ) :: index_sat_angle
93 TYPE(
rtv_type),
INTENT( INOUT ) :: rtv
97 INTEGER :: i, k, niter
98 REAL(fp) :: rad, rad_change
99 REAL(fp),
PARAMETER :: initial_error = 1.e10
100 REAL(fp),
PARAMETER :: small = 1.e-15
101 REAL(fp),
PARAMETER :: sngl_scat_alb_thresh = 0.8
102 REAL(fp),
PARAMETER :: opt_depth_thresh = 4.0
103 REAL(fp) :: radiance_thresh
104 REAL(fp),
DIMENSION( MAX_N_ANGLES ) :: source
109 rtv%e_Layer_Trans( 1 : rtv%n_Angles, k ) = exp( -t_od( k ) / rtv%COS_Angle( 1 : rtv%n_Angles ) )
112 IF ( w( k ) < sngl_scat_alb_thresh .AND. t_od( k ) < opt_depth_thresh )
THEN 114 rtv%COS_Angle, rtv%COS_Weight, rtv%Pff( :, :, k ), &
115 rtv%Pbb( :, :, k ), rtv%Planck_Atmosphere( k ), &
119 rtv%COS_Angle, rtv%COS_Weight, rtv%Pff( :, :, k ), &
120 rtv%Pbb( :, :, k ), rtv%Planck_Atmosphere( k ), &
125 DO i = 1, rtv%n_angles
126 rtv%s_Layer_Trans( i, i, k ) = rtv%s_Layer_Trans( i, i, k ) - rtv%e_layer_Trans( i, k )
130 DO i = 1, rtv%n_Angles
131 rtv%s_Layer_Source_UP( i, k ) = rtv%Planck_Atmosphere( k ) * (
one - rtv%e_Layer_Trans( i, k ) )
132 rtv%s_Layer_Source_DOWN( i, k ) = rtv%s_Layer_Source_UP( i, k )
140 rtv%s_level_Rad_UP( index_sat_angle, 0 ) =
zero 142 IF ( rtv%Number_SOI_Iter > 0 )
THEN 143 rtv%s_Level_IterRad_UP( 1 : rtv%n_Angles, 0 : n_layers, 1 : rtv%Number_SOI_Iter ) =
zero 144 rtv%s_Level_IterRad_DOWN( 1 : rtv%n_Angles, 0 : n_layers, 1 : rtv%Number_SOI_Iter ) =
zero 146 rtv%s_Level_IterRad_UP( 1 : rtv%n_Angles, 0 : n_layers, 1 ) =
zero 147 rtv%s_Level_IterRad_DOWN( 1 : rtv%n_Angles, 0 : n_layers, 1 ) =
zero 153 rtv%s_Level_IterRad_DOWN( 1 : rtv%n_Angles, 0, 1 ) = cosmic_background
155 rad_change = initial_error
164 radiance_thresh = 1.e-4
169 soi_loop:
DO WHILE ( ( ( rad_change > radiance_thresh ) .AND. ( ( niter + 1 ) <=
max_n_soi_iterations ) ) .OR. ( niter < 2 ) )
173 IF ( niter > 1 ) rtv%s_Level_IterRad_DOWN( 1 : rtv%n_Angles, 0, niter ) =
zero 178 layersdn_loop:
DO k = 1, n_layers
180 IF ( niter == 1 )
THEN 181 source( 1 : rtv%n_Angles ) = rtv%s_Layer_Source_DOWN( 1 : rtv%n_Angles, k )
192 source( 1 : rtv%n_Angles ) = matmul( rtv%s_Layer_Trans( 1 : rtv%n_Angles, 1 : rtv%n_Angles, k ), &
193 rtv%s_Level_IterRad_DOWN( 1 : rtv%n_Angles, k - 1, niter - 1 ) ) + &
194 matmul( rtv%s_Layer_Refl( 1 : rtv%n_Angles, 1 : rtv%n_Angles, k ), &
195 rtv%s_Level_IterRad_UP( 1 : rtv%n_Angles, k, niter - 1 ) )
198 source( 1 : rtv%n_Angles ) =
zero 201 rtv%s_Level_IterRad_DOWN( 1 : rtv%n_Angles, k, niter ) = rtv%s_Level_IterRad_DOWN( 1 : rtv%n_Angles, k - 1, niter ) &
202 * rtv%e_Layer_Trans( 1 : rtv%n_Angles, k ) &
203 + source( 1 : rtv%n_Angles )
211 DO i = 1, rtv%n_Angles
212 rtv%s_Level_IterRad_UP( i, n_layers, niter ) = reflectivity( i, i ) * rtv%s_Level_IterRad_DOWN( i, n_layers, niter )
214 IF ( niter == 1 )
THEN 217 rtv%s_Level_IterRad_UP( 1 : rtv%n_Angles, n_layers, niter ) = &
218 rtv%s_Level_IterRad_UP( 1 : rtv%n_Angles, n_layers, niter ) + &
219 emissivity( 1 : rtv%n_Angles ) * rtv%Planck_Surface
226 layersup_loop:
DO k = n_layers, 1, -1
228 IF ( niter == 1 )
THEN 229 source( 1 :rtv%n_Angles ) = rtv%s_Layer_Source_UP( 1 : rtv%n_Angles, k )
240 source( 1 : rtv%n_Angles ) = matmul( rtv%s_Layer_Refl( 1 : rtv%n_Angles, 1 : rtv%n_Angles, k ), &
241 rtv%s_Level_IterRad_DOWN( 1 : rtv%n_Angles, k - 1, niter - 1 ) ) + &
242 matmul( rtv%s_Layer_Trans( 1 : rtv%n_Angles, 1 : rtv%n_Angles, k ), &
243 rtv%s_Level_IterRad_UP( 1 : rtv%n_Angles, k, niter - 1 ) )
246 source( 1 : rtv%n_Angles ) =
zero 249 rtv%s_Level_IterRad_UP( 1 : rtv%n_Angles, k - 1, niter ) = rtv%s_Level_IterRad_UP( 1 : rtv%n_Angles, k, niter ) &
250 * rtv%e_Layer_Trans( 1 : rtv%n_Angles, k ) &
251 + source( 1 : rtv%n_Angles )
257 rad = rtv%s_Level_IterRad_UP( index_sat_angle, 0, niter )
262 rtv%s_level_Rad_UP( index_sat_angle, 0 ) = rtv%s_level_Rad_UP( index_sat_angle, 0 ) + rad
279 rad_change = rad / rtv%s_level_Rad_UP( index_sat_angle, 0 )
284 rtv%Number_SOI_Iter = niter
290 SUBROUTINE crtm_soi_tl(n_Layers, & ! Input number of atmospheric layers
291 w, & ! Input layer scattering albedo
292 T_OD, & ! Input layer optical depth
293 emissivity, & ! Input surface emissivity
294 reflectivity, & ! Input surface reflectivity matrix
295 Index_Sat_Angle, & ! Input satellite angle index
296 RTV, & ! Input structure containing forward part results
297 Planck_Atmosphere_TL, & ! Input tangent-linear atmospheric layer Planck radiance
298 Planck_Surface_TL, & ! Input TL surface Planck radiance
299 w_TL, & ! Input TL layer scattering albedo
300 T_OD_TL, & ! Input TL layer optical depth
301 emissivity_TL, & ! Input TL surface emissivity
302 reflectivity_TL, & ! Input TL reflectivity
303 Pff_TL, & ! Input TL forward phase matrix
304 Pbb_TL, & ! Input TL backward phase matrix
318 INTEGER,
INTENT(IN) :: n_layers
319 REAL (fp),
INTENT(IN),
DIMENSION( : ) :: w, t_od
320 REAL (fp),
INTENT(IN),
DIMENSION( : ) :: emissivity
321 REAL (fp),
INTENT(IN),
DIMENSION( :, : ) :: reflectivity
322 INTEGER,
INTENT( IN ) :: index_sat_angle
324 REAL (fp),
INTENT(IN),
DIMENSION( 0: ) :: planck_atmosphere_tl
325 REAL (fp),
INTENT(IN) :: planck_surface_tl
326 REAL (fp),
INTENT(IN),
DIMENSION( : ) :: w_tl, t_od_tl
327 REAL (fp),
INTENT(IN),
DIMENSION( : ) :: emissivity_tl
328 REAL (fp),
INTENT(IN),
DIMENSION( :, : ) :: reflectivity_tl
329 REAL (fp),
INTENT(IN),
DIMENSION( :, :, : ) :: pff_tl, pbb_tl
330 REAL (fp),
INTENT(INOUT),
DIMENSION( : ) :: s_rad_up_tl
334 INTEGER :: i, k, iter
335 REAL(fp),
PARAMETER :: sngl_scat_alb_thresh = 0.8
336 REAL(fp),
PARAMETER :: opt_depth_thresh = 4.0
337 REAL(fp),
DIMENSION( RTV%n_Angles ) :: source_tl
338 REAL(fp),
DIMENSION( RTV%n_Angles, n_Layers ) :: e_trans_tl
339 REAL(fp),
DIMENSION( RTV%n_Angles, n_Layers ) :: s_source_up_tl, s_source_down_tl
340 REAL(fp),
DIMENSION( RTV%n_Angles, RTV%n_Angles, n_Layers ) :: s_trans_tl, s_refl_tl
341 REAL(fp),
DIMENSION( RTV%n_Angles, 0:n_Layers, RTV%Number_SOI_Iter ) :: s_iterrad_up_tl, s_iterrad_down_tl
346 e_trans_tl( 1 : rtv%n_Angles, k ) = -t_od_tl(k) * (exp( -t_od( k ) / rtv%COS_Angle( 1 : rtv%n_Angles ) ) ) / &
347 rtv%COS_Angle( 1 : rtv%n_Angles )
350 IF ( w( k ) < sngl_scat_alb_thresh .AND. t_od( k ) < opt_depth_thresh )
THEN 352 rtv%COS_Angle( 1 : rtv%n_Angles ), rtv%COS_Weight( 1 : rtv%n_Angles ), &
353 rtv%Pff( 1 : rtv%n_Angles, 1 : rtv%n_Angles, k ), &
354 rtv%Pbb( 1 : rtv%n_Angles, 1 : rtv%n_Angles, k ), rtv%Planck_Atmosphere( k ), &
355 w_tl( k ), t_od_tl( k ), pff_tl( :, :, k ), &
356 pbb_tl( :, :, k ), planck_atmosphere_tl( k ), rtv, &
357 s_trans_tl( :, :, k ), s_refl_tl( :, :, k ), s_source_up_tl( :, k ), &
358 s_source_down_tl( :, k ) )
361 rtv%COS_Angle( 1 : rtv%n_Angles ), rtv%COS_Weight( 1 : rtv%n_Angles ), &
362 rtv%Pff( 1 : rtv%n_Angles, 1 : rtv%n_Angles, k ), &
363 rtv%Pbb( 1 : rtv%n_Angles, 1 : rtv%n_Angles, k ), rtv%Planck_Atmosphere( k ), &
364 w_tl( k ), t_od_tl( k ), pff_tl( :, :, k ), &
365 pbb_tl( :, :, k ), planck_atmosphere_tl( k ), rtv, &
366 s_trans_tl( :, :, k), s_refl_tl( :, :, k ), s_source_up_tl( :, k ), &
367 s_source_down_tl( :, k ) )
371 DO i = 1, rtv%n_angles
372 s_trans_tl( i, i, k ) = s_trans_tl( i, i, k ) - e_trans_tl( i, k )
376 DO i = 1, rtv%n_Angles
377 s_source_up_tl( i, k ) = planck_atmosphere_tl( k ) * (
one - rtv%e_Layer_Trans( i, k ) ) - &
378 rtv%PLanck_Atmosphere( k ) * e_trans_tl( i, k )
379 s_source_down_tl( i, k ) = s_source_up_tl( i, k )
385 s_rad_up_tl( index_sat_angle ) =
zero 386 s_iterrad_up_tl( 1 : rtv%n_Angles, 0 : n_layers, 1 : rtv%Number_SOI_Iter ) =
zero 387 s_iterrad_down_tl( 1 : rtv%n_Angles, 0 : n_layers, 1 : rtv%Number_SOI_Iter ) =
zero 392 DO iter = 1, rtv%Number_SOI_Iter
395 IF ( iter > 1 ) s_iterrad_down_tl( 1 : rtv%n_Angles, 0, iter ) =
zero 400 layersdn_loop:
DO k = 1, n_layers
402 IF ( iter == 1 )
THEN 404 source_tl( 1 : rtv%n_Angles ) = s_source_down_tl( 1 : rtv%n_Angles, k )
408 source_tl( 1 : rtv%n_Angles ) = matmul( rtv%s_Layer_Trans( 1 : rtv%n_Angles, 1 : rtv%n_Angles, k ), &
409 s_iterrad_down_tl( 1 : rtv%n_Angles, k - 1, iter - 1 ) ) + &
410 matmul( s_trans_tl( 1 : rtv%n_Angles, 1 : rtv%n_Angles, k ), &
411 rtv%s_Level_IterRad_DOWN( 1 : rtv%n_Angles, k - 1, iter - 1 ) ) + &
412 matmul( rtv%s_Layer_Refl( 1 : rtv%n_Angles, 1 : rtv%n_Angles, k ), &
413 s_iterrad_up_tl( 1 : rtv%n_Angles, k, iter - 1 ) ) + &
414 matmul( s_refl_tl( 1 : rtv%n_Angles, 1 : rtv%n_Angles, k ), &
415 rtv%s_level_IterRad_UP( 1 : rtv%n_Angles, k, iter - 1 ) )
417 source_tl( 1 : rtv%n_Angles ) =
zero 420 s_iterrad_down_tl( 1 : rtv%n_Angles, k, iter ) = s_iterrad_down_tl( 1 : rtv%n_Angles, k - 1, iter ) &
421 * rtv%e_Layer_Trans( 1 : rtv%n_Angles, k ) + &
422 rtv%s_Level_IterRad_DOWN( 1 : rtv%n_Angles, k - 1, iter ) &
423 * e_trans_tl( 1 : rtv%n_Angles, k ) &
424 + source_tl( 1 : rtv%n_Angles )
431 DO i = 1, rtv%n_Angles
432 s_iterrad_up_tl( i, n_layers, iter ) = reflectivity_tl( i, i ) * rtv%s_Level_IterRad_DOWN( i, n_layers, iter ) + &
433 reflectivity( i, i ) * s_iterrad_down_tl( i, n_layers, iter )
435 IF ( iter == 1 )
THEN 438 s_iterrad_up_tl( 1 : rtv%n_Angles, n_layers, iter ) = s_iterrad_up_tl( 1 : rtv%n_Angles, n_layers, iter ) + &
439 emissivity( 1 : rtv%n_Angles ) * planck_surface_tl + &
440 emissivity_tl( 1 : rtv%n_Angles ) * rtv%Planck_Surface
446 layersup_loop:
DO k = n_layers, 1, -1
448 IF ( iter == 1 )
THEN 449 source_tl( 1 :rtv%n_Angles ) = s_source_up_tl( 1 : rtv%n_Angles, k )
452 source_tl( 1 : rtv%n_Angles ) = matmul( rtv%s_Layer_Refl( 1 : rtv%n_Angles, 1 : rtv%n_Angles, k ), &
453 s_iterrad_down_tl( 1 : rtv%n_Angles, k - 1, iter - 1 ) ) + &
454 matmul( s_refl_tl( 1 : rtv%n_Angles, 1 : rtv%n_Angles, k ), &
455 rtv%s_Level_IterRad_DOWN( 1 : rtv%n_Angles, k - 1, iter - 1 ) ) + &
456 matmul( rtv%s_Layer_Trans( 1 : rtv%n_Angles, 1 : rtv%n_Angles, k ), &
457 s_iterrad_up_tl( 1 : rtv%n_Angles, k, iter - 1 ) ) + &
458 matmul( s_trans_tl( 1 : rtv%n_Angles, 1 : rtv%n_Angles, k ), &
459 rtv%s_Level_IterRad_UP( 1 : rtv%n_Angles, k, iter - 1 ) )
461 source_tl( 1 : rtv%n_Angles ) =
zero 464 s_iterrad_up_tl( 1 : rtv%n_Angles, k - 1, iter ) = rtv%s_Level_IterRad_UP( 1 : rtv%n_Angles, k, iter ) &
465 * e_trans_tl( 1 : rtv%n_Angles, k ) + &
466 s_iterrad_up_tl( 1 : rtv%n_Angles, k, iter ) &
467 * rtv%e_Layer_Trans( 1 : rtv%n_Angles, k ) &
468 + source_tl( 1 : rtv%n_Angles )
474 s_rad_up_tl( index_sat_angle ) = s_rad_up_tl( index_sat_angle ) + s_iterrad_up_tl( index_sat_angle, 0, iter )
481 SUBROUTINE crtm_soi_ad(n_Layers, & ! Input number of atmospheric layers
482 w, & ! Input layer scattering albedo
483 T_OD, & ! Input layer optical depth
484 emissivity, & ! Input surface emissivity
485 reflectivity, & ! Input surface reflectivity matrix
486 Index_Sat_Angle, & ! Input satellite angle index
487 RTV, & ! Input structure containing forward results
488 s_rad_up_AD, & ! Input adjoint upward radiance
489 Planck_Atmosphere_AD, & ! Output AD atmospheric layer Planck radiance
490 Planck_Surface_AD, & ! Output AD surface Planck radiance
491 w_AD, & ! Output AD layer scattering albedo
492 T_OD_AD, & ! Output AD layer optical depth
493 emissivity_AD, & ! Output AD surface emissivity
494 reflectivity_AD, & ! Output AD surface reflectivity
495 Pff_AD, & ! Output AD forward phase matrix
505 INTEGER,
INTENT(IN) :: n_layers
506 REAL (fp),
INTENT(IN),
DIMENSION( : ) :: w, t_od
507 REAL (fp),
INTENT(IN),
DIMENSION( : ) :: emissivity
508 REAL (fp),
INTENT(IN),
DIMENSION( :, : ) :: reflectivity
509 INTEGER,
INTENT(IN) :: index_sat_angle
512 REAL (fp),
INTENT(INOUT),
DIMENSION( :, :, : ) :: pff_ad, pbb_ad
513 REAL (fp),
INTENT(INOUT),
DIMENSION( : ) :: w_ad,t_od_ad
514 REAL (fp),
INTENT(INOUT),
DIMENSION( 0: ) :: planck_atmosphere_ad
515 REAL (fp),
INTENT(INOUT) :: planck_surface_ad
516 REAL (fp),
INTENT(INOUT),
DIMENSION( : ) :: emissivity_ad
517 REAL (fp),
INTENT(INOUT),
DIMENSION( :, : ) :: reflectivity_ad
518 REAL (fp),
INTENT(INOUT),
DIMENSION( : ) :: s_rad_up_ad
521 REAL(fp),
PARAMETER :: sngl_scat_alb_thresh = 0.8
522 REAL(fp),
PARAMETER :: opt_depth_thresh = 4.0
523 INTEGER :: iter, k, i, j
524 REAL(fp),
DIMENSION( RTV%n_Angles, 0:n_Layers, RTV%Number_SOI_Iter ) :: s_iterrad_up_ad
525 REAL(fp),
DIMENSION( RTV%n_Angles, 0:n_Layers, RTV%Number_SOI_Iter ) :: s_iterrad_down_ad
526 REAL(fp),
DIMENSION( RTV%n_Angles ) :: source_ad
527 REAL(fp),
DIMENSION( RTV%n_Angles, n_Layers ) :: s_source_up_ad
528 REAL(fp),
DIMENSION( RTV%n_Angles, n_layers ) :: s_source_down_ad
529 REAL(fp),
DIMENSION( RTV%n_Angles, n_Layers ) :: e_trans_ad
530 REAL(fp),
DIMENSION( RTV%n_Angles, RTV%n_Angles, n_Layers ) :: s_refl_ad
531 REAL(fp),
DIMENSION( RTV%n_Angles, RTV%n_Angles, n_Layers ) :: s_trans_ad
534 s_iterrad_up_ad =
zero 535 s_iterrad_down_ad =
zero 537 s_source_up_ad =
zero 538 s_source_down_ad =
zero 549 DO iter = rtv%Number_SOI_Iter, 1, -1
550 s_iterrad_up_ad( index_sat_angle, 0, iter ) = s_rad_up_ad( index_sat_angle )
555 source_ad( 1 : rtv%n_Angles ) = source_ad( 1 : rtv%n_Angles ) + s_iterrad_up_ad( 1 : rtv%n_Angles, k - 1, iter )
556 e_trans_ad( 1 : rtv%n_Angles, k ) = e_trans_ad( 1 : rtv%n_Angles, k ) + &
557 s_iterrad_up_ad( 1 : rtv%n_Angles, k - 1, iter ) * &
558 rtv%s_Level_IterRad_UP( 1 : rtv%n_Angles, k, iter )
559 s_iterrad_up_ad( 1 : rtv%n_Angles, k, iter ) = s_iterrad_up_ad( 1 : rtv%n_Angles, k, iter ) + &
560 s_iterrad_up_ad( 1 : rtv%n_Angles, k - 1, iter ) * &
561 rtv%e_Layer_Trans( 1 : rtv%n_Angles, k )
562 s_iterrad_up_ad( 1 : rtv%n_Angles, k - 1, iter ) =
zero 563 IF ( iter == 1 )
THEN 564 s_source_up_ad( 1 : rtv%n_Angles, k ) = s_source_up_ad( 1 : rtv%n_Angles, k ) + source_ad( 1 : rtv%n_Angles )
565 source_ad( 1 : rtv%n_Angles ) =
zero 569 DO j = 1, rtv%n_Angles
570 DO i = 1, rtv%n_Angles
571 s_refl_ad( j, i, k ) = s_refl_ad( j, i, k ) + source_ad( j ) * rtv%s_Level_IterRad_DOWN( i, k - 1, iter - 1 )
572 s_iterrad_down_ad( i, k - 1, iter - 1 ) = s_iterrad_down_ad( i, k - 1, iter - 1 ) + source_ad( j ) * &
573 rtv%s_Layer_Refl( j, i, k )
574 s_trans_ad( j, i, k ) = s_trans_ad( j, i, k ) + source_ad( j ) * rtv%s_Level_IterRad_UP( i, k, iter - 1 )
575 s_iterrad_up_ad( i, k, iter - 1 ) = s_iterrad_up_ad( i, k, iter - 1 ) + source_ad( j ) * &
576 rtv%s_Layer_Trans( j, i, k )
578 source_ad( j ) =
zero 581 source_ad( 1 : rtv%n_Angles ) =
zero 586 IF ( iter == 1 )
THEN 589 emissivity_ad( 1 : rtv%n_Angles ) = emissivity_ad( 1 : rtv%n_Angles ) + &
590 s_iterrad_up_ad( 1 : rtv%n_Angles, n_layers, iter ) * rtv%Planck_Surface
591 planck_surface_ad = planck_surface_ad + sum( s_iterrad_up_ad( :, n_layers, iter ) * emissivity )
596 DO i = 1, rtv%n_Angles
597 reflectivity_ad( i, i ) = reflectivity_ad( i, i ) + s_iterrad_up_ad( i, n_layers, iter ) * &
598 rtv%s_Level_IterRad_DOWN( i, n_layers, iter )
599 s_iterrad_down_ad( i, n_layers, iter ) = s_iterrad_down_ad( i, n_layers, iter ) + &
600 s_iterrad_up_ad( i, n_layers, iter ) * reflectivity( i, i )
601 s_iterrad_up_ad( i, n_layers, iter ) =
zero 607 DO k = n_layers, 1, -1
608 source_ad( 1 : rtv%n_Angles ) = source_ad( 1 : rtv%n_Angles ) + s_iterrad_down_ad( 1 : rtv%n_Angles, k, iter )
609 e_trans_ad( 1 : rtv%n_Angles, k ) = e_trans_ad( 1 : rtv%n_Angles, k ) + &
610 s_iterrad_down_ad( 1 : rtv%n_Angles, k, iter ) * &
611 rtv%s_Level_IterRad_DOWN( 1 : rtv%n_Angles, k - 1, iter )
612 s_iterrad_down_ad( 1 : rtv%n_Angles, k - 1, iter ) = s_iterrad_down_ad( 1 : rtv%n_Angles, k - 1, iter ) + &
613 s_iterrad_down_ad( 1 : rtv%n_Angles, k, iter ) * &
614 rtv%e_Layer_Trans( 1 : rtv%n_Angles, k )
615 s_iterrad_down_ad( 1 : rtv%n_Angles, k, iter ) =
zero 616 IF ( iter == 1 )
THEN 617 s_source_down_ad( 1 : rtv%n_Angles, k ) = s_source_down_ad( 1 : rtv%n_Angles, k ) + source_ad( 1 : rtv%n_Angles )
618 source_ad( 1 : rtv%n_Angles ) =
zero 621 DO j = 1, rtv%n_Angles
622 DO i = 1, rtv%n_Angles
623 s_trans_ad( j, i, k ) = s_trans_ad( j, i, k ) + source_ad( j ) * rtv%s_Level_IterRad_DOWN( i, k - 1, iter - 1 )
624 s_iterrad_down_ad( i, k - 1, iter - 1 ) = s_iterrad_down_ad( i, k - 1, iter - 1 ) + source_ad( j ) * &
625 rtv%s_Layer_Trans( j, i, k )
626 s_refl_ad( j, i, k ) = s_refl_ad( j, i, k ) + source_ad( j ) * rtv%s_Level_IterRad_UP( i, k, iter - 1 )
627 s_iterrad_up_ad( i, k, iter - 1 ) = s_iterrad_up_ad( i, k, iter - 1 ) + source_ad( j ) * &
628 rtv%s_Layer_Refl( j, i, k )
630 source_ad( j ) =
zero 633 source_ad( 1 : rtv%n_Angles ) =
zero 638 IF ( iter > 1 ) s_iterrad_down_ad( 1 : rtv%n_Angles, 0, iter ) =
zero 642 s_iterrad_down_ad( 1 : rtv%n_Angles, 0 : n_layers, 1 : rtv%Number_SOI_Iter ) =
zero 643 s_iterrad_up_ad( 1 : rtv%n_Angles, 0 : n_layers, 1 : rtv%Number_SOI_Iter ) =
zero 644 s_rad_up_ad( index_sat_angle ) =
zero 650 DO i = 1, rtv%n_angles
651 e_trans_ad( i, k ) = e_trans_ad( i, k ) - s_trans_ad( i, i, k )
654 IF ( w( k ) < sngl_scat_alb_thresh .AND. t_od( k ) < opt_depth_thresh )
THEN 657 rtv%COS_Angle, rtv%COS_Weight, rtv%Pff( :, :, k ), rtv%Pbb( :, :, k ), &
658 rtv%Planck_Atmosphere( k ), &
659 s_trans_ad( :, :, k ), s_refl_ad( :, :, k ), s_source_up_ad( :, k ), &
660 s_source_down_ad( :, k ), rtv, w_ad( k ), t_od_ad( k ), pff_ad( :, :, k ), &
661 pbb_ad( :, :, k ), planck_atmosphere_ad( k ) )
665 rtv%COS_Angle, rtv%COS_Weight, rtv%Pff( :, :, k ), rtv%Pbb( :, :, k ), &
666 rtv%Planck_Atmosphere( k ), &
667 s_trans_ad( :, :, k ), s_refl_ad( :, :, k ), s_source_up_ad( :, k ), &
668 s_source_down_ad( :, k ), rtv, w_ad( k ), t_od_ad( k ), pff_ad( :, :, k ), &
669 pbb_ad( :, :, k ), planck_atmosphere_ad( k ) )
675 DO i = 1, rtv%n_Angles
676 s_source_up_ad( i, k ) = s_source_up_ad( i, k ) + s_source_down_ad( i, k )
677 s_source_down_ad( i, k ) =
zero 679 planck_atmosphere_ad( k ) = planck_atmosphere_ad( k ) + s_source_up_ad( i, k ) * (
one - rtv%e_Layer_Trans( i, k ) )
680 e_trans_ad( i, k ) = e_trans_ad( i, k ) - rtv%Planck_Atmosphere( k ) * s_source_up_ad( i, k )
681 s_source_up_ad( i, k ) =
zero 685 t_od_ad( k ) = t_od_ad( k ) - sum( e_trans_ad( :, k ) * rtv%e_Layer_Trans( 1:rtv%n_Angles, k ) / &
686 rtv%COS_Angle(1:rtv%n_Angles) )
687 e_trans_ad( 1 : rtv%n_Angles, k ) =
zero 717 CHARACTER(*),
INTENT(OUT) :: id
731 NANG, & ! Input, number of angles
732 KL, & ! Input, KL-th layer
733 single_albedo, & ! Input, single scattering albedo
734 optical_depth, & ! Input, layer optical depth
735 COS_Angle, & ! Input, COSINE of ANGLES
736 COS_Weight, & ! Input, GAUSSIAN Weights
737 ff, & ! Input, Phase matrix (forward part)
758 INTEGER,
INTENT(IN) :: n_streams, NANG, KL
759 REAL(fp),
INTENT(IN) :: single_albedo, optical_depth, Planck_Func
760 REAL(fp),
INTENT(IN),
DIMENSION(:) :: COS_Angle, COS_Weight
761 REAL(fp),
INTENT(IN),
DIMENSION(:,:) :: ff, bb
762 TYPE(RTV_type),
INTENT( INOUT ) :: RTV
765 REAL(fp),
DIMENSION(NANG,NANG) :: term2,term3,trans,refl
766 REAL(fp),
DIMENSION(NANG) :: C1, C2, source_up,source_down
774 rtv%s_Layer_Trans(1:nang,1:nang,kl) =
zero 776 rtv%s_Layer_Trans(i,i,kl) =
one 778 rtv%s_Layer_Refl( 1 : nang, 1 : nang, kl ) =
zero 779 rtv%s_Layer_Source_DOWN( 1 : nang, kl ) =
zero 780 rtv%s_Layer_Source_UP( 1 : nang, kl ) =
zero 789 IF ( rtv%Number_Doubling( kl ) < 1 ) rtv%Number_Doubling( kl ) = 1
791 rtv%Delta_Tau( kl ) = optical_depth / (
two**rtv%Number_Doubling( kl ) )
796 s = rtv%Delta_Tau( kl ) * single_albedo
798 c = s / cos_angle( i )
800 rtv%Refl( i, j, 0, kl ) = c * bb( i, j ) * cos_weight( j )
801 rtv%Trans( i, j, 0, kl ) = c * ff( i, j ) * cos_weight( j )
803 rtv%Trans( i, i, 0, kl ) = rtv%Trans( i, i, 0, kl ) +
one - rtv%Delta_Tau( kl ) / cos_angle( i )
809 DO l = 1, rtv%Number_Doubling( kl )
812 rtv%Inv_BeT( i, j, l, kl ) =
zero 815 rtv%Inv_BeT( i, j, l, kl ) = rtv%Inv_BeT( i, j, l, kl ) + rtv%Refl( i, k, l - 1, kl ) * rtv%Refl( k, j, l - 1, kl )
818 rtv%Inv_BeT( i, i, l, kl ) = rtv%Inv_BeT( i, i, l, kl ) +
one 821 term2 = matmul( rtv%Trans( 1 : nang, 1 : nang, l - 1, kl ), rtv%Inv_BeT( 1 : nang, 1 : nang, l, kl ) )
822 term3 = matmul( term2, rtv%Refl( 1 : nang, 1 : nang, l - 1, kl ) )
823 term3 = matmul( term3, rtv%Trans( 1 : nang, 1 : nang, l - 1, kl ) )
825 rtv%Refl( 1 : nang, 1 : nang, l, kl ) = rtv%Refl( 1 : nang, 1 : nang, l - 1, kl ) + term3
826 rtv%Trans( 1 : nang, 1 : nang, l, kl ) = matmul( term2, rtv%Trans( 1 : nang, 1 : nang, l - 1, kl ) )
830 trans = rtv%Trans( 1 : nang, 1 : nang, rtv%Number_Doubling( kl ), kl )
831 refl = rtv%Refl( 1 : nang, 1 : nang, rtv%Number_Doubling( kl ), kl )
838 c1( i ) = c1( i ) + trans( i, j )
839 c2( i ) = c2( i ) + refl( i, j )
841 IF ( i == nang .AND. nang == ( n_streams + 1 ) )
THEN 842 c1( i ) = c1( i ) + trans( nang, nang )
847 source_up( i ) = (
one - c1( i ) - c2( i ) ) * planck_func
848 source_down( i ) = source_up( i )
851 rtv%C1( 1 : nang, kl ) = c1
852 rtv%C2( 1 : nang, kl ) = c2
853 rtv%s_Layer_Trans( 1 : nang, 1 : nang, kl ) = trans
854 rtv%s_Layer_Refl( 1 : nang, 1 : nang, kl ) = refl
855 rtv%s_Layer_Source_DOWN( 1 : nang, kl ) = source_down
856 rtv%s_Layer_Source_UP( 1 : nang, kl ) = source_up
864 NANG, & ! Input, number of angles
865 KL, & ! Input, number of angles
866 single_albedo, & ! Input, single scattering albedo
867 optical_depth, & ! Input, layer optical depth
868 COS_Angle, & ! Input, COSINE of ANGLES
869 COS_Weight, & ! Input, GAUSSIAN Weights
870 ff, & ! Input, Phase matrix (forward part)
891 INTEGER,
INTENT(IN) :: n_streams, NANG, KL
892 TYPE(RTV_type),
INTENT(IN) :: RTV
893 REAL(fp),
INTENT(IN),
DIMENSION(:,:) :: ff, bb
894 REAL(fp),
INTENT(IN),
DIMENSION(:) :: COS_Angle, COS_Weight
895 REAL(fp),
INTENT(IN) :: single_albedo, optical_depth, Planck_Func
898 REAL(fp),
INTENT(OUT),
DIMENSION( :, : ) :: trans_TL, refl_TL
899 REAL(fp),
INTENT(OUT),
DIMENSION( : ) :: source_up_TL, source_down_TL
900 REAL(fp),
INTENT(IN) :: single_albedo_TL
901 REAL(fp),
INTENT(IN) :: optical_depth_TL, Planck_Func_TL
902 REAL(fp),
INTENT(IN),
DIMENSION( : ,: ) :: ff_TL, bb_TL
905 REAL(fp),
DIMENSION( NANG, NANG ) :: term2, term3, term2_TL, term3_TL, ms_term_TL
907 REAL(fp) :: s_TL, c_TL, Delta_Tau_TL
908 REAL(fp),
DIMENSION( NANG ) :: C1_TL, C2_TL
909 INTEGER :: i, j, k, L
917 source_down_tl =
zero 921 s = rtv%Delta_Tau( kl ) * single_albedo
923 delta_tau_tl = optical_depth_tl / (
two**rtv%Number_Doubling( kl ) )
927 s_tl = delta_tau_tl * single_albedo + rtv%Delta_Tau( kl ) * single_albedo_tl
930 c_tl = s_tl/cos_angle( i )
932 refl_tl( i, j ) = c_tl * bb( i, j ) * cos_weight( j ) + c * bb_tl( i, j ) * cos_weight( j )
933 trans_tl( i, j ) = c_tl * ff( i, j ) * cos_weight( j ) + c * ff_tl( i, j ) * cos_weight( j )
935 trans_tl( i, i ) = trans_tl( i, i ) - delta_tau_tl / cos_angle( i )
938 DO l = 1, rtv%Number_Doubling( kl )
941 ms_term_tl( i, j ) =
zero 943 ms_term_tl( i, j ) = ms_term_tl( i, j ) + rtv%Refl( i, k, l - 1, kl ) * refl_tl( k, j ) &
944 + refl_tl( i, k ) * rtv%Refl( k, j, l - 1, kl )
949 term2 = matmul( rtv%Trans( 1 : nang, 1 : nang, l - 1, kl ), rtv%Inv_BeT( 1 : nang, 1 : nang, l, kl ) )
950 term2_tl = matmul( rtv%Trans( 1 : nang, 1 : nang, l - 1, kl ), ms_term_tl ) + &
951 matmul( trans_tl, rtv%Inv_BeT( 1 : nang, 1 : nang, l, kl ) )
952 term3 = matmul( term2, rtv%Refl( 1 : nang, 1 : nang, l - 1, kl ) )
953 term3_tl = matmul( term2, refl_tl ) + matmul( term2_tl, rtv%Refl( 1 : nang, 1 : nang, l - 1, kl ) )
954 term3 = matmul( term3, rtv%Trans( 1 : nang, 1 : nang, l - 1, kl ) )
955 term3_tl = matmul( term3, trans_tl ) + matmul( term3_tl, rtv%Trans( 1 : nang, 1 : nang, l - 1, kl ) )
956 refl_tl = refl_tl + term3_tl
957 trans_tl = matmul( term2, trans_tl ) + matmul( term2_tl, rtv%Trans( 1 : nang, 1 : nang, l - 1, kl ) )
967 c1_tl( i ) = c1_tl( i ) + trans_tl( i, j )
968 c2_tl( i ) = c2_tl( i ) + refl_tl( i, j )
970 IF ( i == nang .AND. nang == ( n_streams + 1 ) )
THEN 971 c1_tl( i ) = c1_tl( i ) + trans_tl( nang, nang )
976 source_up_tl( i ) = - ( c1_tl( i ) + c2_tl( i ) ) * planck_func &
977 + (
one - rtv%C1( i, kl ) - rtv%C2( i, kl ) ) * planck_func_tl
978 source_down_tl( i ) = source_up_tl( i )
986 NANG, & ! Input, number of angles
987 KL, & ! Input, number of angles
988 single_albedo, & ! Input, single scattering albedo
989 optical_depth, & ! Input, layer optical depth
990 COS_Angle, & ! Input, COSINE of ANGLES
991 COS_Weight, & ! Input, GAUSSIAN Weights
992 ff, & ! Input, Phase matrix (forward part)
1007 INTEGER,
INTENT(IN) :: n_streams,NANG,KL
1008 TYPE(RTV_type),
INTENT(IN) :: RTV
1009 REAL(fp),
INTENT(IN),
DIMENSION(:,:) :: ff,bb
1010 REAL(fp),
INTENT(IN),
DIMENSION(:) :: COS_Angle, COS_Weight
1011 REAL(fp),
INTENT(IN) :: single_albedo,optical_depth,Planck_Func
1014 REAL(fp),
INTENT( INOUT ),
DIMENSION( :,: ) :: trans_AD,refl_AD
1015 REAL(fp),
INTENT( INOUT ),
DIMENSION( : ) :: source_up_AD,source_down_AD
1016 REAL(fp),
INTENT( INOUT ) :: single_albedo_AD
1017 REAL(fp),
INTENT( INOUT ) :: optical_depth_AD,Planck_Func_AD
1018 REAL(fp),
INTENT(INOUT),
DIMENSION(:,:) :: ff_AD,bb_AD
1021 REAL(fp),
DIMENSION( NANG, NANG ) :: term2, term3, term2_AD, term3_AD, ms_term_AD
1023 REAL(fp) :: s_AD, c_AD, Delta_Tau_AD
1024 REAL(fp),
DIMENSION(NANG) :: C1_AD, C2_AD
1033 source_down_ad =
zero 1041 source_up_ad( i ) = source_up_ad( i ) + source_down_ad( i )
1042 source_down_ad( i ) =
zero 1043 c2_ad( i ) = -source_up_ad( i ) * planck_func
1044 c1_ad( i ) = -source_up_ad( i ) * planck_func
1045 planck_func_ad = planck_func_ad + (
one - rtv%C1( i, kl ) - rtv%C2( i, kl ) ) * source_up_ad( i )
1051 IF(i == nang .AND. nang == ( n_streams + 1 ) )
THEN 1052 trans_ad( nang, nang ) = trans_ad( nang, nang ) + c1_ad( i )
1055 DO j = n_streams, 1, -1
1056 refl_ad( i, j ) = refl_ad( i, j ) + c2_ad( i )
1057 trans_ad( i, j ) = trans_ad( i, j ) + c1_ad( i )
1065 DO l = rtv%Number_Doubling(kl), 1, -1
1068 term2 = matmul( rtv%Trans( 1 : nang, 1 : nang, l - 1, kl ), rtv%Inv_BeT( 1 : nang, 1 : nang, l, kl ) )
1069 term3 = matmul( term2, rtv%Refl( 1 : nang, 1 : nang, l - 1, kl ) )
1070 term3 = matmul( term3, rtv%Trans( 1 : nang, 1 : nang, l - 1, kl ) )
1073 term2_ad = term2_ad + matmul( trans_ad, transpose( rtv%Trans( 1 : nang, 1 : nang, l - 1, kl ) ) )
1074 trans_ad = matmul( transpose( term2 ), trans_ad )
1076 term3_ad = term3_ad + refl_ad
1078 trans_ad = trans_ad + matmul( transpose( term3 ), term3_ad )
1079 term3_ad = matmul( term3_ad, transpose( rtv%Trans( 1 : nang, 1 : nang, l - 1, kl ) ) )
1081 term2_ad = term2_ad + matmul( term3_ad, transpose( rtv%Refl( 1 : nang, 1 : nang, l - 1, kl ) ) )
1082 refl_ad = refl_ad + matmul( transpose( term2 ), term3_ad )
1085 ms_term_ad = ms_term_ad + matmul( transpose( rtv%Trans( 1 : nang, 1 : nang, l - 1, kl ) ), term2_ad )
1086 trans_ad = trans_ad + matmul( term2_ad, transpose( rtv%Inv_BeT( 1 : nang, 1 : nang, l, kl ) ) )
1089 refl_ad = refl_ad + matmul( ms_term_ad, transpose( rtv%Refl( 1 : nang, 1 : nang, l - 1, kl ) ) ) + &
1090 matmul( transpose( rtv%Refl( 1 : nang, 1 : nang, l - 1, kl ) ), ms_term_ad )
1095 s = rtv%Delta_Tau( kl ) * single_albedo
1102 c = s / cos_angle( i )
1103 delta_tau_ad = delta_tau_ad - trans_ad( i, i ) / cos_angle( i )
1106 c_ad = c_ad + trans_ad( i, j ) * ff( i, j ) * cos_weight( j )
1107 ff_ad( i, j ) = ff_ad( i, j ) + trans_ad( i, j ) * c * cos_weight( j )
1108 c_ad = c_ad + refl_ad( i, j ) * bb( i, j ) * cos_weight( j )
1109 bb_ad( i, j ) = bb_ad( i, j ) + refl_ad( i, j ) * c * cos_weight( j )
1112 s_ad = s_ad + c_ad / cos_angle( i )
1117 delta_tau_ad = delta_tau_ad + s_ad * single_albedo
1118 single_albedo_ad = single_albedo_ad + rtv%Delta_Tau( kl ) * s_ad
1119 optical_depth_ad = optical_depth_ad + delta_tau_ad / (
two**rtv%Number_Doubling( kl ) )
1125 NANG, & ! Input, number of angles
1126 KL, & ! Input, KL-th layer
1127 single_albedo, & ! Input, single scattering albedo
1128 optical_depth, & ! Input, layer optical depth
1129 COS_Angle, & ! Input, COSINE of ANGLES
1130 COS_Weight, & ! Input, GAUSSIAN Weights
1131 ff, & ! Input, Phase matrix (forward part)
1150 INTEGER,
INTENT(IN) :: n_streams,NANG,KL
1151 TYPE(RTV_type),
INTENT( INOUT ) :: RTV
1152 REAL(fp),
INTENT(IN),
DIMENSION(:,:) :: ff,bb
1153 REAL(fp),
INTENT(IN),
DIMENSION(:) :: COS_Angle, COS_Weight
1154 REAL(fp),
INTENT(IN) :: single_albedo,optical_depth,Planck_Func
1157 REAL(fp),
DIMENSION(NANG,NANG) :: term2,term3,term4,trans,refl
1158 REAL(fp),
DIMENSION(NANG) :: C1, C2, source_up,source_down
1161 INTEGER :: Error_Status
1167 rtv%s_Layer_Trans(1:nang,1:nang,kl) =
zero 1169 rtv%s_Layer_Trans(i,i,kl) =
one 1171 rtv%s_Layer_Refl(1:nang,1:nang,kl) =
zero 1172 rtv%s_Layer_Source_DOWN(1:nang,kl) =
zero 1173 rtv%s_Layer_Source_UP(1:nang,kl) =
zero 1182 IF( rtv%Number_Doubling(kl) < 1 ) rtv%Number_Doubling(kl) = 1
1184 rtv%Delta_Tau(kl) = optical_depth/(
two**rtv%Number_Doubling(kl))
1189 s = rtv%Delta_Tau(kl) * single_albedo
1193 rtv%Refl(i,j,0,kl) = c * bb(i,j) * cos_weight(j)
1194 rtv%Trans(i,j,0,kl) = c * ff(i,j) * cos_weight(j)
1196 rtv%Trans(i,i,0,kl) = rtv%Trans(i,i,0,kl) +
one - rtv%Delta_Tau(kl)/cos_angle(i)
1202 DO l = 1, rtv%Number_Doubling(kl)
1207 term4(i,j) = term4(i,j) - rtv%Refl(i,k,l-1,kl)*rtv%Refl(k,j,l-1,kl)
1210 term4(i,i) = term4(i,i) +
one 1213 rtv%Inv_BeT(1:nang,1:nang,l,kl) =
matinv(term4, error_status)
1214 IF( error_status /=
success )
THEN 1215 print *,
' error at matinv in CRTM_Doubling_layer ' 1216 rtv%s_Layer_Trans(1:nang,1:nang,kl) =
zero 1218 rtv%s_Layer_Trans(i,i,kl) = exp(-optical_depth/cos_angle(i))
1220 rtv%s_Layer_Refl(1:nang,1:nang,kl) =
zero 1221 rtv%s_Layer_Source_DOWN(1:nang,kl) =
zero 1222 rtv%s_Layer_Source_UP(1:nang,kl) =
zero 1226 term2 = matmul(rtv%Trans(1:nang,1:nang,l-1,kl), rtv%Inv_BeT(1:nang,1:nang,l,kl))
1227 term3 = matmul(term2, rtv%Refl(1:nang,1:nang,l-1,kl))
1228 term3 = matmul(term3, rtv%Trans(1:nang,1:nang,l-1,kl))
1230 rtv%Refl(1:nang,1:nang,l,kl) = rtv%Refl(1:nang,1:nang,l-1,kl) + term3
1231 rtv%Trans(1:nang,1:nang,l,kl) = matmul(term2, rtv%Trans(1:nang,1:nang,l-1,kl))
1234 trans = rtv%Trans(1:nang,1:nang,rtv%Number_Doubling(kl),kl)
1235 refl = rtv%Refl(1:nang,1:nang,rtv%Number_Doubling(kl),kl)
1242 c1(i) = c1(i) + trans(i,j)
1243 c2(i) = c2(i) + refl(i,j)
1245 IF(i == nang .AND. nang == (n_streams+1))
THEN 1246 c1(i) = c1(i)+trans(nang,nang)
1251 source_up(i) = (
one-c1(i)-c2(i))*planck_func
1252 source_down(i) = source_up(i)
1255 rtv%C1( 1:nang,kl ) = c1
1256 rtv%C2( 1:nang,kl ) = c2
1257 rtv%s_Layer_Trans(1:nang,1:nang,kl) = trans
1258 rtv%s_Layer_Refl(1:nang,1:nang,kl) = refl
1259 rtv%s_Layer_Source_DOWN(1:nang,kl) = source_down
1260 rtv%s_Layer_Source_UP(1:nang,kl) = source_up
1268 NANG, & ! Input, number of angles
1269 KL, & ! Input, number of angles
1270 single_albedo, & ! Input, single scattering albedo
1271 optical_depth, & ! Input, layer optical depth
1272 COS_Angle, & ! Input, COSINE of ANGLES
1273 COS_Weight, & ! Input, GAUSSIAN Weights
1274 ff, & ! Input, Phase matrix (forward part)
1296 INTEGER,
INTENT(IN) :: n_streams,NANG,KL
1297 TYPE(RTV_type),
INTENT(IN) :: RTV
1298 REAL(fp),
INTENT(IN),
DIMENSION(:,:) :: ff,bb
1299 REAL(fp),
INTENT(IN),
DIMENSION(:) :: COS_Angle, COS_Weight
1300 REAL(fp),
INTENT(IN) :: single_albedo,optical_depth,Planck_Func
1303 REAL(fp),
INTENT(OUT),
DIMENSION( :,: ) :: trans_TL,refl_TL
1304 REAL(fp),
INTENT(OUT),
DIMENSION( : ) :: source_up_TL,source_down_TL
1305 REAL(fp),
INTENT(IN) :: single_albedo_TL
1306 REAL(fp),
INTENT(IN) :: optical_depth_TL,Planck_Func_TL
1307 REAL(fp),
INTENT(IN),
DIMENSION(:,:) :: ff_TL,bb_TL
1310 REAL(fp),
DIMENSION(NANG,NANG) :: term1,term2,term3,term4,term5_TL
1312 REAL(fp) :: s_TL, c_TL, Delta_Tau_TL
1313 REAL(fp),
DIMENSION(NANG) :: C1_TL, C2_TL
1322 source_down_tl =
zero 1326 s = rtv%Delta_Tau(kl) * single_albedo
1328 delta_tau_tl = optical_depth_tl / (
two**rtv%Number_Doubling( kl ) )
1332 s_tl = delta_tau_tl * single_albedo + rtv%Delta_Tau(kl) * single_albedo_tl
1335 c_tl = s_tl/cos_angle(i)
1337 refl_tl(i,j) = c_tl*bb(i,j)*cos_weight(j)+c*bb_tl(i,j)*cos_weight(j)
1338 trans_tl(i,j) =c_tl*ff(i,j)*cos_weight(j)+c*ff_tl(i,j)*cos_weight(j)
1340 trans_tl(i,i) =trans_tl(i,i) - delta_tau_tl/cos_angle(i)
1343 DO l = 1, rtv%Number_Doubling(kl)
1345 term1 = matmul(rtv%Trans(1:nang,1:nang,l-1,kl),rtv%Inv_BeT(1:nang,1:nang,l,kl))
1346 term2 = matmul(rtv%Inv_BeT(1:nang,1:nang,l,kl),rtv%Refl(1:nang,1:nang,l-1,kl))
1347 term3 = matmul(rtv%Inv_BeT(1:nang,1:nang,l,kl),rtv%Trans(1:nang,1:nang,l-1,kl))
1348 term4 = matmul(term2,rtv%Trans(1:nang,1:nang,l-1,kl))
1349 term5_tl = matmul(refl_tl,rtv%Refl(1:nang,1:nang,l-1,kl)) &
1350 + matmul(rtv%Refl(1:nang,1:nang,l-1,kl),refl_tl)
1352 refl_tl=refl_tl+matmul(matmul(term1,term5_tl),term4)+matmul(trans_tl,term4) &
1353 +matmul(matmul(term1,refl_tl),rtv%Trans(1:nang,1:nang,l-1,kl))
1354 refl_tl=refl_tl+matmul(matmul(term1,rtv%Refl(1:nang,1:nang,l-1,kl)),trans_tl)
1356 trans_tl=matmul(trans_tl,term3) &
1357 +matmul(matmul(term1,term5_tl),term3)+matmul(term1,trans_tl)
1367 c1_tl(i) = c1_tl(i) + trans_tl(i,j)
1368 c2_tl(i) = c2_tl(i) + refl_tl(i,j)
1370 IF(i == nang .AND. nang == (n_streams+1))
THEN 1371 c1_tl(i) = c1_tl(i)+trans_tl(nang,nang)
1376 source_up_tl(i) = -(c1_tl(i)+c2_tl(i))*planck_func &
1377 + (
one-rtv%C1(i,kl)-rtv%C2(i,kl))*planck_func_tl
1378 source_down_tl(i) = source_up_tl(i)
1396 NANG, & ! Input, number of angles
1397 KL, & ! Input, number of angles
1398 single_albedo, & ! Input, single scattering albedo
1399 optical_depth, & ! Input, layer optical depth
1400 COS_Angle, & ! Input, COSINE of ANGLES
1401 COS_Weight, & ! Input, GAUSSIAN Weights
1402 ff, & ! Input, Phase matrix (forward part)
1417 INTEGER,
INTENT(IN) :: n_streams,NANG,KL
1418 TYPE(RTV_type),
INTENT(IN) :: RTV
1419 REAL(fp),
INTENT(IN),
DIMENSION(:,:) :: ff,bb
1420 REAL(fp),
INTENT(IN),
DIMENSION(:) :: COS_Angle, COS_Weight
1421 REAL(fp),
INTENT(IN) :: single_albedo,optical_depth,Planck_Func
1424 REAL(fp),
INTENT( INOUT ),
DIMENSION( :,: ) :: trans_AD,refl_AD
1425 REAL(fp),
INTENT( INOUT ),
DIMENSION( : ) :: source_up_AD,source_down_AD
1426 REAL(fp),
INTENT( INOUT ) :: single_albedo_AD
1427 REAL(fp),
INTENT( INOUT ) :: optical_depth_AD,Planck_Func_AD
1428 REAL(fp),
INTENT(INOUT),
DIMENSION(:,:) :: ff_AD,bb_AD
1431 REAL(fp),
DIMENSION(NANG,NANG) :: term1,term2,term3,term4,term5_AD
1433 REAL(fp) :: s_AD, c_AD, Delta_Tau_AD
1434 REAL(fp),
DIMENSION(NANG) :: C1_AD, C2_AD
1443 source_down_ad =
zero 1448 source_up_ad(i) = source_up_ad(i) + source_down_ad(i)
1449 source_down_ad(i) =
zero 1450 c2_ad(i) = -source_up_ad(i)*planck_func
1451 c1_ad(i) = -source_up_ad(i)*planck_func
1452 planck_func_ad = planck_func_ad + (
one-rtv%C1(i,kl)-rtv%C2(i,kl))*source_up_ad(i)
1458 IF(i == nang .AND. nang == (n_streams+1))
THEN 1459 trans_ad(nang,nang)=trans_ad(nang,nang)+c1_ad(i)
1462 DO j = n_streams, 1, -1
1463 refl_ad(i,j)=refl_ad(i,j)+c2_ad(i)
1464 trans_ad(i,j)=trans_ad(i,j)+c1_ad(i)
1469 DO l = rtv%Number_Doubling(kl), 1, -1
1471 term1 = matmul(rtv%Trans(1:nang,1:nang,l-1,kl),rtv%Inv_BeT(1:nang,1:nang,l,kl))
1472 term2 = matmul(rtv%Inv_BeT(1:nang,1:nang,l,kl),rtv%Refl(1:nang,1:nang,l-1,kl))
1473 term3 = matmul(rtv%Inv_BeT(1:nang,1:nang,l,kl),rtv%Trans(1:nang,1:nang,l-1,kl))
1474 term4 = matmul(term2,rtv%Trans(1:nang,1:nang,l-1,kl))
1476 term5_ad = matmul(matmul(transpose(term1),trans_ad),transpose(term3))
1477 trans_ad = matmul(trans_ad,transpose(term3))+matmul(transpose(term1),trans_ad)
1479 trans_ad=trans_ad+matmul(transpose(matmul(term1,rtv%Refl(1:nang,1:nang,l-1,kl))),refl_ad)
1481 term5_ad =term5_ad+matmul(matmul(transpose(term1),refl_ad),transpose(term4))
1482 trans_ad = trans_ad+matmul(refl_ad,transpose(term4))
1483 refl_ad = refl_ad+matmul(matmul(transpose(term1),refl_ad),transpose(rtv%Trans(1:nang,1:nang,l-1,kl)))
1484 refl_ad = refl_ad+matmul(term5_ad,transpose(rtv%Refl(1:nang,1:nang,l-1,kl)))
1485 refl_ad = refl_ad+matmul(transpose(rtv%Refl(1:nang,1:nang,l-1,kl)),term5_ad)
1489 s = rtv%Delta_Tau(kl) * single_albedo
1497 delta_tau_ad = delta_tau_ad - trans_ad(i,i)/cos_angle(i)
1500 c_ad = c_ad + trans_ad(i,j)*ff(i,j)*cos_weight(j)
1501 ff_ad(i,j)=ff_ad(i,j)+trans_ad(i,j)*c*cos_weight(j)
1502 c_ad = c_ad + refl_ad(i,j)*bb(i,j)*cos_weight(j)
1503 bb_ad(i,j)=bb_ad(i,j) + refl_ad(i,j)*c*cos_weight(j)
1506 s_ad = s_ad + c_ad/cos_angle(i)
1511 delta_tau_ad = delta_tau_ad + s_ad* single_albedo
1512 single_albedo_ad = single_albedo_ad+rtv%Delta_Tau(kl) * s_ad
1513 optical_depth_ad = optical_depth_ad + delta_tau_ad/(
two**rtv%Number_Doubling(kl))
subroutine crtm_doubling_layer_tl(n_streams, NANG, KL, single_albedo, optical_depth, COS_Angle, COS_Weight, ff, bb, Planck_Func, single_albedo_TL, optical_depth_TL, ff_TL, bb_TL, Planck_Func_TL, RTV, trans_TL, refl_TL, source_up_TL, source_down_TL)
integer, parameter, public failure
integer, parameter, public set
real(fp), parameter, public zero
integer, parameter, public fp
integer, parameter, public max_n_angles
real(fp), parameter, public scattering_albedo_threshold
real(fp), parameter, public delta_optical_depth
real(fp), parameter, public optical_depth_threshold
subroutine, public crtm_soi(n_Layers, w, T_OD, cosmic_background, emissivity, reflectivity, Index_Sat_Angle, RTV)
integer, parameter, public max_n_legendre_terms
integer, parameter, public max_n_soi_iterations
real(fp), parameter, public secant_diffusivity
character(*), parameter module_version_id
subroutine, public crtm_soi_version(Id)
real(fp), parameter, public one
recursive subroutine, public display_message(Routine_Name, Message, Error_State, Message_Log)
subroutine crtm_doubling_layer(n_streams, NANG, KL, single_albedo, optical_depth, COS_Angle, COS_Weight, ff, bb, Planck_Func, RTV)
subroutine crtm_truncated_doubling_ad(n_streams, NANG, KL, single_albedo, optical_depth, COS_Angle, COS_Weight, ff, bb, Planck_Func, trans_AD, refl_AD, source_up_AD, source_down_AD, RTV, single_albedo_AD, optical_depth_AD, ff_AD, bb_AD, Planck_Func_AD)
real(fp), parameter, public two
subroutine crtm_truncated_doubling_tl(n_streams, NANG, KL, single_albedo, optical_depth, COS_Angle, COS_Weight, ff, bb, Planck_Func, single_albedo_TL, optical_depth_TL, ff_TL, bb_TL, Planck_Func_TL, RTV, trans_TL, refl_TL, source_up_TL, source_down_TL)
real(fp), parameter, public degrees_to_radians
subroutine, public crtm_soi_tl(n_Layers, w, T_OD, emissivity, reflectivity, Index_Sat_Angle, RTV, Planck_Atmosphere_TL, Planck_Surface_TL, w_TL, T_OD_TL, emissivity_TL, reflectivity_TL, Pff_TL, Pbb_TL, s_rad_up_TL)
integer, parameter, public max_n_layers
integer, parameter, public max_n_doubling
subroutine, public crtm_soi_ad(n_Layers, w, T_OD, emissivity, reflectivity, Index_Sat_Angle, RTV, s_rad_up_AD, Planck_Atmosphere_AD, Planck_Surface_AD, w_AD, T_OD_AD, emissivity_AD, reflectivity_AD, Pff_AD, Pbb_AD)
subroutine crtm_truncated_doubling(n_streams, NANG, KL, single_albedo, optical_depth, COS_Angle, COS_Weight, ff, bb, Planck_Func, RTV)
subroutine crtm_doubling_layer_ad(n_streams, NANG, KL, single_albedo, optical_depth, COS_Angle, COS_Weight, ff, bb, Planck_Func, trans_AD, refl_AD, source_up_AD, source_down_AD, RTV, single_albedo_AD, optical_depth_AD, ff_AD, bb_AD, Planck_Func_AD)
integer, parameter, public success
real(fp) function, dimension(size(a, 1), size(a, 2)), public matinv(A, Error_Status)
real(fp), parameter, public pi