Skip to content

Bugfix/gnssro refmetoffice geom2geop #75

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
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
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ module ufo_gnssro_refmetoffice_mod
c_virtual, & ! Related to mw_ratio
n_alpha, & ! Refractivity constant a
n_beta ! Refractivity constant b
use gnssro_mod_transform, only: geometric2geop


implicit none
Expand Down Expand Up @@ -114,6 +115,7 @@ subroutine ufo_gnssro_refmetoffice_simobs(self, geovals, obss, hofx, obs_diags)
integer :: iVar ! Loop variable, obs diagnostics variable number
real(kind_real), allocatable :: refractivity(:) ! Refractivity on various model levels
real(kind_real), allocatable :: model_heights(:) ! Geopotential heights that refractivity is calculated on
real(kind_real) :: tmp_geop_height ! Tmp var used in geopotential height calculation

write(err_msg,*) "TRACE: ufo_gnssro_refmetoffice_simobs: begin"
call fckit_log%info(err_msg)
Expand Down Expand Up @@ -171,6 +173,12 @@ subroutine ufo_gnssro_refmetoffice_simobs(self, geovals, obss, hofx, obs_diags)
call obsspace_get_db(obss, "MetaData", "latitude", obsLat)
call obsspace_get_db(obss, "MetaData", "height", obs_height)

! Convert geometric height to geopotential height
do iobs = 1, nobs
call geometric2geop(obsLat(iobs), obs_height(iobs), tmp_geop_height)
obs_height(iobs) = tmp_geop_height
end do

obs_loop: do iobs = 1, nobs

call RefMetOffice_ForwardModel(prs % nval, &
Expand Down Expand Up @@ -270,15 +278,15 @@ SUBROUTINE RefMetOffice_ForwardModel(nlevp, &

INTEGER, INTENT(IN) :: nlevp ! no. of p levels in state vec.
INTEGER, INTENT(IN) :: nlevq ! no. of theta levels
REAL(kind_real), INTENT(IN) :: za(1:nlevp) ! heights of rho levs
REAL(kind_real), INTENT(IN) :: zb(1:nlevq) ! heights of theta levs
REAL(kind_real), INTENT(IN) :: za(1:nlevp) ! geopotential heights of rho levs
REAL(kind_real), INTENT(IN) :: zb(1:nlevq) ! geopotential heights of theta levs
REAL(kind_real), INTENT(IN) :: pressure(1:nlevp) ! Model background pressure
REAL(kind_real), INTENT(IN) :: humidity(1:nlevq) ! Model background specific humidity
LOGICAL, INTENT(IN) :: GPSRO_pseudo_ops ! Option: Use pseudo-levels in vertical interpolation?
LOGICAL, INTENT(IN) :: GPSRO_vert_interp_ops ! Option: Use ln(p) for vertical interpolation? (rather than exner)
REAL(kind_real), INTENT(IN) :: GPSRO_min_temp_grad ! The minimum temperature gradient which is used
INTEGER, INTENT(IN) :: nobs ! Number of observations in the profile
REAL(kind_real), INTENT(IN) :: zobs(1:nobs) ! Impact parameter for the obs
REAL(kind_real), INTENT(IN) :: zobs(1:nobs) ! Geopotential heights for the obs
REAL(kind_real), INTENT(IN) :: Latitude ! Latitude of this profile
REAL(kind_real), INTENT(INOUT) :: ycalc(1:nobs) ! Model forecast of the observations
LOGICAL, INTENT(OUT) :: BAErr ! Was an error encountered during the calculation?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ module ufo_gnssro_refmetoffice_tlad_mod
c_virtual, & ! Related to mw_ratio
n_alpha, & ! Refractivity constant a
n_beta ! Refractivity constant b
use gnssro_mod_transform, only: geometric2geop

private
public :: ufo_gnssro_refmetoffice_tlad
Expand Down Expand Up @@ -126,6 +127,8 @@ subroutine ufo_gnssro_refmetoffice_tlad_settraj(self, geovals, obss)
integer :: iobs ! Loop variable, observation number

real(kind_real), allocatable :: obs_height(:) ! Geopotential height of the observation
real(kind_real), allocatable :: obsLat(:) ! Observed latitude used in geop hgt calc
real(kind_real) :: tmp_geop_height ! Tmp var used in geopotential height calc

write(err_msg,*) "TRACE: ufo_gnssro_refmetoffice_tlad_settraj: begin"
call fckit_log%info(err_msg)
Expand All @@ -152,7 +155,16 @@ subroutine ufo_gnssro_refmetoffice_tlad_settraj(self, geovals, obss)

! Get the meta-data from the observations
allocate(obs_height(self%nlocs))
allocate(obsLat(self%nlocs))
call obsspace_get_db(obss, "MetaData", "height", obs_height)
call obsspace_get_db(obss, "MetaData", "latitude", obsLat)

! Convert geometric height to geopotential height.
do iobs = 1, self%nlocs
call geometric2geop(obsLat(iobs), obs_height(iobs), tmp_geop_height)
obs_height(iobs) = tmp_geop_height
end do

allocate(self % K(1:self%nlocs, 1:prs%nval + q%nval))

! For each observation, calculate the K-matrix
Expand All @@ -167,7 +179,7 @@ subroutine ufo_gnssro_refmetoffice_tlad_settraj(self, geovals, obss)
self % vert_interp_ops, & ! Whether to interpolate using log(pressure)
self % min_temp_grad, & ! Minimum allowed vertical temperature gradient
1, & ! Number of observations in the profile
obs_height(iobs:iobs), & ! Impact parameter for this observation
obs_height(iobs:iobs), & ! Geopotential height for this observation
self % K(iobs:iobs,1:prs%nval+q%nval)) ! K-matrix (Jacobian of the observation with respect to the inputs)
! Flip the K-matrix back the right way around
self % K(iobs,1:prs%nval) = self % K(iobs, prs%nval:1:-1)
Expand All @@ -178,6 +190,7 @@ subroutine ufo_gnssro_refmetoffice_tlad_settraj(self, geovals, obss)
self%ltraj = .true.

deallocate(obs_height)
deallocate(obsLat)

end subroutine ufo_gnssro_refmetoffice_tlad_settraj

Expand Down