From 8a90be604232d20a790552e50b9f92ed87194a70 Mon Sep 17 00:00:00 2001 From: Helen Kershaw Date: Thu, 29 Aug 2024 12:26:32 -0600 Subject: [PATCH 1/6] fix: mask out missing values from MOM6 geolon|lat|u|v files fixes #685 force longitudes to be between 0-360. The missing value 1e20 is in this calculation. Not sure whether to put missing value back in to avoid accidental use. --- models/MOM6/model_mod.f90 | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/models/MOM6/model_mod.f90 b/models/MOM6/model_mod.f90 index f03283b7b3..29fd1f2626 100644 --- a/models/MOM6/model_mod.f90 +++ b/models/MOM6/model_mod.f90 @@ -97,6 +97,7 @@ module model_mod real(r8), allocatable :: geolon(:,:), geolat(:,:), & ! T geolon_u(:,:), geolat_u(:,:), & ! U geolon_v(:,:), geolat_v(:,:) ! V +logical, allocatable :: mask(:,:) ! geolat/lon/u/v has missing values type(quad_interp_handle) :: interp_t_grid, & interp_u_grid, & interp_v_grid @@ -606,17 +607,25 @@ subroutine read_horizontal_grid() allocate(geolon(nx,ny), geolat(nx,ny)) ! T grid allocate(geolon_u(nx,ny), geolat_u(nx,ny)) ! U grid allocate(geolon_v(nx,ny), geolat_v(nx,ny)) ! V grid +allocate(mask(nx,ny)) ! missing values call nc_get_variable(ncid, 'geolon', geolon, routine) call nc_get_variable(ncid, 'geolon_u', geolon_u, routine) call nc_get_variable(ncid, 'geolon_v', geolon_v, routine) +! mom6 has missing values in the grid +mask(:,:) = .false. +where (geolon == 1.0e+20) mask = .true. !HK tood should check for missing value -! mom6 example file has longitude > 360 +! mom6 example files have longitude > 360 and longitudes < 0 ! DART uses [0,360] -where(geolon > 360.0_r8 ) geolon = geolon - 360.0_r8 -where(geolon_u > 360.0_r8 ) geolon_u = geolon_u - 360.0_r8 -where(geolon_v > 360.0_r8 ) geolon_v = geolon_v - 360.0_r8 +geolon = mod(geolon, 360.0) +geolon_u = mod(geolon_u, 360.0) +geolon_v = mod(geolon_v, 360.0) + +where (geolon < 0.0) geolon = geolon + 360 +where (geolon_u < 0.0) geolon_u = geolon_u + 360 +where (geolon_v < 0.0) geolon_v = geolon_v + 360 call nc_get_variable(ncid, 'geolat', geolat, routine) call nc_get_variable(ncid, 'geolat_u', geolat_u, routine) @@ -831,7 +840,7 @@ subroutine setup_interpolation() global=.true., spans_lon_zero=.true., pole_wrap=.true., & interp_handle=interp_t_grid) -call set_quad_coords(interp_t_grid, geolon, geolat) +call set_quad_coords(interp_t_grid, geolon, geolat, mask) ! U call init_quad_interp(GRID_QUAD_FULLY_IRREGULAR, nx, ny, & @@ -839,7 +848,7 @@ subroutine setup_interpolation() global=.true., spans_lon_zero=.true., pole_wrap=.true., & interp_handle=interp_u_grid) -call set_quad_coords(interp_u_grid, geolon_u, geolat_u) +call set_quad_coords(interp_u_grid, geolon_u, geolat_u, mask) ! V @@ -848,7 +857,7 @@ subroutine setup_interpolation() global=.true., spans_lon_zero=.true., pole_wrap=.true., & interp_handle=interp_v_grid) -call set_quad_coords(interp_v_grid, geolon_v, geolat_v) +call set_quad_coords(interp_v_grid, geolon_v, geolat_v, mask) end subroutine setup_interpolation From 1cc8ded1bb5da182a3035e608e60904e61e22819 Mon Sep 17 00:00:00 2001 From: Helen Kershaw Date: Fri, 30 Aug 2024 07:05:36 -0600 Subject: [PATCH 2/6] query the fill value from the mom6.static.nc file mask where geolon is the fillvalue. Note the mask for geolon/lat/u/v is not the same as 'wet' from the ocean_geometry.nc file. Setting the masked lat lon values to a land value. This is because set_location is used on all the lat, lon vaues and 1e20 will blow up set_location --- models/MOM6/model_mod.f90 | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/models/MOM6/model_mod.f90 b/models/MOM6/model_mod.f90 index 29fd1f2626..6b9054ee64 100644 --- a/models/MOM6/model_mod.f90 +++ b/models/MOM6/model_mod.f90 @@ -32,7 +32,7 @@ module model_mod nc_begin_define_mode, nc_end_define_mode, & nc_open_file_readonly, nc_close_file, & nc_get_variable, nc_get_variable_size, & - NF90_MAX_NAME + NF90_MAX_NAME, nc_get_attribute_from_variable use quad_utils_mod, only : quad_interp_handle, init_quad_interp, & set_quad_coords, quad_lon_lat_locate, & @@ -596,6 +596,7 @@ subroutine read_horizontal_grid() integer :: ncid integer :: nxy(2) ! (nx,ny) +real(r8) :: fillval character(len=*), parameter :: routine = 'read_horizontal_grid' @@ -613,9 +614,23 @@ subroutine read_horizontal_grid() call nc_get_variable(ncid, 'geolon_u', geolon_u, routine) call nc_get_variable(ncid, 'geolon_v', geolon_v, routine) +call nc_get_variable(ncid, 'geolat', geolat, routine) +call nc_get_variable(ncid, 'geolat_u', geolat_u, routine) +call nc_get_variable(ncid, 'geolat_v', geolat_v, routine) + ! mom6 has missing values in the grid mask(:,:) = .false. -where (geolon == 1.0e+20) mask = .true. !HK tood should check for missing value +call nc_get_attribute_from_variable(ncid, 'geolon', '_FillValue', fillval) +where (geolon == fillval) mask = .true. + +! set missing value to a land point to prevent set_location erroring +where (geolon == fillval) geolon = 72.51 +where (geolon_u == fillval) geolon_u = 72.51 +where (geolon_v == fillval) geolon_v = 72.51 + +where (geolat == fillval) geolat = 42.56 +where (geolat_u == fillval) geolat_u = 42.56 +where (geolat_v == fillval) geolat_v = 42.56 ! mom6 example files have longitude > 360 and longitudes < 0 ! DART uses [0,360] @@ -627,10 +642,6 @@ subroutine read_horizontal_grid() where (geolon_u < 0.0) geolon_u = geolon_u + 360 where (geolon_v < 0.0) geolon_v = geolon_v + 360 -call nc_get_variable(ncid, 'geolat', geolat, routine) -call nc_get_variable(ncid, 'geolat_u', geolat_u, routine) -call nc_get_variable(ncid, 'geolat_v', geolat_v, routine) - call nc_close_file(ncid) end subroutine read_horizontal_grid From 7020598106734fddcd2722ed6fa639c01b2edbd9 Mon Sep 17 00:00:00 2001 From: Helen Kershaw Date: Fri, 30 Aug 2024 07:19:16 -0600 Subject: [PATCH 3/6] namelist: set cutoff to something not giant perfect_model_obs init time as -1 -1 --- models/MOM6/work/input.nml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/models/MOM6/work/input.nml b/models/MOM6/work/input.nml index e442ab8c2a..23c6756e15 100644 --- a/models/MOM6/work/input.nml +++ b/models/MOM6/work/input.nml @@ -20,8 +20,8 @@ obs_seq_in_file_name = "obs_seq.in", obs_seq_out_file_name = "obs_seq.out", - init_time_days = 0, - init_time_seconds = 0, + init_time_days = -1, + init_time_seconds = -1, first_obs_days = -1, first_obs_seconds = -1, last_obs_days = -1, @@ -93,7 +93,7 @@ / &assim_tools_nml - cutoff = 1000000.0 + cutoff = 0.03 sort_obs_inc = .false., spread_restoration = .false., sampling_error_correction = .false., From 74c5c9dc1e178b1db4e87135a0515b1c06be0298 Mon Sep 17 00:00:00 2001 From: Helen Kershaw Date: Thu, 26 Sep 2024 11:42:12 -0600 Subject: [PATCH 4/6] fix: mask for t,u,v grids Cautious approach, since it is possible that the missing value mask may not be at the same place --- models/MOM6/model_mod.f90 | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/models/MOM6/model_mod.f90 b/models/MOM6/model_mod.f90 index 6b9054ee64..4284af0dbf 100644 --- a/models/MOM6/model_mod.f90 +++ b/models/MOM6/model_mod.f90 @@ -97,7 +97,7 @@ module model_mod real(r8), allocatable :: geolon(:,:), geolat(:,:), & ! T geolon_u(:,:), geolat_u(:,:), & ! U geolon_v(:,:), geolat_v(:,:) ! V -logical, allocatable :: mask(:,:) ! geolat/lon/u/v has missing values +logical, allocatable :: mask(:,:), mask_u(:,:), mask_v(:,:) ! geolat/lon/u/v has missing values type(quad_interp_handle) :: interp_t_grid, & interp_u_grid, & interp_v_grid @@ -609,6 +609,8 @@ subroutine read_horizontal_grid() allocate(geolon_u(nx,ny), geolat_u(nx,ny)) ! U grid allocate(geolon_v(nx,ny), geolat_v(nx,ny)) ! V grid allocate(mask(nx,ny)) ! missing values +allocate(mask_u(nx,ny)) ! missing values +allocate(mask_v(nx,ny)) ! missing values call nc_get_variable(ncid, 'geolon', geolon, routine) call nc_get_variable(ncid, 'geolon_u', geolon_u, routine) @@ -620,8 +622,14 @@ subroutine read_horizontal_grid() ! mom6 has missing values in the grid mask(:,:) = .false. +mask_u(:,:) = .false. +mask_v(:,:) = .false. call nc_get_attribute_from_variable(ncid, 'geolon', '_FillValue', fillval) where (geolon == fillval) mask = .true. +call nc_get_attribute_from_variable(ncid, 'geolon_u', '_FillValue', fillval) +where (geolon_u == fillval) mask_u = .true. +call nc_get_attribute_from_variable(ncid, 'geolon_v', '_FillValue', fillval) +where (geolon_v == fillval) mask_v = .true. ! set missing value to a land point to prevent set_location erroring where (geolon == fillval) geolon = 72.51 @@ -859,7 +867,7 @@ subroutine setup_interpolation() global=.true., spans_lon_zero=.true., pole_wrap=.true., & interp_handle=interp_u_grid) -call set_quad_coords(interp_u_grid, geolon_u, geolat_u, mask) +call set_quad_coords(interp_u_grid, geolon_u, geolat_u, mask_u) ! V @@ -868,7 +876,7 @@ subroutine setup_interpolation() global=.true., spans_lon_zero=.true., pole_wrap=.true., & interp_handle=interp_v_grid) -call set_quad_coords(interp_v_grid, geolon_v, geolat_v, mask) +call set_quad_coords(interp_v_grid, geolon_v, geolat_v, mask_v) end subroutine setup_interpolation From 448f5230dbf9a2958b407fa3cbb06645f56572ae Mon Sep 17 00:00:00 2001 From: Helen Kershaw Date: Thu, 26 Sep 2024 13:32:03 -0600 Subject: [PATCH 5/6] fix: fill value check for t,u,v --- models/MOM6/model_mod.f90 | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/models/MOM6/model_mod.f90 b/models/MOM6/model_mod.f90 index 4284af0dbf..e6ebcd03f3 100644 --- a/models/MOM6/model_mod.f90 +++ b/models/MOM6/model_mod.f90 @@ -621,23 +621,23 @@ subroutine read_horizontal_grid() call nc_get_variable(ncid, 'geolat_v', geolat_v, routine) ! mom6 has missing values in the grid +! and set missing value to a land point to prevent set_location erroring mask(:,:) = .false. mask_u(:,:) = .false. mask_v(:,:) = .false. call nc_get_attribute_from_variable(ncid, 'geolon', '_FillValue', fillval) where (geolon == fillval) mask = .true. +where (geolon == fillval) geolon = 72.51 +where (geolat == fillval) geolat = 42.56 + call nc_get_attribute_from_variable(ncid, 'geolon_u', '_FillValue', fillval) where (geolon_u == fillval) mask_u = .true. +where (geolon_u == fillval) geolon_u = 72.51 +where (geolat_u == fillval) geolat_u = 42.56 + call nc_get_attribute_from_variable(ncid, 'geolon_v', '_FillValue', fillval) where (geolon_v == fillval) mask_v = .true. - -! set missing value to a land point to prevent set_location erroring -where (geolon == fillval) geolon = 72.51 -where (geolon_u == fillval) geolon_u = 72.51 where (geolon_v == fillval) geolon_v = 72.51 - -where (geolat == fillval) geolat = 42.56 -where (geolat_u == fillval) geolat_u = 42.56 where (geolat_v == fillval) geolat_v = 42.56 ! mom6 example files have longitude > 360 and longitudes < 0 From 3405802fc09a4ba280e71f6a9ddcb7e9ca79a437 Mon Sep 17 00:00:00 2001 From: Helen Kershaw Date: Fri, 27 Sep 2024 09:11:32 -0400 Subject: [PATCH 6/6] bump version and changelog for release --- CHANGELOG.rst | 7 ++++++- conf.py | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index d31552f944..8bc9db08b3 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -22,7 +22,12 @@ individual files. The changes are now listed with the most recent at the top. -**September 10 2024:: MARBL_column. Tag 11.8.0** +**September 27 2024 :: MOM6 mask bug-fix. Tag 11.8.1** + +- Fix for MOM6 CESM3 workhorse 2/3 degree grid TL319_t232 to + mask missing geolon|lat|u|v|t values + +**September 10 2024 :: MARBL_column. Tag 11.8.0** - Interface for MARBL_column for DART: diff --git a/conf.py b/conf.py index 833c43425d..d78663aefd 100644 --- a/conf.py +++ b/conf.py @@ -21,7 +21,7 @@ author = 'Data Assimilation Research Section' # The full version, including alpha/beta/rc tags -release = '11.8.0' +release = '11.8.1' root_doc = 'index' # -- General configuration ---------------------------------------------------