From 2d3866f30c240b06e70528fb89ae2e6730678b5c Mon Sep 17 00:00:00 2001 From: Alistair Adcroft Date: Thu, 25 Jul 2024 14:10:17 -0400 Subject: [PATCH 1/2] Adds new pre-defined coordinate WOA09INT In OM4, we use the "WOA09" coordinate for diagnostic z* output. This grid was based on WOA09 but not exact because the WOA09 grid is not smooth. We tried to construct a grid such that layer centers matched the depths of WOA09 but this was not possible for six layers. As an alternative, this new coordinate, "WOA09INT", uses the WOA09 depths as interfaces so that the layer centers are always midway between the WOA09 depths. To compare with WOA09 directly, WOA data now should be interpolated but this is a simple half-half averaging. --- src/ALE/MOM_regridding.F90 | 60 +++++++++++++++++++++++++++++--------- 1 file changed, 47 insertions(+), 13 deletions(-) diff --git a/src/ALE/MOM_regridding.F90 b/src/ALE/MOM_regridding.F90 index 43d3f65a5e..7ac8cbb4a0 100644 --- a/src/ALE/MOM_regridding.F90 +++ b/src/ALE/MOM_regridding.F90 @@ -226,12 +226,22 @@ subroutine initialize_regridding(CS, GV, US, max_depth, param_file, mdl, coord_m real, dimension(:), allocatable :: dz_max ! Thicknesses used to find maximum interface depths ! [H ~> m or kg m-2] or other units real, dimension(:), allocatable :: rho_target ! Target density used in HYBRID mode [kg m-3] - !> Thicknesses [m] that give level centers corresponding to table 2 of WOA09 - real, dimension(40) :: woa09_dz = (/ 5., 10., 10., 15., 22.5, 25., 25., 25., & - 37.5, 50., 50., 75., 100., 100., 100., 100., & - 100., 100., 100., 100., 100., 100., 100., 175., & - 250., 375., 500., 500., 500., 500., 500., 500., & - 500., 500., 500., 500., 500., 500., 500., 500. /) + ! Thicknesses [m] that give level centers approximately corresponding to table 2 of WOA09 + ! These are approximate because the WOA09 depths are not smoothly spaced. Levels + ! 1, 4, 5, 9, 12, 24, and 36 are 2.5, 2.5, 1.25 12.5, 37.5 and 62.5 m deeper than WOA09 + ! but all others are identical. + real, dimension(40) :: woa09_dz_approx = (/ 5., 10., 10., 15., 22.5, 25., 25., 25., & + 37.5, 50., 50., 75., 100., 100., 100., 100., & + 100., 100., 100., 100., 100., 100., 100., 175., & + 250., 375., 500., 500., 500., 500., 500., 500., & + 500., 500., 500., 500., 500., 500., 500., 500. /) + ! These are the actual spacings [m] between WOA09 depths which, if used for layer thickness, places + ! the interfaces at the WOA09 depths. + real, dimension(39) :: woa09_dzi = (/ 10., 10., 10., 20., 25., 25., 25., 25., & + 50., 50., 50., 100., 100., 100., 100., 100., & + 100., 100., 100., 100., 100., 100., 100., 250., & + 250., 500., 500., 500., 500., 500., 500., 500., & + 500., 500., 500., 500., 500., 500., 500. /) call get_param(param_file, mdl, "INPUTDIR", inputdir, default=".") inputdir = slasher(inputdir) @@ -325,6 +335,7 @@ subroutine initialize_regridding(CS, GV, US, max_depth, param_file, mdl, coord_m " by a comma or space, e.g. FILE:lev.nc,dz\n"//& " or FILE:lev.nc,interfaces=zw\n"//& " WOA09[:N] - the WOA09 vertical grid (approximately)\n"//& + " WOA09INT[:N] - layers spanned by the WOA09 depths\n"//& " FNC1:string - FNC1:dz_min,H_total,power,precision\n"//& " HYBRID:string - read from a file. The string specifies\n"//& " the filename and two variable names, separated\n"//& @@ -458,18 +469,41 @@ subroutine initialize_regridding(CS, GV, US, max_depth, param_file, mdl, coord_m call log_param(param_file, mdl, "!TARGET_DENSITIES", rho_target, & 'HYBRID target densities for interfaces', units=coordinateUnits(coord_mode)) endif + elseif (index(trim(string),'WOA09INT')==1) then + if (len_trim(string)==8) then ! string=='WOA09INT' + tmpReal = 0. ; ke = 0 ; dz_extra = 0. + do while (tmpReal size(woa09_dzi)) then + dz_extra = maximum_depth - tmpReal + exit + endif + tmpReal = tmpReal + woa09_dzi(ke) + enddo + elseif (index(trim(string),'WOA09INT:')==1) then ! string starts with 'WOA09INT:' + if (len_trim(string)==9) call MOM_error(FATAL,trim(mdl)//', initialize_regridding: '// & + 'Expected string of form "WOA09INT:N" but got "'//trim(string)//'".') + ke = extract_integer(string(10:len_trim(string)),'',1) + if (ke>39 .or. ke<1) call MOM_error(FATAL,trim(mdl)//', initialize_regridding: '// & + 'For "WOA05INT:N" N must 0 size(woa09_dzi)) dz(ke) = dz_extra elseif (index(trim(string),'WOA09')==1) then - if (len_trim(string)==5) then + if (len_trim(string)==5) then ! string=='WOA09' tmpReal = 0. ; ke = 0 ; dz_extra = 0. do while (tmpReal size(woa09_dz)) then + if (ke > size(woa09_dz_approx)) then dz_extra = maximum_depth - tmpReal exit endif - tmpReal = tmpReal + woa09_dz(ke) + tmpReal = tmpReal + woa09_dz_approx(ke) enddo - elseif (index(trim(string),'WOA09:')==1) then + elseif (index(trim(string),'WOA09:')==1) then ! string starts with 'WOA09:' if (len_trim(string)==6) call MOM_error(FATAL,trim(mdl)//', initialize_regridding: '// & 'Expected string of form "WOA09:N" but got "'//trim(string)//'".') ke = extract_integer(string(7:len_trim(string)),'',1) @@ -477,10 +511,10 @@ subroutine initialize_regridding(CS, GV, US, max_depth, param_file, mdl, coord_m 'For "WOA05:N" N must 0 size(woa09_dz)) dz(ke) = dz_extra + if (ke > size(woa09_dz_approx)) dz(ke) = dz_extra else call MOM_error(FATAL,trim(mdl)//", initialize_regridding: "// & "Unrecognized coordinate configuration"//trim(string)) From e8f3cb7046466c5bd4df31377f53fb4afd6cb76e Mon Sep 17 00:00:00 2001 From: Alistair Adcroft Date: Thu, 25 Jul 2024 15:26:13 -0400 Subject: [PATCH 2/2] Adds new pre-defined coordinate WOA23INT Encoded the WOA23 depth spacing to use for finer resolution diagnostic grid. As for WOA09INT, the WOA23 depths are used as interface positions requiring the WOA23 data to be interpolated (half-half averaging) to this WOA23INT grid. --- src/ALE/MOM_regridding.F90 | 42 +++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/src/ALE/MOM_regridding.F90 b/src/ALE/MOM_regridding.F90 index 7ac8cbb4a0..0d325292f5 100644 --- a/src/ALE/MOM_regridding.F90 +++ b/src/ALE/MOM_regridding.F90 @@ -230,7 +230,7 @@ subroutine initialize_regridding(CS, GV, US, max_depth, param_file, mdl, coord_m ! These are approximate because the WOA09 depths are not smoothly spaced. Levels ! 1, 4, 5, 9, 12, 24, and 36 are 2.5, 2.5, 1.25 12.5, 37.5 and 62.5 m deeper than WOA09 ! but all others are identical. - real, dimension(40) :: woa09_dz_approx = (/ 5., 10., 10., 15., 22.5, 25., 25., 25., & + real, dimension(40) :: woa09_dz_approx = (/ 5., 10., 10., 15., 22.5, 25., 25., 25., & 37.5, 50., 50., 75., 100., 100., 100., 100., & 100., 100., 100., 100., 100., 100., 100., 175., & 250., 375., 500., 500., 500., 500., 500., 500., & @@ -242,6 +242,22 @@ subroutine initialize_regridding(CS, GV, US, max_depth, param_file, mdl, coord_m 100., 100., 100., 100., 100., 100., 100., 250., & 250., 500., 500., 500., 500., 500., 500., 500., & 500., 500., 500., 500., 500., 500., 500. /) + ! These are the spacings [m] between WOA23 depths from table 3 of + ! https://www.ncei.noaa.gov/data/oceans/woa/WOA13/DOC/woa13documentation.pdf + real, dimension(136) :: woa23_dzi = (/ 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., & + 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., & + 25., 25., 25., 25., 25., 25., 25., 25., 25., 25., & + 25., 25., 25., 25., 25., 25., 50., 50., 50., 50., & + 50., 50., 50., 50., 50., 50., 50., 50., 50., 50., & + 50., 50., 50., 50., 50., 50., 50., 50., 50., 50., & + 50., 50., 50., 50., 50., 50., 100., 100., 100., 100., & + 100., 100., 100., 100., 100., 100., 100., 100., 100., 100., & + 100., 100., 100., 100., 100., 100., 100., 100., 100., 100., & + 100., 100., 100., 100., 100., 100., 100., 100., 100., 100., & + 100., 100., 100., 100., 100., 100., 100., 100., 100., 100., & + 100., 100., 100., 100., 100., 100., 100., 100., 100., 100., & + 100., 100., 100., 100., 100., 100., 100., 100., 100., 100., & + 100., 100., 100., 100., 100., 100. /) call get_param(param_file, mdl, "INPUTDIR", inputdir, default=".") inputdir = slasher(inputdir) @@ -336,6 +352,7 @@ subroutine initialize_regridding(CS, GV, US, max_depth, param_file, mdl, coord_m " or FILE:lev.nc,interfaces=zw\n"//& " WOA09[:N] - the WOA09 vertical grid (approximately)\n"//& " WOA09INT[:N] - layers spanned by the WOA09 depths\n"//& + " WOA23INT[:N] - layers spanned by the WOA23 depths\n"//& " FNC1:string - FNC1:dz_min,H_total,power,precision\n"//& " HYBRID:string - read from a file. The string specifies\n"//& " the filename and two variable names, separated\n"//& @@ -492,6 +509,29 @@ subroutine initialize_regridding(CS, GV, US, max_depth, param_file, mdl, coord_m dz(k) = woa09_dzi(k) enddo if (ke > size(woa09_dzi)) dz(ke) = dz_extra + elseif (index(trim(string),'WOA23INT')==1) then + if (len_trim(string)==8) then ! string=='WOA23INT' + tmpReal = 0. ; ke = 0 ; dz_extra = 0. + do while (tmpReal size(woa23_dzi)) then + dz_extra = maximum_depth - tmpReal + exit + endif + tmpReal = tmpReal + woa23_dzi(ke) + enddo + elseif (index(trim(string),'WOA23INT:')==1) then ! string starts with 'WOA23INT:' + if (len_trim(string)==9) call MOM_error(FATAL,trim(mdl)//', initialize_regridding: '// & + 'Expected string of form "WOA23INT:N" but got "'//trim(string)//'".') + ke = extract_integer(string(10:len_trim(string)),'',1) + if (ke>39 .or. ke<1) call MOM_error(FATAL,trim(mdl)//', initialize_regridding: '// & + 'For "WOA05INT:N" N must 0 size(woa23_dzi)) dz(ke) = dz_extra elseif (index(trim(string),'WOA09')==1) then if (len_trim(string)==5) then ! string=='WOA09' tmpReal = 0. ; ke = 0 ; dz_extra = 0.