24 REAL,
intent(in) :: residual(:)
25 INTEGER,
intent(out) :: crossing_num, crossing_vector(:)
33 length =
size(residual)
42 if ( residual(i) < 0 ) k(i) = -1
47 crossing_num=0; crossing_vector=0.
49 if(
abs(k(i+1)-k(i)) > 1) then
50 crossing_num = crossing_num + 1
51 crossing_vector(crossing_num) = i
75 REAL,
intent(in) :: residual(:)
76 INTEGER,
intent(out) :: local_min_num, local_min_vector(:)
81 length =
size(residual)
83 local_min_num=0; local_min_vector=0.
87 if( residual(i) < residual(i-1) .AND. residual(i) < residual(i+1) ) then
88 local_min_num = local_min_num + 1
89 local_min_vector(local_min_num) = i
112 REAL,
intent(in) :: residual(:)
113 INTEGER,
intent(out) :: local_max_num, local_max_vector(:)
118 length =
size(residual)
120 local_max_num=0; local_max_vector=0.
124 if( residual(i) > residual(i-1) .AND. residual(i) > residual(i+1) ) then
125 local_max_num = local_max_num + 1
126 local_max_vector(local_max_num) = i
134 subroutine solution_re (re, residual, crossing_vector, crossing_num, &
135 local_min_vector, local_min_num, local_max_vector, local_max_num, &
159 integer,
intent(in) :: crossing_vector(:), crossing_num, &
160 local_min_vector(:), local_min_num, local_max_vector(:), local_max_num
161 real,
intent(in) :: residual(:), re(:)
163 real,
intent(out) :: retrieval
164 integer*1,
intent(out) :: quality
166 integer :: residual_crossing_index, index1(1)
167 real :: fillval_r4, resid_lo, resid_hi, slope_1, slope_2
168 logical :: process_zero_crossing_residual
211 process_zero_crossing_residual = .false.
216 retrieval = fillval_r4; quality = -1
222 if (crossing_num < 0)
then
230 if (crossing_num > 2)
then
257 IF (crossing_num == 0)
THEN
258 if (process_zero_crossing_residual)
then
260 index1 = minloc(
abs(residual))
261 retrieval = re(index1(1))
273 IF (crossing_num == 1 .OR. crossing_num == 2)
THEN
282 If (crossing_num == 1)
Then
283 residual_crossing_index = crossing_vector(crossing_num)
286 slope_1 = residual(crossing_vector(1)+1) - residual(crossing_vector(1))
287 slope_2 = residual(crossing_vector(2)+1) - residual(crossing_vector(2))
295 if ( slope_1 <= 0. )
then
296 residual_crossing_index = crossing_vector(1)
298 if ( slope_2 <= 0. )
then
299 residual_crossing_index = crossing_vector(2)
308 if (residual_crossing_index > 0) &
310 fillval_r4, local_min_vector, local_min_num, local_max_vector, &
311 local_max_num, retrieval, quality)
318 residual_crossing_index, fillval_r4, &
319 local_min_vector, local_min_num, local_max_vector, local_max_num, &
343 real,
intent (in) :: re(:), residual(:), fillval_r4
344 integer,
intent (in) :: residual_crossing_index, &
345 local_min_vector(:), local_min_num, local_max_vector(:), local_max_num
347 real,
intent(inout) :: retrieval
348 integer*1,
intent(inout) :: quality
350 integer i, icount, iternum
351 real y2(size(re)), z, delta_resid, delta_resid_fraction, &
352 resid_min_allowable, resid_max_for_spline
353 real yl(2), xl(2), re_lower, re_upper, re_iter
355 character*15 numerical_type
366 resid_min_allowable = 0.0001
367 if (
abs(residual(residual_crossing_index)) < resid_min_allowable)
then
368 retrieval = re(residual_crossing_index)
372 if (
abs(residual(residual_crossing_index+1)) < resid_min_allowable)
then
373 retrieval = re(residual_crossing_index+1)
384 residual(residual_crossing_index+1)))
then
385 retrieval = re(residual_crossing_index)
394 numerical_type =
'spline'
430 IF (numerical_type /=
'linear')
THEN
431 if (residual_crossing_index ==
size(re)-1)
then
432 numerical_type =
'linear'
451 resid_max_for_spline = 100.
452 IF (numerical_type /=
'linear')
THEN
453 if ( maxval(
abs(residual)) > resid_max_for_spline)
then
454 numerical_type =
'linear'
463 IF (numerical_type ==
'linear')
THEN
464 yl(1) = residual(residual_crossing_index); yl(2) = &
465 residual(residual_crossing_index+1)
466 if (
sign(1.,yl(1))*
sign(1.,yl(2)) <= 0.)
then
468 re(residual_crossing_index:residual_crossing_index+1), retrieval)
472 IF (numerical_type ==
'spline')
THEN
473 call spline (
size(re), re, residual, y2)
475 iternum = 30; icount = 1; delta_resid_fraction=0.001
477 delta_resid =
abs( delta_resid_fraction * &
478 max(residual(residual_crossing_index), &
479 residual(residual_crossing_index+1)) )
480 if(delta_resid < resid_min_allowable) delta_resid = resid_min_allowable
481 re_lower = re(residual_crossing_index)
482 re_upper = re(residual_crossing_index+1)
483 re_iter = 0.5*(re_lower + re_upper)
490 DO WHILE (icount < iternum)
491 z=
splint(
size(re), re_iter, re, residual, y2)
493 if(
abs(z) < delta_resid)
then
498 if(
sign(1.,z)*
sign(1.,residual(residual_crossing_index)) > 0.)
then
503 re_iter = 0.5*(re_lower + re_upper)
509 if(icount < iternum-5)
then
524 real(
single),
intent(in) :: library_radii(:)
535 sfr, fti1, fti0, fluxup_solar, fluxup_sensor, &
536 theta, theta0, phi, location, crefl)
560 real,
intent(in) :: tau, re, Pc, sfr, fti1, fti0, theta, theta0, phi, &
562 integer,
dimension(2),
intent(in) :: location
563 integer,
intent(in) :: iw
564 real,
dimension(:,:,:,:),
intent(in) :: fluxup_solar, fluxup_sensor
565 real,
intent(inout) :: crefl
567 real,
parameter :: Ps = 1013.
568 real,
parameter :: Cm = 0.84
569 real,
parameter :: taur0(2) = (/0.044, 0.025/)
571 real :: taur, mu0, mu, x, pray, refl_s
572 real :: fti1_as, fti0_as
573 real :: angles(2), functionvalues(2)
574 real :: fluxup_solar_tau, fluxup_sensor_tau
575 integer :: lowbound, highbound
580 taur = taur0(iw) * pc / ps
581 mu0 = cos(
d2r*theta0)
584 x = -mu0*mu + sqrt((1.-mu0**2)*(1.-mu**2))*cos(
d2r*phi)
585 pray = 3.*(1.+x**2)/4.0
594 if (location(1) == 1)
then
597 functionvalues(1) = fluxup_solar(lowbound,location(1)-1,1,location(2))
598 functionvalues(2) = fluxup_solar(highbound,location(1)-1,1,location(2))
610 if (location(1) == 1)
then
613 functionvalues(1) = fluxup_sensor(lowbound,location(1)-1,1,location(2))
614 functionvalues(2) = fluxup_sensor(lowbound,location(1)-1,1,location(2))
618 fti1_as = fluxup_sensor_tau
619 fti0_as = fluxup_solar_tau
622 fti0_as = fti0_as + fti0*as*(1-sfr)/(1 - sfr*as)
623 fti1_as = fti1_as + fti1*as*(1-sfr)/(1 - sfr*as)
626 refl_s = taur*pray/(4.*mu0*mu) + 0.5*taur* fti1_as * exp(-taur/mu )/mu0 + &
627 0.5*taur* fti0_as * exp(-taur/mu0)/mu
628 crefl = (refl_source - refl_s)*exp(cm*taur*(1./mu0 + 1./mu))
633 radii, tau, re, lib_dist, phase_liquid, Ram_corr,quality_in,CH37_IDX, &
634 CTopT,CH37_NUM, platFormName)
665 integer,
intent(in) ::xx_pt,yy_pt
666 real,
intent(in) :: Ram, Rbm
667 real,
dimension(:),
intent(in) :: radii
668 integer,
dimension(:),
intent(in) :: twobands
669 real,
intent(inout) :: tau, re, lib_dist, Ram_corr
670 logical,
intent(in) :: phase_liquid
671 integer,
intent(in) :: quality_in
672 CHARACTER(len=*),
INTENT(IN),
OPTIONAL::platFormName
673 INTEGER,
INTENT(IN),
OPTIONAL::CH37_NUM,CH37_IDX
674 REAL,
INTENT(IN),
OPTIONAL::CTopT
676 REAL :: Pc, theta, theta0, phi
677 real::CTopT_lcl, intCTop,intSurf
678 integer :: size_tau, size_re
689 IF(
PRESENT(ctopt))
THEN
695 IF(
PRESENT(ch37_idx) .AND.
PRESENT(ctopt) .and.
PRESENT(platformname) &
696 .and.
PRESENT(ch37_num) .and. ctopt_lcl > 0.0)
THEN
697 intctop=
modis_planck(platformname, ctopt_lcl, ch37_num, 1)
735 if(quality_in == -4 .OR. quality_in == -3)
then
736 CALL asl_boundary(ram, rbm, twobands, radii, tau, re, lib_dist, pc, &
737 theta, theta0, phi, phase_liquid, ram_corr)
739 CALL asl_interior(ram, rbm, twobands, radii, tau, re, lib_dist, pc, &
740 theta, theta0, phi, phase_liquid, ram_corr)
748 thermal_trans_1way, thermal_trans_2way, solar_zenith, &
757 real,
intent(in) :: intensity,intensity_g,solar_zenith
759 real,
intent(in) :: thermal_trans_2way,thermal_trans_1way
760 real(single),
intent(in) :: sfr(:,:), fti1(:,:), fti0(:,:), fri1(:,:)
763 integer :: total_taus, radii, wavelengths,i,j
764 real :: absorbing_albedo
765 real :: tc, local_trans_1way, local_trans_2way
767 if (thermal_trans_1way < 0. .or. thermal_trans_1way > 1.) then
768 local_trans_1way = 1.
770 local_trans_1way = thermal_trans_1way
773 if (thermal_trans_2way < 0. .or. thermal_trans_2way > 1.) then
774 local_trans_2way = 1.
776 local_trans_2way = thermal_trans_2way
781 absorbing_albedo =
reflibb(1,1)
783 rad37lib(1,:) = (1.0 - absorbing_albedo) * intensity_g
784 rad37lib(2:,:) = (1.0- fti1(:,:) - fri1(:,:)) * intensity + &
785 fti1(:,:) * (1.0 - absorbing_albedo) * intensity_g / &
786 (1.0 - absorbing_albedo * sfr(:,:))
794 thermal_trans_1way, thermal_trans_2way, solar_zenith, &
803 real,
intent(in) :: intensity,intensity_g,solar_zenith
804 real,
intent(in) :: thermal_trans_2way,thermal_trans_1way
805 real(single),
intent(in) :: cl_emis(:,:), sf_emis(:,:)
810 integer :: total_taus, radii, wavelengths,i,j
811 real :: absorbing_albedo
812 real :: tc, local_trans_1way, local_trans_2way
814 if (thermal_trans_1way < 0. .or. thermal_trans_1way > 1.) then
815 local_trans_1way = 1.
817 local_trans_1way = thermal_trans_1way
820 if (thermal_trans_2way < 0. .or. thermal_trans_2way > 1.) then
821 local_trans_2way = 1.
823 local_trans_2way = thermal_trans_2way
828 rad37lib(:,:) = cl_emis(:,:) * intensity + sf_emis(:,:) * intensity_g
835 subroutine asl_interior(Ram, Rbm_in, bands, radii, tau, re, lib_dist, Pc, &
836 theta, theta0, phi, phase_liquid, Ram_corr)
863 real,
intent(in) :: Ram, Rbm_in, Pc, theta, theta0, phi
864 real,
dimension(:),
intent(in) :: radii
865 integer,
dimension(:),
intent(in) :: bands
866 real,
intent(inout) :: tau, re, lib_dist, Ram_corr
867 logical,
intent(in) :: phase_liquid
870 real,
dimension(:,:),
allocatable :: rel_residual,reflibBL
871 integer :: size_tau, size_re, loc(2), rel_loc(2)
872 logical :: re_altered
874 real :: Ramc, crefl,Rbm
875 integer :: iter, max_iter
877 real :: albedoA, albedoB,normConst
878 real :: sfr, fti1, fti0
882 allocate(rel_residual(size_tau, size_re),reflibbl(size_tau, size_re))
889 rbm = rbm_in * normconst
894 albedob = reflibbl(1,1)
910 do while (iter <= max_iter)
913 if (ramc < albedoa)
then
918 deallocate (rel_residual, reflibbl )
922 rel_residual = sqrt( (
refliba - ramc)**2 + (reflibbl-rbm)**2 ) / &
923 sqrt(ramc**2 + rbm**2)
924 loc = minloc(rel_residual)
925 lib_dist = rel_residual(loc(1), loc(2))
929 if (re < 4. ) re = 4.
933 if (loc(1) == 1)
then
945 if (phase_liquid)
then
946 if (loc(1) == 1)
then
958 theta, theta0, phi, loc, crefl)
960 if (loc(1) == 1)
then
972 theta, theta0, phi, loc, crefl)
984 if (ramc < albedoa)
then
988 deallocate (rel_residual, reflibbl )
992 rel_residual = sqrt( (
refliba - ramc)**2 + (reflibbl-rbm)**2 ) / &
993 sqrt(ramc**2 + rbm**2)
994 loc = minloc(rel_residual)
995 lib_dist = rel_residual(loc(1), loc(2))
1000 if (re < 4. ) re = 4.
1004 if (loc(1) == 1)
then
1010 deallocate (rel_residual,reflibbl)
1015 subroutine asl_boundary(Ram, Rbm_in, bands, radii, tau, re, lib_dist, Pc, &
1016 theta, theta0, phi, phase_liquid, Ram_corr)
1045 real,
intent(in) :: Ram, Rbm_in, Pc, theta, theta0, phi
1046 real,
dimension(:),
intent(in) :: radii
1047 integer,
dimension(:),
intent(in) :: bands
1048 real,
intent(inout) :: tau, re, lib_dist, Ram_corr
1049 logical,
intent(in) :: phase_liquid
1051 real,
dimension(:,:),
allocatable :: temp_refl,reflibBL
1052 real,
dimension(:),
allocatable::rel_residual
1053 integer :: size_tau, size_re, loc, rel_loc(1),ire_ct_1, &
1054 temp_array_size,s_rt,iL,iR
1055 logical :: re_altered
1057 real :: Ramc, crefl, Rbm
1058 integer :: iter, max_iter,iiiloc
1060 real :: albedoA, albedoB,normConst
1061 real :: sfr, fti1, fti0
1069 allocate(reflibbl(size_tau, size_re))
1075 rbm = rbm_in * normconst
1088 albedob = reflibbl(1,ire_ct_1)
1090 s_rt = size_tau+size_re
1091 temp_array_size = size_tau + s_rt - (ire_ct_1 + 1)
1093 allocate(rel_residual(temp_array_size))
1094 allocate(temp_refl(2,temp_array_size))
1096 temp_refl(1,1:size_tau) =
refliba(1:size_tau,ire_ct_1)
1098 temp_refl(1, size_tau+1 : s_rt-ire_ct_1) = &
1099 refliba(size_tau,ire_ct_1+1:size_re)
1101 temp_refl(1, s_rt-ire_ct_1+1 : temp_array_size) = &
1105 temp_refl(2, 1 : size_tau) = reflibbl(1:size_tau,ire_ct_1)
1106 temp_refl(2, size_tau+1 : s_rt-ire_ct_1) = &
1107 reflibbl(size_tau,ire_ct_1+1:size_re)
1108 temp_refl(2, s_rt-ire_ct_1+1 : temp_array_size) = &
1109 reflibbl(1:size_tau-1,size_re)
1113 if (ramc < albedoa .OR. &
1114 ( rbm < minval(reflibbl(size_tau,ire_ct_1:size_re)) .and. &
1115 ramc > minval(
refliba(size_tau,ire_ct_1:size_re)) ) .OR. &
1116 ( rbm > maxval(reflibbl(size_tau,ire_ct_1:size_re)) .and. &
1117 ramc > maxval(
refliba(size_tau,ire_ct_1:size_re)) ))
then
1123 deallocate (rel_residual, temp_refl, reflibbl)
1128 rel_residual = sqrt( (temp_refl(1,:) - ramc)**2 + &
1129 (temp_refl(2,:) -rbm)**2 ) / sqrt(ramc**2 + rbm**2)
1130 rel_loc = minloc(rel_residual)
1131 lib_dist = rel_residual(rel_loc(1))
1137 if(rel_loc(1) <= size_tau)
then
1139 re = radii(ire_ct_1)
1143 if(phase_liquid)
then
1150 temp_refl(2,1:size_tau),lib_dist,loc)
1160 if(ramc > maxval(
refliba(size_tau,ire_ct_1:size_re)))
then
1164 if((rbm - reflibbl(size_tau,ire_ct_1)) < 0.0)
then
1165 do iiiloc = ire_ct_1+1,size_re
1168 if((rbm - reflibbl(size_tau,iiiloc)) >=0.0)
exit
1173 if(
abs(reflibbl(size_tau,ir)-reflibbl(size_tau,il)) > 0.000001)
then
1174 re = (rbm-reflibbl(size_tau,il))*(radii(ir) - &
1175 radii(il))/(reflibbl(size_tau,ir)-reflibbl(size_tau,il)) + &
1177 if(re > radii(ir) .OR. re < radii(il))re = radii(il)
1183 elseif(rel_loc(1) > size_tau .and. rel_loc(1) <= s_rt - ire_ct_1)
then
1185 loc = rel_loc(1) - size_tau + 1
1189 ((rbm - reflibbl(size_tau,loc)) < 0.0 .AND. loc <= size_re))
then
1190 do iiiloc = loc , size_re
1191 if((rbm - reflibbl(size_tau,iiiloc)) >=0.0)
exit
1197 elseif((rbm - reflibbl(size_tau,loc)) >= 0.0 .AND. loc <= size_re)
then
1198 do iiiloc = loc-1 , 1,-1
1199 if((rbm - reflibbl(size_tau,iiiloc)) <= 0.0)
exit
1206 if(ir <= size_re .and. il >= 1)
then
1208 if(
abs(reflibbl(size_tau,ir)-reflibbl(size_tau,il)) > 0.000001 &
1209 .and.
abs(rbm - reflibbl(size_tau,loc)) > 0.0)
then
1210 re = radii(loc) + (rbm-reflibbl(size_tau,loc))*(radii(ir) - &
1211 radii(il))/(reflibbl(size_tau,ir)-reflibbl(size_tau,il))
1212 if(re > radii(ir) .OR. re < radii(il))re = radii(loc)
1217 if(phase_liquid)
then
1232 if(ramc > 0 .and. ramc < maxval(
refliba(1:size_tau,size_re)) .and. &
1241 loc = rel_loc(1) - (s_rt-ire_ct_1) + 1
1244 if(phase_liquid)
then
1251 temp_refl(1,s_rt-ire_ct_1+1: temp_array_size), &
1252 temp_refl(2,s_rt-ire_ct_1+1: temp_array_size),lib_dist,loc)
1256 if ( loc == 1 )
then
1262 if(ramc > maxval(
refliba(1:size_tau,size_re)))
then
1283 deallocate (rel_residual,temp_refl,reflibbl)
1296 REAL,
INTENT(IN)::R1,R2
1297 REAL,
DIMENSION(:),
INTENT(IN)::R1vec,R2vec
1298 REAL,
INTENT(OUT)::mindist
1299 INTEGER,
INTENT(OUT)::loc_index
1301 real,
dimension(:),
allocatable::rel_residual
1304 allocate(rel_residual(
size(r1vec)))
1306 rel_residual = sqrt( (r1vec - r1)**2 + (r2vec -r2)**2 ) / &
1308 rel_loc = minloc(rel_residual)
1309 mindist = rel_residual(rel_loc(1))
1310 loc_index = rel_loc(1)
1312 deallocate(rel_residual)
1318 library_radii, effective_radius, optical_thickness)
1329 real,
intent(in) :: optical_thickness_vector(:)
1330 real,
intent(in) :: library_radii(:)
1331 real,
intent(in) :: effective_radius
1332 real,
intent(out) :: optical_thickness
1347 real(library_radii), ilo, ihi)
1350 real(library_radii(ilo:ilo+2)), optical_thickness_vector(ilo:ilo+2) )
1352 if (optical_thickness > 150.) optical_thickness = 150.
1353 if (optical_thickness < 0.)
then
1360 library_radii, effective_radius, optical_thickness, debug, &
1361 use_nearest, quality_out)
1380 real,
intent(in) :: residual(:), optical_thickness_vector(:)
1381 real(single),
intent(in) :: library_radii(:)
1382 logical,
intent(in) :: debug
1383 logical,
intent(inout) :: use_nearest
1384 real,
intent(out) :: effective_radius, optical_thickness
1385 integer,
intent(out)::quality_out
1387 real :: max_allowable_tau,local_max_allowable
1388 integer:: total_taus
1390 integer :: number_local_minima, ilo, ihi, zero_count
1391 integer :: local_minima(8)
1393 INTEGER,
parameter :: nre=18
1394 INTEGER :: crossing_num, crossing_vector(nre), local_max_num, &
1395 local_max_vector(nre), local_min_num, local_min_vector(nre), k
1396 integer(integer_onebyte) :: quality
1400 real re_water_outofbounds_high, re_water_outofbounds_low
1401 logical :: re_altered, correction_made
1404 re_water_outofbounds_high = 30.; re_water_outofbounds_low = 4.
1406 correction_made = .false.
1417 crossing_vector, crossing_num)
1419 local_min_vector, local_min_num)
1421 local_max_vector, local_max_num)
1425 local_min_vector, local_min_num, local_max_vector, local_max_num, &
1426 effective_radius, quality )
1432 call solution_re (library_radii, residual, crossing_vector, crossing_num, &
1433 local_min_vector, local_min_num, local_max_vector, local_max_num, &
1434 effective_radius, quality )
1437 quality_out = quality
1439 use_nearest = .false.
1440 if ( quality == -2 .or. quality == -3 .or. quality == -4 &
1441 .OR. quality == -6)
then
1443 use_nearest = .true.
1466 re_altered = .false.
1468 ( (effective_radius < re_water_outofbounds_low) .or. &
1470 effective_radius = 10.
1476 effective_radius = 30.
1484 real(library_radii), ilo, ihi)
1490 local_max_allowable = max_allowable_tau - 1.0
1494 if(.not.(use_nearest) .and. &
1495 (maxval(optical_thickness_vector(ilo:ilo+2)) > local_max_allowable &
1496 .OR. minval(optical_thickness_vector(ilo:ilo+2)) < 0))
then
1498 correction_made = .true.
1500 if(maxval(optical_thickness_vector(1:2)) > local_max_allowable &
1501 .OR. minval(optical_thickness_vector(1:2)) < 0)
then
1503 use_nearest = .true.
1507 optical_thickness = optical_thickness_vector(ilo) + &
1508 ( ( effective_radius -
real(library_radii(ilo))) / &
1509 (
real(library_radii(ilo+1)-library_radii(ilo))) ) * &
1510 (optical_thickness_vector(ilo+1) - optical_thickness_vector(ilo) )
1513 elseif(maxval(optical_thickness_vector(ilo-1:ilo)) > local_max_allowable &
1514 .OR. minval(optical_thickness_vector(ilo-1:ilo)) < 0)
then
1516 use_nearest = .true.
1519 elseif(maxval(optical_thickness_vector(ilo-1:ilo)) < local_max_allowable &
1520 .AND. minval(optical_thickness_vector(ilo-1:ilo)) > 0)
then
1522 if(optical_thickness_vector(ilo+3) < local_max_allowable &
1523 .AND. optical_thickness_vector(ilo+3) > 0)ilo = ilo+1
1525 optical_thickness = optical_thickness_vector(ilo+1) + &
1526 ( ( effective_radius -
real(library_radii(ilo+1))) / &
1527 (
real(library_radii(ilo+2)-library_radii(ilo+1))) ) * &
1528 (optical_thickness_vector(ilo+2) - optical_thickness_vector(ilo+1) )
1534 use_nearest = .true.
1541 if(.NOT.(correction_made))
then
1543 real(library_radii(ilo:ilo+2)), &
1544 optical_thickness_vector(ilo:ilo+2) )
1547 if( optical_thickness < optical_thickness_vector(ilo) .AND. &
1548 (.NOT.(correction_made))) then
1551 real(library_radii), ilo, ihi)
1552 optical_thickness = optical_thickness_vector(ilo) + &
1553 ( ( effective_radius -
real(library_radii(ilo))) / &
1554 (
real(library_radii(ilo+1)-library_radii(ilo))) ) * &
1555 (optical_thickness_vector(ilo+1) - optical_thickness_vector(ilo) )
1568 if (optical_thickness /=
fillvalue_real .and. optical_thickness < 0.)
then
1571 use_nearest = .true.
1576 optical_thickness < 0.01 .and. optical_thickness > 0.) then
1577 optical_thickness = 0.01
1607 effective_radius < library_radii(1)) then
1608 effective_radius = library_radii(1)
1613 if (effective_radius > library_radii(
size(library_radii))) then
1614 effective_radius = library_radii(
size(library_radii))
1628 real,
intent(in) :: residual(2), rad(2)
1629 real,
intent(out) :: re
1631 re = -1.0*( rad(1)*residual(2)/(residual(1)-residual(2)) + &
1632 rad(2)*residual(1)/(residual(2)-residual(1)) )
1647 integer,
intent(in) :: n1, n
1648 real,
intent(in) :: xx, x(n)
1650 integer,
intent(out) :: k1, k2
1657 do while (xx > x(i) .and. i < n)
1684 real,
intent(in) :: x(3), y(3), xx
1685 lagrangeinterp = (xx-x(2))* (xx-x(3))/ (x(1)-x(2))/ (x(1)-x(3))*y(1) + &
1686 (xx-x(3))* (xx-x(1))/ (x(2)-x(3))/ (x(2)-x(1))*y(2) + &
1687 (xx-x(1))* (xx-x(2))/ (x(3)-x(1))/ (x(3)-x(2))*y(3)
1706 real,
intent(in) :: x(3)
1707 integer,
intent(out) :: signchange
1709 if ( (x(1)==0 .and. x(2)==0) .or. (x(1)==0 .and. x(3)==0) .or. &
1710 (x(2)==0 .and. x(3)==0) )
Then
1713 if (
sign(1.,x(1))*
sign(1.,x(2))*
sign(1.,x(3)) /= -1.)
Then
1715 if ( x(1) > 0 .AND. x(2) > 0 .AND. x(3) > 0) then
1719 if ( x(1) < 0 .AND. x(2) < 0 .AND. x(3) < 0) then
1728 if (signchange == 1) then
1729 if (
sign(1.,x(1))*
sign(1.,x(2)) == -1. ) signchange = 1
1730 if (
sign(1.,x(2))*
sign(1.,x(3)) == -1. ) signchange = 2
1746 real(single),
intent(in) :: radii(:), residual(:)
1748 real(single),
intent(out) :: radius_solution
1749 integer,
intent(out) :: status
1751 real(double) :: d1, d2, d3, a0, a1, a2, root1, root2, z
1753 d1 = residual(1) / ((radii(1)-radii(2))*(radii(1)-radii(3)))
1754 d2 = residual(2) / ((radii(2)-radii(1))*(radii(2)-radii(3)))
1755 d3 = residual(3) / ((radii(3)-radii(1))*(radii(3)-radii(2)))
1757 a0 = d1*radii(2)*radii(3) + d2*radii(1)*radii(3) + d3*radii(1)*radii(2)
1758 a1 = -d1*(radii(2)+radii(3)) - d2*(radii(1)+radii(3)) - d3*(radii(1)+radii(2))
1764 if(z >= 0. .and. a2 /= 0.) then
1765 root1 = (-a1 + sqrt(z))/(2*a2)
1766 root2 = (-a1 - sqrt(z))/(2*a2)
1768 root1 = -999; root2 = -999
1772 if (root1 < radii(1) .and. root2 < radii(1)) then
1773 radius_solution =-999.
1775 elseif (root1 > radii(3) .and. root2 > radii(3)) then
1776 radius_solution =-999.
1778 elseif (root1 >= radii(1) .and. root1 <= radii(3)) then
1779 radius_solution = root1
1781 elseif(root2 >= radii(1) .and. root2 <= radii(3)) then
1782 radius_solution = root2
1785 radius_solution = -999.