Skip to content

Commit

Permalink
Merge branch 'avoid_zero_chl' into dev/ncar
Browse files Browse the repository at this point in the history
  • Loading branch information
mnlevy1981 committed Oct 3, 2024
2 parents 00beb26 + 8fb8aaf commit ad7cf38
Showing 1 changed file with 12 additions and 2 deletions.
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

0 comments on commit ad7cf38

Please sign in to comment.