Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/CRTM_Forward_Module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,9 @@ FUNCTION profile_solution (m, Opt, AncillaryInput) RESULT( Error_Status )
IF( Opt%n_Stokes > 0 ) THEN
RTV(:)%n_Stokes = Opt%n_Stokes
RTV_Clear(:)%n_Stokes = Opt%n_Stokes
ELSE
RTV(:)%n_Stokes = 0
Copy link
Contributor

@chengdang chengdang Mar 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this ELSE statement is unnecessary, because Opt%n_Stokes is by default set as 1 (See CRTM_Options_Define.f90) that Opt%n_Stokes > 0 is always true, unless users accidentally set Opt%n_Stokes <= 0, which is wrong.

I feel this IF statement is here to prevent users from assigning a wrong number to Opt%n_Stokes, and to make sure it is at least set as 1 in CRTM.

A lot of the conditional calculations are based on RTV%n_Stokes, especially IF %n_Stokes == 1, so it should never be set as 0.

RTV_Clear(:)%n_Stokes = 0
END IF
RTV(:)%RT_Algorithm_Id = Opt%RT_Algorithm_Id
! IF( Opt%RT_Algorithm_Id == RT_VMOM .and. RTV(1)%n_Stokes == 1) THEN
Expand Down Expand Up @@ -1078,6 +1081,7 @@ FUNCTION profile_solution (m, Opt, AncillaryInput) RESULT( Error_Status )
! mth_Azi = 0 is for an azimuth-averaged value (IR, MW)
! ...Initialise radiance
RTSolution(ln,m)%Radiance = ZERO
RTSolution(ln,m)%Stokes = ZERO
! ...Fourier expansion over azimuth angle
Azimuth_Fourier_Loop: DO mth_Azi = 0, RTV(nt)%n_Azi

Expand Down
23 changes: 15 additions & 8 deletions src/RTSolution/CRTM_RTSolution_Define.f90
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ MODULE CRTM_RTSolution_Define
! Radiative transfer results for a single channel
REAL(fp) :: Radiance = ZERO
REAL(fp) :: Brightness_Temperature = ZERO
REAL(fp) :: Stokes(4)
REAL(fp) :: Stokes(4) = ZERO
REAL(fp) :: Solar_Irradiance = ZERO
REAL(fp) :: Reflectance = ZERO
REAL(fp), ALLOCATABLE :: Reflectivity(:) ! K
Expand Down Expand Up @@ -445,12 +445,12 @@ ELEMENTAL SUBROUTINE CRTM_RTSolution_Zero( RTSolution )

! Zero out the array data components
IF ( CRTM_RTSolution_Associated(RTSolution) ) THEN
RTSolution%Upwelling_Radiance = ZERO
RTSolution%Upwelling_Overcast_Radiance = ZERO
RTSolution%Layer_Optical_Depth = ZERO
RTSolution%Single_Scatter_Albedo = ZERO
RTSolution%Reflectivity = ZERO
RTSolution%Reflectivity_Attenuated = ZERO
RTSolution%Upwelling_Radiance = ZERO
RTSolution%Upwelling_Overcast_Radiance = ZERO
RTSolution%Layer_Optical_Depth = ZERO
RTSolution%Single_Scatter_Albedo = ZERO
RTSolution%Reflectivity = ZERO
RTSolution%Reflectivity_Attenuated = ZERO
END IF

END SUBROUTINE CRTM_RTSolution_Zero
Expand Down Expand Up @@ -498,6 +498,12 @@ SUBROUTINE Scalar_Inspect( RTSolution, Unit )
CHARACTER(len=*), PARAMETER :: fmt32 = '(3x,a,es13.6)' ! print in 32-bit precision
CHARACTER(len=*), PARAMETER :: fmt = fmt64 ! choose 64-bit precision

CHARACTER(len=*), PARAMETER :: fmt64_4 = '(3x,a,4es22.15)' ! print in 64-bit precision
CHARACTER(len=*), PARAMETER :: fmt32_4 = '(3x,a,4es13.6)' ! print in 32-bit precision
CHARACTER(len=*), PARAMETER :: fmt_4 = fmt64_4 ! choose 64-bit precision



! Setup
fid = OUTPUT_UNIT
IF ( PRESENT(Unit) ) THEN
Expand Down Expand Up @@ -527,7 +533,8 @@ SUBROUTINE Scalar_Inspect( RTSolution, Unit )
WRITE(fid,fmt) "Brightness Temperature : ", RTSolution%Brightness_Temperature
WRITE(fid,fmt) "Solar Irradiance : ", RTSolution%Solar_Irradiance
WRITE(fid,fmt) "Reflectance : ", RTSolution%Reflectance
!WRITE(fid,fmt) "Stokes : ", RTSolution%Stokes
WRITE(fid,fmt_4) "Stokes(1:4) : ", RTSolution%Stokes(1:4)

IF ( CRTM_RTSolution_Associated(RTSolution) ) THEN
WRITE(fid,'(3x,"n_Layers : ",i0)') RTSolution%n_Layers
WRITE(fid,'(3x,"Upwelling Overcast Radiance :")')
Expand Down