-
Notifications
You must be signed in to change notification settings - Fork 405
Implement MPAS init-atmosphere case 11 + 12 for model-level IFS and ERA5 with lapse-rate vinterp #1413
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
base: develop
Are you sure you want to change the base?
Implement MPAS init-atmosphere case 11 + 12 for model-level IFS and ERA5 with lapse-rate vinterp #1413
Changes from 3 commits
fa48c91
a2fd267
86845cb
924b456
ef43c50
34306d3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8154,3 +8154,4 @@ end function read_text_array | |
|
|
||
|
|
||
| end module init_atm_cases | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,9 +38,10 @@ real (kind=RKIND) function vertical_interp(target_z, nz, zf, order, extrap, surf | |
| real (kind=RKIND), intent(in), optional :: sealev_val | ||
| integer, intent(out), optional :: ierr | ||
|
|
||
| integer :: k, lm, lp | ||
| integer :: k, lm, lp, n_lapse | ||
| real (kind=RKIND) :: wm, wp | ||
| real (kind=RKIND) :: slope | ||
| real (kind=RKIND) :: sum_x, sum_y, sum_x2, sum_xy, n_real | ||
|
|
||
| integer :: interp_order, extrap_type | ||
| real (kind=RKIND) :: surface, sealevel | ||
|
|
@@ -81,7 +82,22 @@ real (kind=RKIND) function vertical_interp(target_z, nz, zf, order, extrap, surf | |
| slope = (zf(2,2) - zf(2,1)) / (zf(1,2) - zf(1,1)) | ||
| vertical_interp = zf(2,1) + slope * (target_z - zf(1,1)) | ||
| else if (extrap_type == 2) then | ||
| vertical_interp = zf(2,1) - (target_z - zf(1,1))*0.0065 | ||
| n_lapse = min(nz, 3) | ||
| sum_x = 0.0_RKIND; sum_y = 0.0_RKIND | ||
| sum_x2 = 0.0_RKIND; sum_xy = 0.0_RKIND | ||
| do k = 1, n_lapse | ||
| sum_x = sum_x + zf(1,k) | ||
| sum_y = sum_y + zf(2,k) | ||
| sum_x2 = sum_x2 + zf(1,k)**2 | ||
| sum_xy = sum_xy + zf(1,k)*zf(2,k) | ||
| end do | ||
| n_real = real(n_lapse, RKIND) | ||
| if (n_lapse > 1) then | ||
| slope = (n_real*sum_xy - sum_x*sum_y) / (n_real*sum_x2 - sum_x**2) | ||
| else | ||
| slope = 0.0_RKIND | ||
| end if | ||
| vertical_interp = zf(2,1) + slope * (target_z - zf(1,1)) | ||
| end if | ||
|
Comment on lines
84
to
88
|
||
| return | ||
| end if | ||
|
|
@@ -92,9 +108,22 @@ real (kind=RKIND) function vertical_interp(target_z, nz, zf, order, extrap, surf | |
| slope = (zf(2,nz) - zf(2,nz-1)) / (zf(1,nz) - zf(1,nz-1)) | ||
| vertical_interp = zf(2,nz) + slope * (target_z - zf(1,nz)) | ||
|
Comment on lines
78
to
96
|
||
| else if (extrap_type == 2) then | ||
| call mpas_log_write('extrap_type == 2 not implemented for target_z >= zf(1,nz)', messageType=MPAS_LOG_ERR) | ||
| if (present(ierr)) ierr = 1 | ||
| return | ||
| n_lapse = min(nz, 3) | ||
| sum_x = 0.0_RKIND; sum_y = 0.0_RKIND | ||
| sum_x2 = 0.0_RKIND; sum_xy = 0.0_RKIND | ||
| do k = nz - n_lapse + 1, nz | ||
| sum_x = sum_x + zf(1,k) | ||
|
||
| sum_y = sum_y + zf(2,k) | ||
| sum_x2 = sum_x2 + zf(1,k)**2 | ||
| sum_xy = sum_xy + zf(1,k)*zf(2,k) | ||
| end do | ||
| n_real = real(n_lapse, RKIND) | ||
| if (n_lapse > 1) then | ||
| slope = (n_real*sum_xy - sum_x*sum_y) / (n_real*sum_x2 - sum_x**2) | ||
| else | ||
| slope = 0.0_RKIND | ||
| end if | ||
| vertical_interp = zf(2,nz) + slope * (target_z - zf(1,nz)) | ||
| end if | ||
|
Comment on lines
+78
to
101
|
||
| return | ||
| end if | ||
|
|
@@ -120,3 +149,4 @@ real (kind=RKIND) function vertical_interp(target_z, nz, zf, order, extrap, surf | |
| end function vertical_interp | ||
|
|
||
| end module init_atm_vinterp | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The lapse-rate extrapolation for the lower boundary (target_z < zf(1,1)) used to apply a fixed standard lapse rate (0.0065 K/m). This change switches extrap_type==2 to a least-squares slope fit from the lowest 1–3 input levels, which is a behavioral change beyond the PR description (which focuses on missing upper boundary support). Please confirm this is intended; if not, keep the fixed lapse-rate behavior for the lower boundary (and implement the same for the upper boundary) or update the PR description/namelist documentation accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hard-code 0.0065 K/m threshold is a field-specific constant that only produce a reasonable extrapolation when it is done for temperature in K. However, this is a field-agnostic function that is also used to extrapolate humidity, for example, which might produce unphysical extrapolated values. We will have a change in PR description before merging it.