Skip to content

Commit

Permalink
Merge pull request #960 from breichl/user/bgr/Init_from_Z_add_scale_o…
Browse files Browse the repository at this point in the history
…ffset

Adding scale_factor and add_offset for horiz_interp_and_extrap_tracer_record
  • Loading branch information
adcroft authored Jul 23, 2019
2 parents f30d5af + f0fec84 commit 9bd3f00
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/framework/MOM_horizontal_regridding.F90
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ subroutine horiz_interp_and_extrap_tracer_record(filename, varnam, conversion,
real, dimension(:), allocatable :: lat_inp, last_row
real :: max_lat, min_lat, pole, max_depth, npole
real :: roundoff ! The magnitude of roundoff, usually ~2e-16.
real :: add_offset, scale_factor
logical :: add_np
character(len=8) :: laynum
type(horiz_interp_type) :: Interp
Expand Down Expand Up @@ -376,6 +377,13 @@ subroutine horiz_interp_and_extrap_tracer_record(filename, varnam, conversion,
if (rcode /= 0) call MOM_error(FATAL,"error finding missing value for "//&
trim(varnam)//" in file "// trim(filename)//" in hinterp_extrap")

rcode = NF90_GET_ATT(ncid, varid, "add_offset", add_offset)
if (rcode /= 0) add_offset = 0.0

rcode = NF90_GET_ATT(ncid, varid, "scale_factor", scale_factor)
if (rcode /= 0) scale_factor = 1.0


if (allocated(lon_in)) deallocate(lon_in)
if (allocated(lat_in)) deallocate(lat_in)
if (allocated(z_in)) deallocate(z_in)
Expand Down Expand Up @@ -499,7 +507,7 @@ subroutine horiz_interp_and_extrap_tracer_record(filename, varnam, conversion,
do i=1,id
if (abs(tr_inp(i,j)-missing_value) > abs(roundoff*missing_value)) then
mask_in(i,j) = 1.0
tr_inp(i,j) = tr_inp(i,j) * conversion
tr_inp(i,j) = (tr_inp(i,j)*scale_factor+add_offset) * conversion
else
tr_inp(i,j) = missing_value
endif
Expand Down

0 comments on commit 9bd3f00

Please sign in to comment.