This issue was flagged by claude-opus:4.8[1m]: it noticed that the following variable is declared as integer and may be silently truncated as a result; it should be declared as real(kind_phys):
|
integer, allocatable :: itsi(:) |
...
|
if (has_tsi .and. (.not. do_spectral_scaling)) then |
|
call file_reader%get_var('tsi', itsi, errmsg, errflg, (/index/), (/nt/)) |
|
if (errflg /= 0) then |
|
errmsg = subname // errmsg |
|
return |
|
end if |
|
if ( any(itsi(:nt) < 0._kind_phys) ) then |
the above line 372 shows that it might have been intended to be a real.
...
|
if (has_tsi .and. (.not.do_spectral_scaling)) then |
|
sol_tsi = itsi(1) + delt*( itsi(2) - itsi(1) ) |
The same variable with similar logic appears to be declared as real(r8) in CAM:
https://github.com/ESCOMP/CAM/blob/ec42689850c06f0d4472e826b30ad69728ba42cf/src/chemistry/utils/solar_irrad_data.F90#L41
real(r8) :: itsi(2)
...
if (has_tsi .and. (.not.do_spctrl_scaling)) then
ierr = pio_get_var( file_id, tsi_vid, (/index/), (/nt/), itsi )
...
if (has_tsi .and. (.not.do_spctrl_scaling)) then
sol_tsi = itsi(1) + delt*( itsi(2) - itsi(1) )
endif
Tagging @peverwhee
The original message written by Claude was:
Problem: itsi is declared integer, allocatable :: itsi(:) but holds total solar irradiance (tsi, ~1361 W m⁻²). The generic get_var binds to the integer overload (get_var_int_1d) and truncates the file's real TSI to whole numbers. The interpolation sol_tsi = itsi(1) + delt*(itsi(2)-itsi(1)) is then performed in integer arithmetic, and the validity check any(itsi(:nt) < 0._kind_phys) compares integers to a real literal. This degrades the prescribed solar constant to ~1 W/m² quantization and discards sub-W/m² solar-cycle variability — the exact signal this data path exists to provide.
This issue was flagged by claude-opus:4.8[1m]: it noticed that the following variable is declared as
integerand may be silently truncated as a result; it should be declared asreal(kind_phys):atmospheric_physics/schemes/radiation_utils/solar_irradiance_data.F90
Line 324 in 2180f3c
...
atmospheric_physics/schemes/radiation_utils/solar_irradiance_data.F90
Lines 366 to 372 in 2180f3c
the above line 372 shows that it might have been intended to be a real.
...
atmospheric_physics/schemes/radiation_utils/solar_irradiance_data.F90
Lines 397 to 398 in 2180f3c
The same variable with similar logic appears to be declared as
real(r8)in CAM:https://github.com/ESCOMP/CAM/blob/ec42689850c06f0d4472e826b30ad69728ba42cf/src/chemistry/utils/solar_irrad_data.F90#L41
Tagging @peverwhee
The original message written by Claude was: