56 SUBROUTINE crtm_ada(n_Layers, & ! Input number of atmospheric layers
57 w, & ! Input layer scattering albedo
58 T_OD, & ! Input layer optical depth
59 cosmic_background, & ! Input cosmic background radiance
60 emissivity, & ! Input surface emissivity
61 reflectivity, & ! Input surface reflectivity matrix
62 direct_reflectivity, & ! Input surface direct reflectivity
75 INTEGER,
INTENT(IN) :: n_layers
77 TYPE(
rtv_type),
INTENT( INOUT ) :: rtv
78 REAL (fp),
INTENT(IN),
DIMENSION( : ) :: w,t_od
79 REAL (fp),
INTENT(IN),
DIMENSION( : ) :: emissivity, direct_reflectivity
80 REAL (fp),
INTENT(IN),
DIMENSION( :,: ) :: reflectivity
81 REAL (fp),
INTENT(IN) :: cosmic_background
88 REAL (fp),
DIMENSION(RTV%n_Angles, RTV%n_Angles) :: temporal_matrix
89 REAL (fp),
DIMENSION( RTV%n_Angles, n_Layers) :: refl_down
90 REAL (fp),
DIMENSION(0:n_Layers) :: total_opt
91 INTEGER :: i, j, k, error_status
92 CHARACTER(*),
PARAMETER :: routine_name =
'CRTM_ADA' 93 CHARACTER(256) :: message
97 total_opt(k) = total_opt(k-1) + t_od(k)
101 rtv%s_Layer_Trans =
zero 102 rtv%s_Layer_Refl =
zero 103 rtv%s_Level_Refl_UP =
zero 104 rtv%s_Level_Rad_UP =
zero 105 rtv%s_Layer_Source_UP =
zero 106 rtv%s_Layer_Source_DOWN =
zero 108 rtv%s_Level_Refl_UP(1:rtv%n_Angles,1:rtv%n_Angles,n_layers)=reflectivity(1:rtv%n_Angles,1:rtv%n_Angles)
110 IF( rtv%mth_Azi == 0 )
THEN 111 rtv%s_Level_Rad_UP(1:rtv%n_Angles,n_layers ) = emissivity(1:rtv%n_Angles)*rtv%Planck_Surface
114 IF( rtv%Solar_Flag_true )
THEN 115 rtv%s_Level_Rad_UP(1:nz,n_layers ) = rtv%s_Level_Rad_UP(1:nz,n_layers )+direct_reflectivity(1:nz)* &
116 rtv%COS_SUN*rtv%Solar_irradiance/
pi*exp(-total_opt(n_layers)/rtv%COS_SUN)
120 DO 10 k = n_layers, 1, -1
132 rtv%n_Angles,k,w(k), &
139 rtv%Planck_Atmosphere(k), &
147 temporal_matrix = -matmul(rtv%s_Level_Refl_UP(1:rtv%n_Angles,1:rtv%n_Angles,k), &
148 rtv%s_Layer_Refl(1:rtv%n_Angles,1:rtv%n_Angles,k))
149 DO i = 1, rtv%n_Angles
150 temporal_matrix(i,i) =
one + temporal_matrix(i,i)
153 rtv%Inv_Gamma(1:rtv%n_Angles,1:rtv%n_Angles,k) =
matinv(temporal_matrix, error_status)
154 IF( error_status /=
success )
THEN 155 WRITE( message,
'("Error in matrix inversion matinv(temporal_matrix, Error_Status) ")' )
162 rtv%Inv_GammaT(1:rtv%n_Angles,1:rtv%n_Angles,k) = &
163 matmul(rtv%s_Layer_Trans(1:rtv%n_Angles,1:rtv%n_Angles,k), rtv%Inv_Gamma(1:rtv%n_Angles,1:rtv%n_Angles,k))
164 refl_down(1:rtv%n_Angles,k) = matmul(rtv%s_Level_Refl_UP(1:rtv%n_Angles,1:rtv%n_Angles,k), &
165 rtv%s_Layer_Source_DOWN(1:rtv%n_Angles,k))
167 rtv%s_Level_Rad_UP(1:rtv%n_Angles,k-1 )=rtv%s_Layer_Source_UP(1:rtv%n_Angles,k)+ &
168 matmul(rtv%Inv_GammaT(1:rtv%n_Angles,1:rtv%n_Angles,k),refl_down(1:rtv%n_Angles,k) &
169 +rtv%s_Level_Rad_UP(1:rtv%n_Angles,k ))
170 rtv%Refl_Trans(1:rtv%n_Angles,1:rtv%n_Angles,k) = matmul(rtv%s_Level_Refl_UP(1:rtv%n_Angles,1:rtv%n_Angles,k), &
171 rtv%s_Layer_Trans(1:rtv%n_Angles,1:rtv%n_Angles,k))
172 rtv%s_Level_Refl_UP(1:rtv%n_Angles,1:rtv%n_Angles,k-1)=rtv%s_Layer_Refl(1:rtv%n_Angles,1:rtv%n_Angles,k) + &
173 matmul(rtv%Inv_GammaT(1:rtv%n_Angles,1:rtv%n_Angles,k),rtv%Refl_Trans(1:rtv%n_Angles,1:rtv%n_Angles,k))
176 DO i = 1, rtv%n_Angles
177 rtv%s_Layer_Trans(i,i,k) = exp(-t_od(k)/rtv%COS_Angle(i))
178 rtv%s_Layer_Source_UP(i,k) = rtv%Planck_Atmosphere(k) * (
one - rtv%s_Layer_Trans(i,i,k) )
179 rtv%s_Layer_Source_DOWN(i,k) = rtv%s_Layer_Source_UP(i,k)
184 DO i = 1, rtv%n_Angles
185 rtv%s_Level_Rad_UP(i,k-1 )=rtv%s_Layer_Source_UP(i,k)+ &
186 rtv%s_Layer_Trans(i,i,k)*(sum(rtv%s_Level_Refl_UP(i,1:rtv%n_Angles,k)*rtv%s_Layer_Source_DOWN(1:rtv%n_Angles,k)) &
187 +rtv%s_Level_Rad_UP(i,k ))
189 DO i = 1, rtv%n_Angles
190 DO j = 1, rtv%n_Angles
191 rtv%s_Level_Refl_UP(i,j,k-1)=rtv%s_Layer_Trans(i,i,k)*rtv%s_Level_Refl_UP(i,j,k)*rtv%s_Layer_Trans(j,j,k)
199 IF( rtv%mth_Azi == 0 )
THEN 200 DO i = 1, rtv%n_Angles
201 rtv%s_Level_Rad_UP(i,0)=rtv%s_Level_Rad_UP(i,0)+sum(rtv%s_Level_Refl_UP(i,1:rtv%n_Angles,0))*cosmic_background
210 nZ, & ! Input, number of angles
211 KL, & ! Input, KL-th layer
212 single_albedo, & ! Input, single scattering albedo
213 optical_depth, & ! Input, layer optical depth
214 total_opt, & ! Input, accumulated optical depth from the top to current layer top
215 COS_Angle, & ! Input, COSINE of ANGLES
216 COS_Weight, & ! Input, GAUSSIAN Weights
217 ff, & ! Input, Phase matrix (forward part)
239 INTEGER,
INTENT(IN) :: n_streams,nZ,KL
240 TYPE(RTV_type),
INTENT( INOUT ) :: RTV
241 REAL(fp),
INTENT(IN),
DIMENSION(:,:) :: ff,bb
242 REAL(fp),
INTENT(IN),
DIMENSION(:) :: COS_Angle, COS_Weight
243 REAL(fp) :: single_albedo,optical_depth,Planck_Func,total_opt
246 REAL(fp),
DIMENSION(nZ,nZ) :: trans, refl, tempo
248 INTEGER :: i,j,N2,N2_1
249 INTEGER :: Error_Status
250 REAL(fp) :: EXPfactor,Sfactor,s_transmittance,Solar(2*nZ),V0(2*nZ,2*nZ),Solar1(2*nZ)
251 REAL(fp) :: V1(2*nZ,2*nZ),Sfac2,source_up(nZ),source_down(nZ)
252 CHARACTER(*),
PARAMETER :: ROUTINE_NAME =
'CRTM_AMOM_layer' 253 CHARACTER(256) :: Message
257 s = optical_depth * single_albedo
259 rtv%Thermal_C(i,kl) =
zero 262 rtv%s_Layer_Refl(i,j,kl) = c * bb(i,j) * cos_weight(j)
263 rtv%s_Layer_Trans(i,j,kl) = c * ff(i,j) * cos_weight(j)
265 rtv%s_Layer_Trans(i,i,kl) = rtv%s_Layer_Trans(i,i,kl) + &
266 one - optical_depth/cos_angle(i)
268 IF( rtv%mth_Azi == 0 )
THEN 269 rtv%Thermal_C(i,kl) = rtv%Thermal_C(i,kl) + &
270 ( rtv%s_Layer_Refl(i,j,kl) + rtv%s_Layer_Trans(i,j,kl) )
274 IF( rtv%mth_Azi == 0 )
THEN 275 rtv%s_Layer_Source_UP(i,kl) = (
one - rtv%Thermal_C(i,kl) ) * planck_func
276 rtv%s_Layer_Source_DOWN(i,kl) = rtv%s_Layer_Source_UP(i,kl)
295 rtv%PM(i,j,kl) = c * bb(i,j) * cos_weight(j)
296 rtv%PP(i,j,kl) = c * ff(i,j) * cos_weight(j)
298 rtv%PP(i,i,kl) = rtv%PP(i,i,kl) -
one/cos_angle(i)
300 rtv%PPM(1:nz,1:nz,kl) = rtv%PP(1:nz,1:nz,kl) - rtv%PM(1:nz,1:nz,kl)
301 rtv%i_PPM(1:nz,1:nz,kl) =
matinv( rtv%PPM(1:nz,1:nz,kl), error_status )
302 IF( error_status /=
success )
THEN 303 WRITE( message,
'("Error in matrix inversion matinv( RTV%PPM(1:nZ,1:nZ,KL), Error_Status ) ")' )
310 rtv%PPP(1:nz,1:nz,kl) = rtv%PP(1:nz,1:nz,kl) + rtv%PM(1:nz,1:nz,kl)
311 rtv%HH(1:nz,1:nz,kl) = matmul( rtv%PPM(1:nz,1:nz,kl), rtv%PPP(1:nz,1:nz,kl) )
314 tempo = rtv%HH(1:nz,1:nz,kl)
315 CALL asymtx(tempo,nz,nz,nz,rtv%EigVe(1:nz,1:nz,kl),rtv%EigVa(1:nz,kl),error_status)
317 IF( rtv%EigVa(i,kl) >
zero )
THEN 318 rtv%EigValue(i,kl) = sqrt( rtv%EigVa(i,kl) )
320 rtv%EigValue(i,kl) =
zero 326 rtv%EigVeVa(i,j,kl) = rtv%EigVe(i,j,kl) * rtv%EigValue(j,kl)
329 rtv%EigVeF(1:nz,1:nz,kl) = matmul( rtv%i_PPM(1:nz,1:nz,kl), rtv%EigVeVa(1:nz,1:nz,kl) )
332 rtv%Gp(1:nz,1:nz,kl) = ( rtv%EigVe(1:nz,1:nz,kl) + rtv%EigVeF(1:nz,1:nz,kl) )/2.0_fp
333 rtv%Gm(1:nz,1:nz,kl) = ( rtv%EigVe(1:nz,1:nz,kl) - rtv%EigVeF(1:nz,1:nz,kl) )/2.0_fp
334 rtv%i_Gm(1:nz,1:nz,kl) =
matinv( rtv%Gm(1:nz,1:nz,kl), error_status)
336 IF( error_status /=
success )
THEN 337 WRITE( message,
'("Error in matrix inversion matinv( RTV%Gm(1:nZ,1:nZ,KL), Error_Status) ")' )
345 xx = rtv%EigValue(i,kl)*optical_depth
346 rtv%Exp_x(i,kl) = exp(-xx)
351 rtv%A1(i,j,kl) = rtv%Gp(i,j,kl) * rtv%Exp_x(j,kl)
352 rtv%A4(i,j,kl) = rtv%Gm(i,j,kl) * rtv%Exp_x(j,kl)
356 rtv%A2(1:nz,1:nz,kl) = matmul( rtv%i_Gm(1:nz,1:nz,kl), rtv%A1(1:nz,1:nz,kl) )
357 rtv%A3(1:nz,1:nz,kl) = matmul( rtv%Gp(1:nz,1:nz,kl), rtv%A2(1:nz,1:nz,kl) )
358 rtv%A5(1:nz,1:nz,kl) = matmul( rtv%A1(1:nz,1:nz,kl), rtv%A2(1:nz,1:nz,kl) )
359 rtv%A6(1:nz,1:nz,kl) = matmul( rtv%A4(1:nz,1:nz,kl), rtv%A2(1:nz,1:nz,kl) )
360 rtv%Gm_A5(1:nz,1:nz,kl) = rtv%Gm(1:nz,1:nz,kl) - rtv%A5(1:nz,1:nz,kl)
361 rtv%i_Gm_A5(1:nz,1:nz,kl) =
matinv(rtv%Gm_A5(1:nz,1:nz,kl), error_status)
362 IF( error_status /=
success )
THEN 363 WRITE( message,
'("Error in matrix inversion matinv(RTV%Gm_A5(1:nZ,1:nZ,KL), Error_Status) ")' )
369 trans = matmul( rtv%A4(1:nz,1:nz,kl) - rtv%A3(1:nz,1:nz,kl), rtv%i_Gm_A5(1:nz,1:nz,kl) )
370 refl = matmul( rtv%Gp(1:nz,1:nz,kl) - rtv%A6(1:nz,1:nz,kl), rtv%i_Gm_A5(1:nz,1:nz,kl) )
373 rtv%s_Layer_Trans(1:nz,1:nz,kl) = trans(:,:)
374 rtv%s_Layer_Refl(1:nz,1:nz,kl) = refl(:,:)
375 rtv%s_Layer_Source_UP(:,kl) =
zero 376 IF( rtv%mth_Azi == 0 )
THEN 378 rtv%Thermal_C(i,kl) =
zero 380 rtv%Thermal_C(i,kl) = rtv%Thermal_C(i,kl) + (trans(i,j) + refl(i,j) )
382 IF ( i == nz .AND. nz == (n_streams+1) )
THEN 383 rtv%Thermal_C(i,kl) = rtv%Thermal_C(i,kl) + trans(nz,nz)
385 rtv%s_Layer_Source_UP(i,kl) = (
one - rtv%Thermal_C(i,kl) ) * planck_func
386 rtv%s_Layer_Source_DOWN(i,kl) = rtv%s_Layer_Source_UP(i,kl)
391 IF( rtv%Visible_Flag_true )
THEN 398 sfactor = single_albedo*rtv%Solar_irradiance/
pi 399 IF( rtv%mth_Azi == 0 ) sfactor = sfactor/
two 400 expfactor = exp(-optical_depth/rtv%COS_SUN)
401 s_transmittance = exp(-total_opt/rtv%COS_SUN)
404 solar(i) = -bb(i,nz+1)*sfactor
405 solar(i+nz) = -ff(i,nz+1)*sfactor
408 v0(i,j) = single_albedo * ff(i,j) * cos_weight(j)
409 v0(i+nz,j) = single_albedo * bb(i,j) * cos_weight(j)
410 v0(i,j+nz) = v0(i+nz,j)
411 v0(nz+i,j+nz) = v0(i,j)
413 v0(i,i) = v0(i,i) -
one - cos_angle(i)/rtv%COS_SUN
414 v0(i+nz,i+nz) = v0(i+nz,i+nz) -
one + cos_angle(i)/rtv%COS_SUN
417 v1(1:n2_1,1:n2_1) =
matinv(v0(1:n2_1,1:n2_1), error_status)
418 IF( error_status /=
success )
THEN 419 WRITE( message,
'("Error in matrix inversion matinv(V0(1:N2_1,1:N2_1), Error_Status) ")' )
426 solar1(1:n2_1) = matmul( v1(1:n2_1,1:n2_1), solar(1:n2_1) )
428 sfac2 = solar(n2) - sum( v0(n2,1:n2_1)*solar1(1:n2_1) )
432 source_up(i) = solar1(i)
433 source_down(i) = expfactor*solar1(i+nz)
435 source_up(i) =source_up(i)-refl(i,j)*solar1(j+nz)-trans(i,j)*expfactor*solar1(j)
436 source_down(i) =source_down(i) -trans(i,j)*solar1(j+nz) -refl(i,j)*expfactor*solar1(j)
440 IF( abs( v0(n2,n2) ) > 0.0001_fp )
THEN 441 source_down(nz) =source_down(nz) +(expfactor-trans(nz,nz))*sfac2/v0(n2,n2)
443 source_down(nz) =source_down(nz) -expfactor*sfac2*optical_depth/cos_angle(nz)
446 source_up(1:nz) = source_up(1:nz)*s_transmittance
447 source_down(1:nz) = source_down(1:nz)*s_transmittance
449 rtv%s_Layer_Source_UP(1:nz,kl) = rtv%s_Layer_Source_UP(1:nz,kl)+source_up(1:nz)
450 rtv%s_Layer_Source_DOWN(1:nz,kl) = rtv%s_Layer_Source_DOWN(1:nz,kl)+source_down(1:nz)
457 SUBROUTINE crtm_ada_tl(n_Layers, & ! Input number of atmospheric layers
458 w, & ! Input layer scattering albedo
459 T_OD, & ! Input layer optical depth
460 cosmic_background, & ! Input cosmic background radiance
461 emissivity, & ! Input surface emissivity
462 direct_reflectivity, & ! Input direct reflectivity
463 RTV, & ! Input structure containing forward part results
464 Planck_Atmosphere_TL, & ! Input tangent-linear atmospheric layer Planck radiance
465 Planck_Surface_TL, & ! Input TL surface Planck radiance
466 w_TL, & ! Input TL layer scattering albedo
467 T_OD_TL, & ! Input TL layer optical depth
468 emissivity_TL, & ! Input TL surface emissivity
469 reflectivity_TL, & ! Input TL reflectivity
470 direct_reflectivity_TL, & ! Input TL direct reflectivity
471 Pff_TL, & ! Input TL forward phase matrix
472 Pbb_TL, & ! Input TL backward phase matrix
488 INTEGER,
INTENT(IN) :: n_layers
490 REAL (fp),
INTENT(IN),
DIMENSION( : ) :: w,t_od
491 REAL (fp),
INTENT(IN),
DIMENSION( : ) :: emissivity,direct_reflectivity
492 REAL (fp),
INTENT(IN) :: cosmic_background
494 REAL (fp),
INTENT(IN),
DIMENSION( :,:,: ) :: pff_tl, pbb_tl
495 REAL (fp),
INTENT(IN),
DIMENSION( : ) :: w_tl,t_od_tl
496 REAL (fp),
INTENT(IN),
DIMENSION( 0: ) :: planck_atmosphere_tl
497 REAL (fp),
INTENT(IN) :: planck_surface_tl
498 REAL (fp),
INTENT(IN),
DIMENSION( : ) :: emissivity_tl
499 REAL (fp),
INTENT(IN),
DIMENSION( :,: ) :: reflectivity_tl
500 REAL (fp),
INTENT(INOUT),
DIMENSION( : ) :: s_rad_up_tl
501 REAL (fp),
INTENT(INOUT),
DIMENSION( : ) :: direct_reflectivity_tl
507 REAL (fp),
DIMENSION(RTV%n_Angles,RTV%n_Angles) :: temporal_matrix_tl
509 REAL (fp),
DIMENSION( RTV%n_Angles, n_Layers) :: refl_down
510 REAL (fp),
DIMENSION( RTV%n_Angles ) :: s_source_up_tl,s_source_down_tl,refl_down_tl
512 REAL (fp),
DIMENSION( RTV%n_Angles, RTV%n_Angles ) :: s_trans_tl,s_refl_tl,refl_trans_tl
513 REAL (fp),
DIMENSION( RTV%n_Angles, RTV%n_Angles ) :: s_refl_up_tl,inv_gamma_tl,inv_gammat_tl
514 REAL (fp),
DIMENSION(0:n_Layers) :: total_opt, total_opt_tl
515 INTEGER :: i, j, k, nz
520 total_opt_tl(0) =
zero 522 total_opt(k) = total_opt(k-1) + t_od(k)
523 total_opt_tl(k) = total_opt_tl(k-1) + t_od_tl(k)
528 s_refl_up_tl = reflectivity_tl
529 IF( rtv%mth_Azi == 0 )
THEN 530 s_rad_up_tl = emissivity_tl * rtv%Planck_Surface + emissivity * planck_surface_tl
533 IF( rtv%Solar_Flag_true )
THEN 534 s_rad_up_tl = s_rad_up_tl+direct_reflectivity_tl*rtv%COS_SUN*rtv%Solar_irradiance/
pi &
535 * exp(-total_opt(n_layers)/rtv%COS_SUN) &
536 - direct_reflectivity * rtv%Solar_irradiance/
pi &
537 * total_opt_tl(n_layers) * exp(-total_opt(n_layers)/rtv%COS_SUN)
540 DO 10 k = n_layers, 1, -1
541 s_source_up_tl =
zero 542 s_source_down_tl =
zero 557 rtv%COS_Angle(1:rtv%n_Angles),rtv%COS_Weight(1:rtv%n_Angles) , &
558 rtv%Pff(:,:,k), rtv%Pbb(:,:,k),rtv%Planck_Atmosphere(k) , &
559 w_tl(k),t_od_tl(k),total_opt_tl(k-1),pff_tl(:,:,k) , &
560 pbb_tl(:,:,k),planck_atmosphere_tl(k),rtv , &
561 s_trans_tl,s_refl_tl,s_source_up_tl,s_source_down_tl)
564 temporal_matrix_tl = -matmul(s_refl_up_tl,rtv%s_Layer_Refl(1:rtv%n_Angles,1:rtv%n_Angles,k)) &
565 - matmul(rtv%s_Level_Refl_UP(1:rtv%n_Angles,1:rtv%n_Angles,k),s_refl_tl)
567 temporal_matrix_tl = matmul(rtv%Inv_Gamma(1:rtv%n_Angles,1:rtv%n_Angles,k),temporal_matrix_tl)
568 inv_gamma_tl = -matmul(temporal_matrix_tl,rtv%Inv_Gamma(1:rtv%n_Angles,1:rtv%n_Angles,k))
570 inv_gammat_tl = matmul(s_trans_tl, rtv%Inv_Gamma(1:rtv%n_Angles,1:rtv%n_Angles,k)) &
571 + matmul(rtv%s_Layer_Trans(1:rtv%n_Angles,1:rtv%n_Angles,k), inv_gamma_tl)
573 refl_down(1:rtv%n_Angles,k) = matmul(rtv%s_Level_Refl_UP(1:rtv%n_Angles,1:rtv%n_Angles,k), &
574 rtv%s_Layer_Source_DOWN(1:rtv%n_Angles,k))
575 refl_down_tl(:) = matmul(s_refl_up_tl,rtv%s_Layer_Source_DOWN(1:rtv%n_Angles,k)) &
576 + matmul(rtv%s_Level_Refl_UP(1:rtv%n_Angles,1:rtv%n_Angles,k),s_source_down_tl(:))
577 s_rad_up_tl(1:rtv%n_Angles)=s_source_up_tl(1:rtv%n_Angles)+ &
578 matmul(inv_gammat_tl,refl_down(:,k)+rtv%s_Level_Rad_UP(1:rtv%n_Angles,k)) &
579 +matmul(rtv%Inv_GammaT(1:rtv%n_Angles,1:rtv%n_Angles,k),refl_down_tl(1:rtv%n_Angles)+s_rad_up_tl(1:rtv%n_Angles))
581 refl_trans_tl = matmul(s_refl_up_tl,rtv%s_Layer_Trans(1:rtv%n_Angles,1:rtv%n_Angles,k)) &
582 + matmul(rtv%s_Level_Refl_UP(1:rtv%n_Angles,1:rtv%n_Angles,k),s_trans_tl)
584 s_refl_up_tl=s_refl_tl+matmul(inv_gammat_tl,rtv%Refl_Trans(1:rtv%n_Angles,1:rtv%n_Angles,k)) &
585 +matmul(rtv%Inv_GammaT(1:rtv%n_Angles,1:rtv%n_Angles,k),refl_trans_tl)
591 DO i = 1, rtv%n_Angles
592 s_trans_tl(i,i) = -t_od_tl(k)/rtv%COS_Angle(i) * rtv%s_Layer_Trans(i,i,k)
593 s_source_up_tl(i) = planck_atmosphere_tl(k) * (
one - rtv%s_Layer_Trans(i,i,k) ) &
594 - rtv%Planck_Atmosphere(k) * s_trans_tl(i,i)
595 s_source_down_tl(i) = s_source_up_tl(i)
599 DO i = 1, rtv%n_Angles
600 s_rad_up_tl(i)=s_source_up_tl(i) &
601 +s_trans_tl(i,i)*(sum(rtv%s_Level_Refl_UP(i,1:rtv%n_Angles,k) &
602 *rtv%s_Layer_Source_DOWN(1:rtv%n_Angles,k))+rtv%s_Level_Rad_UP(i,k)) &
603 +rtv%s_Layer_Trans(i,i,k) &
604 *(sum(s_refl_up_tl(i,1:rtv%n_Angles)*rtv%s_Layer_Source_DOWN(1:rtv%n_Angles,k) &
605 +rtv%s_Level_Refl_UP(i,1:rtv%n_Angles,k)*s_source_down_tl(1:rtv%n_Angles))+s_rad_up_tl(i))
609 DO i = 1, rtv%n_Angles
610 DO j = 1, rtv%n_Angles
611 s_refl_up_tl(i,j)=s_trans_tl(i,i)*rtv%s_Level_Refl_UP(i,j,k) &
612 *rtv%s_Layer_Trans(j,j,k) &
613 +rtv%s_Layer_Trans(i,i,k)*s_refl_up_tl(i,j)*rtv%s_Layer_Trans(j,j,k) &
614 +rtv%s_Layer_Trans(i,i,k)*rtv%s_Level_Refl_UP(i,j,k)*s_trans_tl(j,j)
622 IF( rtv%mth_Azi == 0 )
THEN 623 DO i = 1, rtv%n_Angles
624 s_rad_up_tl(i)=s_rad_up_tl(i)+sum(s_refl_up_tl(i,:))*cosmic_background
632 nZ, & ! Input, number of angles
633 KL, & ! Input, KL-th layer
634 single_albedo, & ! Input, single scattering albedo
635 optical_depth, & ! Input, layer optical depth
636 total_opt, & ! Input, accumulated optical depth from the top to current layer top
637 COS_Angle, & ! Input, COSINE of ANGLES
638 COS_Weight, & ! Input, GAUSSIAN Weights
639 ff, & ! Input, Phase matrix (forward part)
664 INTEGER,
INTENT(IN) :: n_streams,nZ,KL
665 TYPE(RTV_type),
INTENT( IN ) :: RTV
666 REAL(fp),
INTENT(IN),
DIMENSION(:,:) :: ff,bb
667 REAL(fp),
INTENT(IN),
DIMENSION(:) :: COS_Angle, COS_Weight
668 REAL(fp) :: single_albedo,optical_depth,Planck_Func,total_opt
671 REAL(fp) :: s, c, s_TL,c_TL,xx_TL
673 INTEGER :: Error_Status
676 REAL(fp),
INTENT(OUT),
DIMENSION( :,: ) :: trans_TL,refl_TL
677 REAL(fp),
INTENT(OUT),
DIMENSION( : ) :: source_up_TL,source_down_TL
679 REAL(fp),
INTENT(IN) :: single_albedo_TL
680 REAL(fp),
INTENT(IN) :: optical_depth_TL,Planck_Func_TL,total_opt_TL
681 REAL(fp),
INTENT(IN),
DIMENSION(:,:) :: ff_TL,bb_TL
683 REAL(fp),
DIMENSION(nZ) :: Exp_x_TL,EigVa_TL,EigValue_TL
684 REAL(fp),
DIMENSION(nZ,nZ) :: i_Gm_TL, Gm_TL, Gp_TL, EigVe_TL, EigVeF_TL, EigVeVa_TL
685 REAL(fp),
DIMENSION(nZ,nZ) :: A1_TL,A2_TL,A3_TL,A4_TL,A5_TL,A6_TL,Gm_A5_TL,i_Gm_A5_TL
686 REAL(fp),
DIMENSION(nZ,nZ) :: HH_TL,PM_TL,PP_TL,PPM_TL,i_PPM_TL,PPP_TL
688 REAL(fp) :: EXPfactor,Sfactor,s_transmittance,Solar(2*nZ),V0(2*nZ,2*nZ),Solar1(2*nZ)
689 REAL(fp) :: V1(2*nZ,2*nZ),Sfac2,source_up(nZ),source_down(nZ)
690 REAL(fp) :: EXPfactor_TL,Sfactor_TL,s_transmittance_TL,Solar_TL(2*nZ),V0_TL(2*nZ,2*nZ),Solar1_TL(2*nZ)
692 REAL(fp),
DIMENSION( nZ ) :: thermal_up_TL,thermal_down_TL
693 REAL(fp),
DIMENSION(nZ,nZ) :: trans, refl
695 REAL(fp) :: Thermal_C_TL
696 CHARACTER(*),
PARAMETER :: ROUTINE_NAME =
'CRTM_AMOM_layer_TL' 697 CHARACTER(256) :: Message
701 s = optical_depth * single_albedo
702 s_tl = optical_depth_tl * single_albedo + optical_depth * single_albedo_tl
706 c_tl = s_tl/cos_angle(i)
708 refl_tl(i,j) = (c_tl * bb(i,j) + c*bb_tl(i,j) )* cos_weight(j)
709 trans_tl(i,j) = (c_tl * ff(i,j) + c*ff_tl(i,j) )* cos_weight(j)
711 trans_tl(i,j) = trans_tl(i,j) - optical_depth_tl/cos_angle(i)
714 IF( rtv%mth_Azi == 0 )
THEN 715 thermal_c_tl = thermal_c_tl + refl_tl(i,j) + trans_tl(i,j)
718 IF( rtv%mth_Azi == 0 )
THEN 719 source_up_tl(i) = -thermal_c_tl * planck_func + &
720 (
one - rtv%Thermal_C(i,kl) ) * planck_func_tl
721 source_down_tl(i) = source_up_tl(i)
731 s_tl = single_albedo_tl
740 c_tl = s_tl/cos_angle(i)
742 pm_tl(i,j) = (c_tl * bb(i,j) + c*bb_tl(i,j) ) * cos_weight(j)
743 pp_tl(i,j) = (c_tl * ff(i,j) + c*ff_tl(i,j) ) * cos_weight(j)
747 ppm_tl(:,:) = pp_tl(:,:) - pm_tl(:,:)
748 i_ppm_tl(:,:) = - matmul( rtv%i_PPM(1:nz,1:nz,kl), matmul(ppm_tl(:,:),rtv%i_PPM(1:nz,1:nz,kl)) )
749 ppp_tl(:,:) = pp_tl(:,:) + pm_tl(:,:)
750 hh_tl(:,:) = matmul( ppm_tl(:,:), rtv%PPP(1:nz,1:nz,kl) )+matmul( rtv%PPM(1:nz,1:nz,kl), ppp_tl(:,:) )
753 CALL asymtx_tl(nz,rtv%EigVe(1:nz,1:nz,kl),rtv%EigVa(1:nz,kl),hh_tl, &
754 eigve_tl,eigva_tl,error_status)
757 IF( rtv%EigVa(i,kl) >
zero )
THEN 758 eigvalue_tl(i) = 0.5_fp*eigva_tl(i)/rtv%EigValue(i,kl)
760 eigvalue_tl(i) =
zero 767 eigveva_tl(i,j) = eigve_tl(i,j) * rtv%EigValue(j,kl)+rtv%EigVe(i,j,kl) * eigvalue_tl(j)
770 eigvef_tl(:,:) = matmul( i_ppm_tl(:,:), rtv%EigVeVa(1:nz,1:nz,kl) ) &
771 + matmul( rtv%i_PPM(1:nz,1:nz,kl), eigveva_tl(:,:) )
774 gp_tl(:,:) = ( eigve_tl(:,:) + eigvef_tl(:,:) )/2.0_fp
775 gm_tl(:,:) = ( eigve_tl(:,:) - eigvef_tl(:,:) )/2.0_fp
776 i_gm_tl = -matmul( rtv%i_Gm(1:nz,1:nz,kl), matmul(gm_tl,rtv%i_Gm(1:nz,1:nz,kl)) )
778 xx_tl = eigvalue_tl(i)*optical_depth+rtv%EigValue(i,kl)*optical_depth_tl
779 exp_x_tl(i) = -xx_tl*rtv%Exp_x(i,kl)
784 a1_tl(i,j) = gp_tl(i,j)* rtv%Exp_x(j,kl)+ rtv%Gp(i,j,kl)* exp_x_tl(j)
785 a4_tl(i,j) = gm_tl(i,j)* rtv%Exp_x(j,kl)+ rtv%Gm(i,j,kl)* exp_x_tl(j)
788 a2_tl(:,:) = matmul(i_gm_tl(:,:),rtv%A1(1:nz,1:nz,kl))+matmul(rtv%i_Gm(1:nz,1:nz,kl),a1_tl(:,:))
789 a3_tl(:,:) = matmul(gp_tl(:,:),rtv%A2(1:nz,1:nz,kl))+matmul(rtv%Gp(1:nz,1:nz,kl),a2_tl(:,:))
790 a5_tl(:,:) = matmul(a1_tl(:,:),rtv%A2(1:nz,1:nz,kl))+matmul(rtv%A1(1:nz,1:nz,kl),a2_tl(:,:))
791 a6_tl(:,:) = matmul(a4_tl(:,:),rtv%A2(1:nz,1:nz,kl))+matmul(rtv%A4(1:nz,1:nz,kl),a2_tl(:,:))
793 gm_a5_tl(:,:) = gm_tl(:,:) - a5_tl(:,:)
794 i_gm_a5_tl(:,:) = -matmul( rtv%i_Gm_A5(1:nz,1:nz,kl),matmul(gm_a5_tl,rtv%i_Gm_A5(1:nz,1:nz,kl)))
797 trans_tl = matmul( a4_tl(:,:) - a3_tl(:,:), rtv%i_Gm_A5(1:nz,1:nz,kl) ) &
798 + matmul( rtv%A4(1:nz,1:nz,kl) - rtv%A3(1:nz,1:nz,kl), i_gm_a5_tl(:,:) )
799 refl_tl = matmul( gp_tl(:,:) - a6_tl(:,:), rtv%i_Gm_A5(1:nz,1:nz,kl) ) &
800 + matmul( rtv%Gp(1:nz,1:nz,kl) - rtv%A6(1:nz,1:nz,kl), i_gm_a5_tl(:,:) )
802 trans(1:nz,1:nz) = rtv%s_Layer_Trans(1:nz,1:nz,kl)
803 refl(1:nz,1:nz) = rtv%s_Layer_Refl(1:nz,1:nz,kl)
805 source_down_tl =
zero 808 IF( rtv%mth_Azi == 0 )
THEN 812 thermal_c_tl = thermal_c_tl + (trans_tl(i,j) + refl_tl(i,j))
814 IF(i == nz .AND. nz == (n_streams+1))
THEN 815 thermal_c_tl = thermal_c_tl + trans_tl(nz,nz)
817 thermal_up_tl(i) = -thermal_c_tl * planck_func &
818 + (
one - rtv%Thermal_C(i,kl) ) * planck_func_tl
819 thermal_down_tl(i) = thermal_up_tl(i)
825 IF( rtv%Visible_Flag_true )
THEN 839 sfactor = single_albedo*rtv%Solar_irradiance/
pi 840 sfactor_tl = single_albedo_tl*rtv%Solar_irradiance/
pi 842 IF( rtv%mth_Azi == 0 )
THEN 843 sfactor = sfactor/
two 844 sfactor_tl = sfactor_tl/
two 846 expfactor = exp(-optical_depth/rtv%COS_SUN)
847 expfactor_tl = -optical_depth_tl/rtv%COS_SUN*expfactor
849 s_transmittance = exp(-total_opt/rtv%COS_SUN)
850 s_transmittance_tl = -total_opt_tl/rtv%COS_SUN*s_transmittance
853 solar(i) = -bb(i,nz+1)*sfactor
854 solar_tl(i) = -bb_tl(i,nz+1)*sfactor-bb(i,nz+1)*sfactor_tl
855 solar(i+nz) = -ff(i,nz+1)*sfactor
856 solar_tl(i+nz) = -ff_tl(i,nz+1)*sfactor-ff(i,nz+1)*sfactor_tl
858 v0(i,j) = single_albedo * ff(i,j) * cos_weight(j)
859 v0_tl(i,j) = single_albedo_tl*ff(i,j)*cos_weight(j)+single_albedo*ff_tl(i,j)*cos_weight(j)
860 v0(i+nz,j) = single_albedo * bb(i,j) * cos_weight(j)
861 v0_tl(i+nz,j) = single_albedo_tl*bb(i,j)*cos_weight(j)+single_albedo*bb_tl(i,j)*cos_weight(j)
862 v0(i,j+nz) = v0(i+nz,j)
863 v0_tl(i,j+nz) = v0_tl(i+nz,j)
864 v0(nz+i,j+nz) = v0(i,j)
865 v0_tl(nz+i,j+nz) = v0_tl(i,j)
867 v0(i,i) = v0(i,i) -
one - cos_angle(i)/rtv%COS_SUN
868 v0(i+nz,i+nz) = v0(i+nz,i+nz) -
one + cos_angle(i)/rtv%COS_SUN
871 v1(1:n2_1,1:n2_1) =
matinv(v0(1:n2_1,1:n2_1), error_status)
872 IF( error_status /=
success )
THEN 873 WRITE( message,
'("Error in matrix inversion matinv(V0(1:N2_1,1:N2_1), Error_Status) ")' )
880 solar1(1:n2_1) = matmul( v1(1:n2_1,1:n2_1), solar(1:n2_1) )
882 solar(1:n2_1) = matmul( v1(1:n2_1,1:n2_1),solar(1:n2_1) )
883 solar1_tl(1:n2_1) = matmul( v0_tl(1:n2_1,1:n2_1),solar(1:n2_1) )
884 solar1_tl(1:n2_1) = -matmul( v1(1:n2_1,1:n2_1),solar1_tl(1:n2_1) ) &
885 + matmul( v1(1:n2_1,1:n2_1), solar_tl(1:n2_1) )
889 sfac2 = solar(n2) - sum( v0(n2,1:n2_1)*solar1(1:n2_1) )
890 sfac2_tl = solar_tl(n2) - sum( v0_tl(n2,1:n2_1)*solar1(1:n2_1) ) &
891 - sum( v0(n2,1:n2_1)*solar1_tl(1:n2_1) )
894 source_up(i) = solar1(i)
895 source_up_tl(i) = solar1_tl(i)
896 source_down(i) = expfactor*solar1(i+nz)
897 source_down_tl(i) = expfactor_tl*solar1(i+nz)+expfactor*solar1_tl(i+nz)
899 source_up(i) =source_up(i)-refl(i,j)*solar1(j+nz)-trans(i,j)*expfactor*solar1(j)
900 source_up_tl(i) =source_up_tl(i)-refl_tl(i,j)*solar1(j+nz) -refl(i,j)*solar1_tl(j+nz) &
901 - trans_tl(i,j)*expfactor*solar1(j) - trans(i,j)*expfactor_tl*solar1(j) -trans(i,j)*expfactor*solar1_tl(j)
902 source_down(i) =source_down(i) -trans(i,j)*solar1(j+nz) -refl(i,j)*expfactor*solar1(j)
903 source_down_tl(i) =source_down_tl(i) -trans_tl(i,j)*solar1(j+nz) -trans(i,j)*solar1_tl(j+nz) &
904 -refl_tl(i,j)*expfactor*solar1(j) -refl(i,j)*expfactor_tl*solar1(j) -refl(i,j)*expfactor*solar1_tl(j)
909 IF( abs( v0(n2,n2) ) > 0.0001_fp )
THEN 910 source_down(nz) =source_down(nz) +(expfactor-trans(nz,nz))*sfac2/v0(n2,n2)
911 source_down_tl(nz) =source_down_tl(nz) +(expfactor_tl-trans_tl(nz,nz))*sfac2/v0(n2,n2) &
912 +(expfactor-trans(nz,nz))*sfac2_tl/v0(n2,n2)-(expfactor-trans(nz,nz))*sfac2*v0_tl(n2,n2)/v0(n2,n2)/v0(n2,n2)
914 source_down(nz) =source_down(nz) -expfactor*sfac2*optical_depth/cos_angle(nz)
915 source_down_tl(nz) =source_down_tl(nz) -expfactor_tl*sfac2*optical_depth/cos_angle(nz) &
916 -expfactor*sfac2_tl*optical_depth/cos_angle(nz)-expfactor*sfac2*optical_depth_tl/cos_angle(nz)
920 source_up_tl(1:nz) = source_up_tl(1:nz)*s_transmittance+source_up(1:nz)*s_transmittance_tl
922 source_down_tl(1:nz) = source_down_tl(1:nz)*s_transmittance + source_down(1:nz)*s_transmittance_tl
925 source_up_tl(:) = source_up_tl(:) + thermal_up_tl(:)
926 source_down_tl(:) = source_down_tl(:) + thermal_down_tl(:)
932 SUBROUTINE crtm_ada_ad(n_Layers, & ! Input number of atmospheric layers
933 w, & ! Input layer scattering albedo
934 T_OD, & ! Input layer optical depth
935 cosmic_background, & ! Input cosmic background radiance
936 emissivity, & ! Input surface emissivity
937 direct_reflectivity, & ! surface direct reflectivity
938 RTV, & ! Input structure containing forward results
939 s_rad_up_AD, & ! Input adjoint upward radiance
940 Planck_Atmosphere_AD, & ! Output AD atmospheric layer Planck radiance
941 Planck_Surface_AD, & ! Output AD surface Planck radiance
942 w_AD, & ! Output AD layer scattering albedo
943 T_OD_AD, & ! Output AD layer optical depth
944 emissivity_AD, & ! Output AD surface emissivity
945 reflectivity_AD, & ! Output AD surface reflectivity
946 direct_reflectivity_AD, & ! Output AD surface direct reflectivity
947 Pff_AD, & ! Output AD forward phase matrix
963 INTEGER,
INTENT(IN) :: n_layers
965 REAL (fp),
INTENT(IN),
DIMENSION( : ) :: w,t_od
966 REAL (fp),
INTENT(IN),
DIMENSION( : ) :: emissivity,direct_reflectivity
967 REAL (fp),
INTENT(IN) :: cosmic_background
969 REAL (fp),
INTENT(INOUT),
DIMENSION( :,:,: ) :: pff_ad, pbb_ad
970 REAL (fp),
INTENT(INOUT),
DIMENSION( : ) :: w_ad,t_od_ad
971 REAL (fp),
INTENT(INOUT),
DIMENSION( 0: ) :: planck_atmosphere_ad
972 REAL (fp),
INTENT(INOUT) :: planck_surface_ad
973 REAL (fp),
INTENT(INOUT),
DIMENSION( : ) :: emissivity_ad,direct_reflectivity_ad
974 REAL (fp),
INTENT(INOUT),
DIMENSION( :,: ) :: reflectivity_ad
975 REAL (fp),
INTENT(INOUT),
DIMENSION( : ) :: s_rad_up_ad
981 REAL (fp),
DIMENSION(RTV%n_Angles,RTV%n_Angles) :: temporal_matrix_ad
983 REAL (fp),
DIMENSION( RTV%n_Angles, n_Layers) :: refl_down
984 REAL (fp),
DIMENSION( RTV%n_Angles ) :: s_source_up_ad,s_source_down_ad,refl_down_ad
986 REAL (fp),
DIMENSION( RTV%n_Angles, RTV%n_Angles) :: s_trans_ad,s_refl_ad,refl_trans_ad
987 REAL (fp),
DIMENSION( RTV%n_Angles, RTV%n_Angles) :: s_refl_up_ad,inv_gamma_ad,inv_gammat_ad
988 REAL (fp) :: sum_s_ad, sums_ad, xx
989 REAL (fp),
DIMENSION(0:n_Layers) :: total_opt, total_opt_ad
990 INTEGER :: i, j, k,nz
997 total_opt(k) = total_opt(k-1) + t_od(k)
1001 planck_atmosphere_ad =
zero 1002 planck_surface_ad =
zero 1010 DO i = 1, rtv%n_Angles
1011 sum_s_ad = s_rad_up_ad(i)*cosmic_background
1012 DO j = 1, rtv%n_Angles
1013 s_refl_up_ad(i,j) = sum_s_ad
1018 DO 10 k = 1, n_layers
1019 s_source_up_ad =
zero 1020 s_source_down_ad =
zero 1026 refl_down(1:rtv%n_Angles,k) = matmul(rtv%s_Level_Refl_UP(1:rtv%n_Angles,1:rtv%n_Angles,k), &
1027 rtv%s_Layer_Source_DOWN(1:rtv%n_Angles,k))
1029 s_refl_ad = s_refl_up_ad
1030 inv_gammat_ad = matmul(s_refl_up_ad,transpose(rtv%Refl_Trans(1:rtv%n_Angles,1:rtv%n_Angles,k)))
1031 refl_trans_ad = matmul(transpose(rtv%Inv_GammaT(1:rtv%n_Angles,1:rtv%n_Angles,k)),s_refl_up_ad)
1033 s_refl_up_ad=matmul(refl_trans_ad,transpose(rtv%s_Layer_Trans(1:rtv%n_Angles,1:rtv%n_Angles,k)))
1034 s_trans_ad=matmul(transpose(rtv%s_Level_Refl_UP(1:rtv%n_Angles,1:rtv%n_Angles,k)),refl_trans_ad)
1036 s_source_up_ad(1:rtv%n_Angles) = s_rad_up_ad(1:rtv%n_Angles)
1038 DO i = 1, rtv%n_Angles
1039 sums_ad = s_rad_up_ad(i)
1040 DO j = 1, rtv%n_Angles
1041 inv_gammat_ad(i,j)=inv_gammat_ad(i,j)+sums_ad*(refl_down(j,k)+rtv%s_Level_Rad_UP(j,k))
1045 refl_down_ad(1:rtv%n_Angles)=matmul(transpose(rtv%Inv_GammaT(1:rtv%n_Angles,1:rtv%n_Angles,k)),s_rad_up_ad(1:rtv%n_Angles))
1046 s_rad_up_ad(1:rtv%n_Angles)=matmul(transpose(rtv%Inv_GammaT(1:rtv%n_Angles,1:rtv%n_Angles,k)),s_rad_up_ad(1:rtv%n_Angles))
1048 DO i = 1, rtv%n_Angles
1049 sums_ad = refl_down_ad(i)
1050 DO j = 1, rtv%n_Angles
1051 s_refl_up_ad(i,j)=s_refl_up_ad(i,j)+sums_ad*rtv%s_Layer_Source_DOWN(j,k)
1055 s_source_down_ad=matmul(transpose(rtv%s_Level_Refl_UP(1:rtv%n_Angles,1:rtv%n_Angles,k)),refl_down_ad(:))
1057 s_trans_ad=s_trans_ad+matmul(inv_gammat_ad,transpose(rtv%Inv_Gamma(1:rtv%n_Angles,1:rtv%n_Angles,k)))
1058 inv_gamma_ad= matmul(transpose(rtv%s_Layer_Trans(1:rtv%n_Angles,1:rtv%n_Angles,k)),inv_gammat_ad)
1060 temporal_matrix_ad= -matmul(inv_gamma_ad,transpose(rtv%Inv_Gamma(1:rtv%n_Angles,1:rtv%n_Angles,k)))
1061 temporal_matrix_ad=matmul(transpose(rtv%Inv_Gamma(1:rtv%n_Angles,1:rtv%n_Angles,k)),temporal_matrix_ad)
1063 s_refl_up_ad=s_refl_up_ad-matmul(temporal_matrix_ad,transpose(rtv%s_Layer_Refl(1:rtv%n_Angles,1:rtv%n_Angles,k)))
1064 s_refl_ad=s_refl_ad-matmul(transpose(rtv%s_Level_Refl_UP(1:rtv%n_Angles,1:rtv%n_Angles,k)),temporal_matrix_ad)
1071 rtv%COS_Angle,rtv%COS_Weight,rtv%Pff(:,:,k),rtv%Pbb(:,:,k),rtv%Planck_Atmosphere(k), &
1072 s_trans_ad,s_refl_ad,s_source_up_ad,s_source_down_ad,rtv,w_ad(k),t_od_ad(k) , &
1073 total_opt_ad(k-1),pff_ad(:,:,k),pbb_ad(:,:,k),planck_atmosphere_ad(k))
1076 DO i = 1, rtv%n_Angles
1077 DO j = 1, rtv%n_Angles
1078 s_trans_ad(j,j)=s_trans_ad(j,j)+rtv%s_Layer_Trans(i,i,k)*rtv%s_Level_Refl_UP(i,j,k)*s_refl_up_ad(i,j)
1079 s_trans_ad(i,i)=s_trans_ad(i,i)+s_refl_up_ad(i,j)*rtv%s_Level_Refl_UP(i,j,k)*rtv%s_Layer_Trans(j,j,k)
1080 s_refl_up_ad(i,j)=rtv%s_Layer_Trans(i,i,k)*s_refl_up_ad(i,j)*rtv%s_Layer_Trans(j,j,k)
1084 DO i = 1, rtv%n_Angles
1086 s_source_up_ad(i)=s_rad_up_ad(i)
1087 s_trans_ad(i,i)=s_trans_ad(i,i)+s_rad_up_ad(i)*(sum(rtv%s_Level_Refl_UP(i,1:rtv%n_Angles,k) &
1088 *rtv%s_Layer_Source_DOWN(1:rtv%n_Angles,k))+rtv%s_Level_Rad_UP(i,k))
1090 sum_s_ad=rtv%s_Layer_Trans(i,i,k)*s_rad_up_ad(i)
1091 DO j = 1, rtv%n_Angles
1092 s_refl_up_ad(i,j)=s_refl_up_ad(i,j)+sum_s_ad*rtv%s_Layer_Source_DOWN(j,k)
1095 sum_s_ad=rtv%s_Layer_Trans(i,i,k)*s_rad_up_ad(i)
1096 DO j = 1, rtv%n_Angles
1097 s_source_down_ad(j)=s_source_down_ad(j)+sum_s_ad*rtv%s_Level_Refl_UP(i,j,k)
1099 s_rad_up_ad(i)=rtv%s_Layer_Trans(i,i,k)*s_rad_up_ad(i)
1103 DO i = rtv%n_Angles, 1, -1
1104 s_source_up_ad(i) = s_source_up_ad(i) + s_source_down_ad(i)
1105 s_trans_ad(i,i) = s_trans_ad(i,i) - rtv%Planck_Atmosphere(k) * s_source_up_ad(i)
1106 planck_atmosphere_ad(k) = planck_atmosphere_ad(k) + s_source_up_ad(i) * (
one - rtv%s_Layer_Trans(i,i,k) )
1107 s_source_up_ad(i) =
zero 1109 t_od_ad(k)=t_od_ad(k)-s_trans_ad(i,i)/rtv%COS_Angle(i)*rtv%s_Layer_Trans(i,i,k)
1117 IF( rtv%Solar_Flag_true )
THEN 1118 xx = rtv%Solar_irradiance/
pi * exp(-total_opt(n_layers)/rtv%COS_SUN)
1119 total_opt_ad(n_layers) = total_opt_ad(n_layers) &
1120 - xx*sum(direct_reflectivity(1:rtv%n_Angles)*s_rad_up_ad(1:rtv%n_Angles))
1121 direct_reflectivity_ad = direct_reflectivity_ad + s_rad_up_ad * rtv%COS_SUN * xx
1124 emissivity_ad = s_rad_up_ad * rtv%Planck_Surface
1125 planck_surface_ad = sum(emissivity(:) * s_rad_up_ad(:) )
1128 reflectivity_ad = s_refl_up_ad
1134 DO k = n_layers, 1, -1
1135 t_od_ad(k) = t_od_ad(k) + total_opt_ad(k)
1136 total_opt_ad(k-1) = total_opt_ad(k-1) + total_opt_ad(k)
1145 nZ, & ! Input, number of angles
1146 KL, & ! Input, KL-th layer
1147 single_albedo, & ! Input, single scattering albedo
1148 optical_depth, & ! Input, layer optical depth
1149 total_opt, & ! Input,
1150 COS_Angle, & ! Input, COSINE of ANGLES
1151 COS_Weight, & ! Input, GAUSSIAN Weights
1152 ff, & ! Input, Phase matrix (forward part)
1176 INTEGER,
INTENT(IN) :: n_streams,nZ,KL
1177 TYPE(RTV_type),
INTENT( IN ) :: RTV
1178 REAL(fp),
INTENT(IN),
DIMENSION(:,:) :: ff,bb
1179 REAL(fp),
INTENT(IN),
DIMENSION(:) :: COS_Angle, COS_Weight
1180 REAL(fp) :: single_albedo,optical_depth,Planck_Func,total_opt
1183 REAL(fp) :: s, c, s_AD,c_AD,xx_AD
1185 INTEGER :: Error_Status
1188 REAL(fp),
INTENT( INOUT ),
DIMENSION( :,: ) :: trans_AD,refl_AD
1189 REAL(fp),
INTENT( INOUT ),
DIMENSION( : ) :: source_up_AD,source_down_AD
1190 REAL(fp),
INTENT( INOUT ) :: single_albedo_AD
1191 REAL(fp),
INTENT( INOUT ) :: optical_depth_AD,Planck_Func_AD,total_opt_AD
1192 REAL(fp),
INTENT(INOUT),
DIMENSION(:,:) :: ff_AD,bb_AD
1194 REAL(fp),
DIMENSION(nZ) :: Exp_x_AD,EigVa_AD,EigValue_AD
1195 REAL(fp),
DIMENSION(nZ,nZ) :: i_Gm_AD, Gm_AD, Gp_AD, EigVe_AD, EigVeF_AD, EigVeVa_AD
1196 REAL(fp),
DIMENSION(nZ,nZ) :: A1_AD,A2_AD,A3_AD,A4_AD,A5_AD,A6_AD,Gm_A5_AD,i_Gm_A5_AD
1197 REAL(fp),
DIMENSION(nZ,nZ) :: HH_AD,PM_AD,PP_AD,PPM_AD,i_PPM_AD,PPP_AD
1199 REAL(fp),
DIMENSION(nZ) :: thermal_up_AD, thermal_down_AD
1200 REAL(fp) :: EXPfactor,Sfactor,s_transmittance,Solar(2*nZ),V0(2*nZ,2*nZ),Solar1(2*nZ)
1201 REAL(fp) :: V1(2*nZ,2*nZ),Sfac2,source_up(nZ),source_down(nZ)
1202 REAL(fp) :: EXPfactor_AD,Sfactor_AD,s_transmittance_AD,Solar_AD(2*nZ),V0_AD(2*nZ,2*nZ),Solar1_AD(2*nZ)
1203 REAL(fp) :: V1_AD(2*nZ,2*nZ),Sfac2_AD
1204 REAL(fp),
DIMENSION(nZ,nZ) :: trans, refl
1206 REAL(fp) :: Thermal_C_AD
1207 CHARACTER(*),
PARAMETER :: ROUTINE_NAME =
'CRTM_AMOM_layer_AD' 1208 CHARACTER(256) :: Message
1215 s = optical_depth * single_albedo
1218 IF( rtv%mth_Azi == 0 )
THEN 1219 source_up_ad(i) = source_up_ad(i) + source_down_ad(i)
1220 source_down_ad(i) =
zero 1221 planck_func_ad = planck_func_ad + (
one - rtv%Thermal_C(i,kl))*source_up_ad(i)
1222 thermal_c_ad = -source_up_ad(i) * planck_func
1226 IF( rtv%mth_Azi == 0 )
THEN 1227 refl_ad(i,j) = refl_ad(i,j) + thermal_c_ad
1228 trans_ad(i,j) = trans_ad(i,j) + thermal_c_ad
1231 optical_depth_ad = optical_depth_ad - trans_ad(i,j)/cos_angle(i)
1234 c_ad = c_ad + trans_ad(i,j) * ff(i,j) * cos_weight(j)
1235 ff_ad(i,j) = ff_ad(i,j) + c * trans_ad(i,j) * cos_weight(j)
1236 c_ad = c_ad + refl_ad(i,j) * bb(i,j) * cos_weight(j)
1237 bb_ad(i,j) = bb_ad(i,j) + c * refl_ad(i,j) * cos_weight(j)
1240 source_up_ad(i) =
zero 1241 s_ad = s_ad + c_ad/cos_angle(i)
1244 optical_depth_ad = optical_depth_ad + s_ad * single_albedo
1245 single_albedo_ad = single_albedo_ad + optical_depth * s_ad
1249 trans(1:nz,1:nz) = rtv%s_Layer_Trans(1:nz,1:nz,kl)
1250 refl(1:nz,1:nz) = rtv%s_Layer_Refl(1:nz,1:nz,kl)
1252 thermal_up_ad(:) = source_up_ad(:)
1253 thermal_down_ad(:) = source_down_ad(:)
1255 IF( rtv%Visible_Flag_true )
THEN 1267 s_transmittance_ad =
zero 1272 sfactor = single_albedo*rtv%Solar_irradiance/
pi 1273 IF( rtv%mth_Azi == 0 ) sfactor = sfactor/
two 1274 expfactor = exp(-optical_depth/rtv%COS_SUN)
1275 s_transmittance = exp(-total_opt/rtv%COS_SUN)
1278 solar(i) = -bb(i,nz+1)*sfactor
1279 solar(i+nz) = -ff(i,nz+1)*sfactor
1282 v0(i,j) = single_albedo * ff(i,j) * cos_weight(j)
1283 v0(i+nz,j) = single_albedo * bb(i,j) * cos_weight(j)
1284 v0(i,j+nz) = v0(i+nz,j)
1285 v0(nz+i,j+nz) = v0(i,j)
1287 v0(i,i) = v0(i,i) -
one - cos_angle(i)/rtv%COS_SUN
1288 v0(i+nz,i+nz) = v0(i+nz,i+nz) -
one + cos_angle(i)/rtv%COS_SUN
1291 v1(1:n2_1,1:n2_1) =
matinv(v0(1:n2_1,1:n2_1), error_status)
1292 IF( error_status /=
success )
THEN 1293 WRITE( message,
'("Error in matrix inversion matinv(V0(1:N2_1,1:N2_1), Error_Status) ")' )
1300 solar1(1:n2_1) = matmul( v1(1:n2_1,1:n2_1), solar(1:n2_1) )
1302 sfac2 = solar(n2) - sum( v0(n2,1:n2_1)*solar1(1:n2_1) )
1305 source_up(i) = solar1(i)
1306 source_down(i) = expfactor*solar1(i+nz)
1308 source_up(i) =source_up(i)-refl(i,j)*solar1(j+nz)-trans(i,j)*expfactor*solar1(j)
1309 source_down(i) =source_down(i) -trans(i,j)*solar1(j+nz) -refl(i,j)*expfactor*solar1(j)
1313 IF( abs( v0(n2,n2) ) > 0.0001_fp )
THEN 1314 source_down(nz) =source_down(nz) +(expfactor-trans(nz,nz))*sfac2/v0(n2,n2)
1316 source_down(nz) =source_down(nz) -expfactor*sfac2*optical_depth/cos_angle(nz)
1321 s_transmittance_ad = s_transmittance_ad+sum(source_down(1:nz)*source_down_ad(1:nz) )
1322 source_down_ad(1:nz) = source_down_ad(1:nz)*s_transmittance
1323 s_transmittance_ad = s_transmittance_ad + sum(source_up(1:nz)*source_up_ad(1:nz) )
1324 source_up_ad(1:nz) = source_up_ad(1:nz)*s_transmittance
1327 IF( abs( v0(n2,n2) ) > 0.0001_fp )
THEN 1328 v0_ad(n2,n2)=v0_ad(n2,n2)-(expfactor-trans(nz,nz))*sfac2*source_down_ad(nz)/v0(n2,n2)/v0(n2,n2)
1329 sfac2_ad = sfac2_ad+(expfactor-trans(nz,nz))*source_down_ad(nz)/v0(n2,n2)
1330 expfactor_ad = expfactor_ad+source_down_ad(nz)*sfac2/v0(n2,n2)
1331 trans_ad(nz,nz) = trans_ad(nz,nz)-source_down_ad(nz)*sfac2/v0(n2,n2)
1333 optical_depth_ad = optical_depth_ad -expfactor*sfac2*source_down_ad(nz)/cos_angle(nz)
1334 sfac2_ad = sfac2_ad-expfactor*source_down_ad(nz)*optical_depth/cos_angle(nz)
1335 expfactor_ad = expfactor_ad-source_down_ad(nz)*sfac2*optical_depth/cos_angle(nz)
1340 solar1_ad(j)=solar1_ad(j)-refl(i,j)*expfactor*source_down_ad(i)
1341 expfactor_ad = expfactor_ad -refl(i,j)*source_down_ad(i)*solar1(j)
1342 refl_ad(i,j) = refl_ad(i,j) -source_down_ad(i)*expfactor*solar1(j)
1343 solar1_ad(j+nz) = solar1_ad(j+nz) -trans(i,j)*source_down_ad(i)
1344 trans_ad(i,j) = trans_ad(i,j) -source_down_ad(i)*solar1(j+nz)
1346 solar1_ad(j)=solar1_ad(j)-trans(i,j)*expfactor*source_up_ad(i)
1347 expfactor_ad = expfactor_ad - trans(i,j)*source_up_ad(i)*solar1(j)
1348 trans_ad(i,j)=trans_ad(i,j) - source_up_ad(i)*expfactor*solar1(j)
1349 solar1_ad(j+nz) = solar1_ad(j+nz) -refl(i,j)*source_up_ad(i)
1350 refl_ad(i,j) = refl_ad(i,j) -source_up_ad(i)*solar1(j+nz)
1353 solar1_ad(i+nz) = solar1_ad(i+nz) + expfactor * source_down_ad(i)
1354 expfactor_ad = expfactor_ad + source_down_ad(i)*solar1(i+nz)
1355 solar1_ad(i) = solar1_ad(i) + source_up_ad(i)
1358 solar1_ad(1:n2_1)=solar1_ad(1:n2_1) -sfac2_ad*v0(n2,1:n2_1)
1359 v0_ad(n2,1:n2_1)=v0_ad(n2,1:n2_1) -sfac2_ad*solar1(1:n2_1)
1360 solar_ad(n2) = solar_ad(n2) + sfac2_ad
1362 solar1_ad(n2) =
zero 1363 solar_ad(1:n2_1)=solar_ad(1:n2_1)+matmul( transpose(v1(1:n2_1,1:n2_1)),solar1_ad(1:n2_1) )
1364 solar(1:n2_1) = matmul( v1(1:n2_1,1:n2_1),solar(1:n2_1) )
1365 solar1_ad(1:n2_1) = -matmul( transpose(v1(1:n2_1,1:n2_1)),solar1_ad(1:n2_1) )
1368 v0_ad(i,j)=v0_ad(i,j)+solar1_ad(i)*solar(j)
1375 v0_ad(i,j)=v0_ad(i,j) + v0_ad(nz+i,j+nz)
1376 v0_ad(i+nz,j)=v0_ad(i+nz,j) + v0_ad(i,j+nz)
1377 bb_ad(i,j)=bb_ad(i,j) + single_albedo*v0_ad(i+nz,j)*cos_weight(j)
1378 single_albedo_ad=single_albedo_ad + v0_ad(i+nz,j)*bb(i,j)*cos_weight(j)
1379 ff_ad(i,j)=ff_ad(i,j) + single_albedo*v0_ad(i,j)*cos_weight(j)
1380 single_albedo_ad=single_albedo_ad +v0_ad(i,j)*ff(i,j)*cos_weight(j)
1383 sfactor_ad = sfactor_ad -ff(i,nz+1)*solar_ad(i+nz)
1384 ff_ad(i,nz+1) = ff_ad(i,nz+1) -solar_ad(i+nz)*sfactor
1385 sfactor_ad = sfactor_ad -bb(i,nz+1)*solar_ad(i)
1386 bb_ad(i,nz+1)=bb_ad(i,nz+1) - solar_ad(i)*sfactor
1389 total_opt_ad = total_opt_ad -s_transmittance_ad/rtv%COS_SUN*s_transmittance
1390 optical_depth_ad = optical_depth_ad -expfactor_ad/rtv%COS_SUN*expfactor
1392 IF( rtv%mth_Azi == 0 )
THEN 1393 sfactor_ad = sfactor_ad/
two 1396 single_albedo_ad = single_albedo_ad + sfactor_ad*rtv%Solar_irradiance/
pi 1401 IF( rtv%mth_Azi == 0 )
THEN 1403 thermal_up_ad(i) = thermal_up_ad(i) + thermal_down_ad(i)
1404 thermal_down_ad(i) =
zero 1405 planck_func_ad = planck_func_ad + (
one - rtv%Thermal_C(i,kl) ) * thermal_up_ad(i)
1406 thermal_c_ad = -thermal_up_ad(i) * planck_func
1408 IF ( i == nz .AND. nz == (n_streams+1) )
THEN 1409 trans_ad(nz,nz) = trans_ad(nz,nz) + thermal_c_ad
1412 DO j = n_streams, 1, -1
1413 trans_ad(i,j) = trans_ad(i,j) + thermal_c_ad
1414 refl_ad(i,j) = refl_ad(i,j) + thermal_c_ad
1416 thermal_up_ad(i) =
zero 1420 i_gm_a5_ad = matmul( transpose(rtv%Gp(1:nz,1:nz,kl)-rtv%A6(1:nz,1:nz,kl)),refl_ad )
1421 gp_ad(:,:) = matmul( refl_ad, transpose(rtv%i_Gm_A5(1:nz,1:nz,kl)) )
1424 i_gm_a5_ad = i_gm_a5_ad + matmul( transpose(rtv%A4(1:nz,1:nz,kl)-rtv%A3(1:nz,1:nz,kl)),trans_ad )
1425 a4_ad(:,:) = matmul( trans_ad, transpose(rtv%i_Gm_A5(1:nz,1:nz,kl)) )
1427 gm_a5_ad = -matmul( transpose(rtv%i_Gm_A5(1:nz,1:nz,kl)) ,matmul( i_gm_a5_ad,transpose(rtv%i_Gm_A5(1:nz,1:nz,kl)) ) )
1431 a4_ad = a4_ad + matmul( a6_ad(:,:), transpose(rtv%A2(1:nz,1:nz,kl)) )
1432 a2_ad = matmul( transpose(rtv%A4(1:nz,1:nz,kl)),a6_ad(:,:) )
1434 a1_ad = matmul( a5_ad(:,:), transpose(rtv%A2(1:nz,1:nz,kl)) )
1435 a2_ad = a2_ad + matmul( transpose(rtv%A1(1:nz,1:nz,kl)), a5_ad(:,:) )
1437 gp_ad = gp_ad + matmul( a3_ad(:,:), transpose(rtv%A2(1:nz,1:nz,kl)) )
1438 a2_ad = a2_ad + matmul( transpose(rtv%Gp(1:nz,1:nz,kl)),a3_ad(:,:) )
1440 i_gm_ad = matmul( a2_ad(:,:), transpose(rtv%A1(1:nz,1:nz,kl)) )
1441 a1_ad = a1_ad + matmul( transpose(rtv%i_Gm(1:nz,1:nz,kl)), a2_ad(:,:) )
1447 gm_ad(i,j) = gm_ad(i,j) + a4_ad(i,j)* rtv%Exp_x(j,kl)
1448 exp_x_ad(j) = exp_x_ad(j) + rtv%Gm(i,j,kl)*a4_ad(i,j)
1449 gp_ad(i,j) = gp_ad(i,j) + a1_ad(i,j)* rtv%Exp_x(j,kl)
1450 exp_x_ad(j) = exp_x_ad(j) + rtv%Gp(i,j,kl)*a1_ad(i,j)
1455 xx_ad = -exp_x_ad(i)*rtv%Exp_x(i,kl)
1457 eigvalue_ad(i) = xx_ad*optical_depth
1458 optical_depth_ad = optical_depth_ad + rtv%EigValue(i,kl)*xx_ad
1461 gm_ad = gm_ad -matmul( transpose(rtv%i_Gm(1:nz,1:nz,kl)), matmul( i_gm_ad, transpose(rtv%i_Gm(1:nz,1:nz,kl)) ) )
1463 eigve_ad(:,:) = gm_ad(:,:)/2.0_fp
1464 eigvef_ad(:,:) = - gm_ad(:,:)/2.0_fp
1466 eigve_ad = eigve_ad + gp_ad(:,:)/2.0_fp
1467 eigvef_ad = eigvef_ad + gp_ad(:,:)/2.0_fp
1469 i_ppm_ad(:,:) = matmul( eigvef_ad(:,:), transpose(rtv%EigVeVa(1:nz,1:nz,kl)) )
1470 eigveva_ad(:,:) = matmul( transpose(rtv%i_PPM(1:nz,1:nz,kl)), eigvef_ad(:,:) )
1474 eigve_ad(i,j)=eigve_ad(i,j)+eigveva_ad(i,j)* rtv%EigValue(j,kl)
1475 eigvalue_ad(j) = eigvalue_ad(j)+rtv%EigVe(i,j,kl)*eigveva_ad(i,j)
1480 IF( rtv%EigVa(i,kl) >
zero )
THEN 1481 eigva_ad(i) = 0.5_fp*eigvalue_ad(i)/rtv%EigValue(i,kl)
1483 eigvalue_ad(i) =
zero 1489 CALL asymtx_ad(nz,rtv%EigVe(1:nz,1:nz,kl),rtv%EigVa(1:nz,kl), &
1490 eigve_ad,eigva_ad,hh_ad,error_status)
1492 ppm_ad(:,:) = matmul( hh_ad(:,:), transpose(rtv%PPP(1:nz,1:nz,kl)) )
1493 ppp_ad(:,:) = matmul( transpose(rtv%PPM(1:nz,1:nz,kl)), hh_ad(:,:) )
1498 ppm_ad(:,:) = ppm_ad(:,:)-matmul( transpose(rtv%i_PPM(1:nz,1:nz,kl)),matmul(i_ppm_ad(:,:),transpose(rtv%i_PPM(1:nz,1:nz,kl))) )
1500 pp_ad = pp_ad + ppm_ad
1501 pm_ad = pm_ad - ppm_ad
1514 c_ad = c_ad + pp_ad(i,j) * ff(i,j) * cos_weight(j)
1515 ff_ad(i,j) = ff_ad(i,j) + c * pp_ad(i,j) * cos_weight(j)
1516 c_ad = c_ad + pm_ad(i,j) * bb(i,j) * cos_weight(j)
1517 bb_ad(i,j) = bb_ad(i,j) + c * pm_ad(i,j) * cos_weight(j)
1519 s_ad = s_ad + c_ad/cos_angle(i)
1525 single_albedo_ad = s_ad + single_albedo_ad
real(fp), parameter, public zero
subroutine, public crtm_ada(n_Layers, w, T_OD, cosmic_background, emissivity, reflectivity, direct_reflectivity, RTV)
real(fp), parameter, public scattering_albedo_threshold
real(fp), parameter, public delta_optical_depth
subroutine crtm_amom_layer_tl(n_streams, nZ, KL, single_albedo, optical_depth, total_opt, COS_Angle, COS_Weight, ff, bb, Planck_Func, single_albedo_TL, optical_depth_TL, total_opt_TL, ff_TL, bb_TL, Planck_Func_TL, RTV, trans_TL, refl_TL, source_up_TL, source_down_TL)
subroutine, public asymtx_tl(nZ, V, VAL, A_TL, V_TL, VAL_TL, Error_Status)
subroutine crtm_amom_layer(n_streams, nZ, KL, single_albedo, optical_depth, total_opt, COS_Angle, COS_Weight, ff, bb, Planck_Func, RTV)
subroutine crtm_amom_layer_ad(n_streams, nZ, KL, single_albedo, optical_depth, total_opt, 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, total_opt_AD, ff_AD, bb_AD, Planck_Func_AD)
subroutine, public crtm_ada_tl(n_Layers, w, T_OD, cosmic_background, emissivity, direct_reflectivity, RTV, Planck_Atmosphere_TL, Planck_Surface_TL, w_TL, T_OD_TL, emissivity_TL, reflectivity_TL, direct_reflectivity_TL, Pff_TL, Pbb_TL, s_rad_up_TL)
character(*), parameter module_version_id
real(fp), parameter, public one
recursive subroutine, public display_message(Routine_Name, Message, Error_State, Message_Log)
real(fp), parameter, public two
real(fp), parameter, public max_albedo
subroutine, public asymtx(AAD, M, IA, IEVEC, EVECD, EVALD, IER)
integer, parameter, public success
real(fp) function, dimension(size(a, 1), size(a, 2)), public matinv(A, Error_Status)
real(fp), parameter, public pi
subroutine, public asymtx_ad(nZ, V, VAL, V_AD, VAL_AD, A_AD, Error_Status)
subroutine, public crtm_ada_ad(n_Layers, w, T_OD, cosmic_background, emissivity, direct_reflectivity, RTV, s_rad_up_AD, Planck_Atmosphere_AD, Planck_Surface_AD, w_AD, T_OD_AD, emissivity_AD, reflectivity_AD, direct_reflectivity_AD, Pff_AD, Pbb_AD)