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

[WIP] Improvement of testing routines #68

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
Draft

Conversation

AdelekeBankole
Copy link
Collaborator

This PR will close #64

@jatkinson1000 jatkinson1000 linked an issue Oct 18, 2024 that may be closed by this pull request
5 tasks
Copy link
Member

@jatkinson1000 jatkinson1000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @AdelekeBankole This looks great, thank you!

We have just run these locally and everything is passing.
Just left a couple of comments for things to check or suggestions to make things a little clearer.

Comment on lines 86 to +89
integer, parameter :: input_ver_dim = 30
!! The number of cells in a SAM atmospheric column on which the neural net was trained

integer, parameter :: num_sam_cells = 30
!! number of SAM cells
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These fulfill the same purpose - number of cells in a SAM column for which the net was trained, so we should look at combining them into one.

!! Define a CAM grid from 1111.0 to 10.0
!! Check interpolation to SAM grid by defining an idential CAM grid and
!! interpolating a variable equal to the pressure
!! Define a CAM grid consiting of 4 atmospheric columns
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
!! Define a CAM grid consiting of 4 atmospheric columns
!! Define a CAM grid consisting of 4 atmospheric columns

Comment on lines +34 to +38
real(dp), dimension(num_cols, nrf) :: p_cam, p_int_cam
real(dp), dimension(num_cols, nrf) :: var_cam
real(dp), dimension(num_cols) :: var_cam_surface
real(dp), dimension(num_cols) :: ps_cam
real(dp), dimension(num_cols, nrf) :: var_sam, var_sam_exp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These used to be length 48, but now use nrf which is length 30.
Should they be size sam_sounding instead of nrf?

Comment on lines -76 to +85
p_cam = reshape((/ 1000.0, 1000.0, 1000.0, 1000.0, 500.0, 500.0, 500.0, 500.0, 10.0, 10.0, 10.0, 10.0 /), (/ 4, 3 /))
real(dp), dimension(num_cols, num_cells) :: p_cam
real(dp), dimension(num_cols, num_cells) :: var_cam
real(dp), dimension(num_cols) :: var_cam_surface
real(dp), dimension(num_cols) :: ps_cam
real(dp), dimension(num_cols, num_sam_cells) :: var_sam, var_sam_exp

! Set up a coarse CAM grid of 4 columns of pressures [1000, 500, 10] hPa with surface pressure 1111 hPa
do i = 1, num_cols
p_cam(i, 1) = 1000.0
p_cam(i, 2) = 500.0
p_cam(i, 3) = 10.0
end do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is much much better than the hardcoded and reshaped array!

Comment on lines 99 to +101
!! Check interpolation to SAM grid by interpolating pressure to pressure
!! Set top of CAM to 1.0d-4
!! => should match pres from SAM
!! Use a coarse CAM grid of 3 cells and 4 columns
!! => expected variable on SAM grid should be pressure at that point
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we should provide a bit more of an explanation as to what this test is checking.
e.g.

We are setting the variable equal to the coordinates (pressure) on the CAM grid, i.e. y=x.
We expect the interpolated values on the SAM grid to also satisfy y=x on that grid

rho_cam(:, i) = var_cam(:, i) / (p_int_cam(:, i)-p_int_cam(:, i+1))
subroutine test_interp_to_cam_coarse(test_name)
!! Check conservative regridding to CAM coarse grid
!! => should conserve density
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
!! => should conserve density
!! => should conserve mass

Mass I think - as discussed.

! Fetch SAM grid data
call fetch_sam_data(pres_sam, presi_sam, gamaz_sam, rho_sam, z_sam)

! Define CAM grid coarser than SAM grid
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
! Define CAM grid coarser than SAM grid
! Define CAM grid coarser than SAM grid - one CAM cell to every 3 SAM cells.

Comment on lines +205 to 208
do j = 1, num_cols
! Set SAM variable (density) equal to 1.0
var_sam(j, :) = 1.0
end do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
do j = 1, num_cols
! Set SAM variable (density) equal to 1.0
var_sam(j, :) = 1.0
end do
! Set SAM variable (density) equal to 1.0
var_sam(:, :) = 1.0


subroutine test_interp_to_cam_coarse_variable_density(test_name)
!! Check conservative regridding to CAM coarse grid with variable density
!! => With integrated sum, this test should conserve density
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
!! => With integrated sum, this test should conserve density
!! => With integrated sum, this test should conserve mass

Comment on lines +255 to +260
do j = 1, num_cols
do i = 1, num_sam_cells
! Set SAM variable density not equal to 1.0
var_sam(j, i) = tan(real(i * j))
end do
end do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good function to use, and also because it varies across columns, so will check that our scheme is robust in that sense as well! Great job.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Regridding Tests Comprehensive testing of conservative regridding scheme (and other interface functions)
2 participants