Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't compute log10(chl) for small chl #305

Merged
merged 2 commits into from
Oct 3, 2024
Merged
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
14 changes: 12 additions & 2 deletions src/parameterizations/vertical/MOM_opacity.F90
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ module MOM_opacity
!! Lookup tables for Ohlmann solar penetration scheme
!! These would naturally exist as private module variables but that is prohibited in MOM6
real :: dlog10chl !< Chl increment within lookup table
real :: chl_min !< Lower bound of Chl in lookup table
real :: log10chl_min !< Lower bound of Chl in lookup table
real :: log10chl_max !< Upper bound of Chl in lookup table
real, allocatable, dimension(:) :: a1_lut,& !< Coefficient for band 1
Expand Down Expand Up @@ -1303,6 +1304,7 @@ subroutine init_ohlmann_table(optics)
call MOM_error(FATAL,"init_ohlmann: Cannot allocate lookup table")
endif

optics%chl_min = chl_tab1a(1)
optics%log10chl_min = log10(chl_tab1a(1))
optics%log10chl_max = log10(chl_tab1a(nval_tab1a))
optics%dlog10chl = (optics%log10chl_max - optics%log10chl_min)/(nval_lut-1)
Expand Down Expand Up @@ -1349,7 +1351,11 @@ function lookup_ohlmann_swpen(chl,optics) result(A)
integer :: n

! Make sure we are in the table
log10chl = max(optics%log10chl_min,min(log10(chl),optics%log10chl_max))
if (chl > optics%chl_min) then
log10chl = min(log10(chl),optics%log10chl_max)
else
log10chl = optics%log10chl_min
endif
! Do a nearest neighbor lookup
n = nint( (log10chl - optics%log10chl_min)/optics%dlog10chl ) + 1

Expand All @@ -1371,7 +1377,11 @@ function lookup_ohlmann_opacity(chl,optics) result(B)
integer :: n

! Make sure we are in the table
log10chl = max(optics%log10chl_min,min(log10(chl),optics%log10chl_max))
if (chl > optics%chl_min) then
log10chl = min(log10(chl),optics%log10chl_max)
else
log10chl = optics%log10chl_min
endif
! Do a nearest neighbor lookup
n = nint( (log10chl - optics%log10chl_min)/optics%dlog10chl ) + 1

Expand Down
Loading