From cc75731bbb2450609266d3a4530cd3c02a78f805 Mon Sep 17 00:00:00 2001 From: ezhilsabareesh8 Date: Thu, 24 Oct 2024 12:40:11 +1100 Subject: [PATCH 01/25] add_t_cell_cutoff_function --- README.md | 7 +++++++ src/topography.f90 | 50 ++++++++++++++++++++++++++++++++++++++++++++++ src/topogtools.f90 | 32 ++++++++++++++++++++++++++++- 3 files changed, 88 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 16eb61c..71da438 100644 --- a/README.md +++ b/README.md @@ -137,6 +137,13 @@ double-precision topography file. Options * `--vgrid ` vertical grid (default 'ocean_vgrid.nc') +## cut_off_T_cells + +``` +usage: topogtools cut_off_T_cells --input --output --hgrid --cutoff +``` + +Cut off T cells with size smaller than . Cut off should be in kilometers # Building and Installation diff --git a/src/topography.f90 b/src/topography.f90 index 8651e21..b411a1c 100644 --- a/src/topography.f90 +++ b/src/topography.f90 @@ -35,6 +35,7 @@ module topography procedure :: nonadvective => topography_nonadvective procedure :: min_max_depth => topography_min_max_depth procedure :: mask => topography_mask + procedure :: cut_off_T_cells => topography_cut_off_T_cells end type topography_t interface topography_t @@ -464,6 +465,55 @@ subroutine topography_min_max_depth(this, vgrid_file, vgrid_type, level) end subroutine topography_min_max_depth + subroutine topography_cut_off_T_cells(this, hgrid, cutoff) + class(topography_t), intent(inout) :: this + character(len=*), intent(in) :: hgrid + real(real64), intent(in) :: cutoff + + integer(int32) :: i,j + integer(int32) :: ncid_hgrid, dy_id ! NetCDF ids for hgrid + integer(int32) :: dids_dy(2) ! NetCDF ids for dimensions + integer(int32) :: ny_len, nxp_len, nx_len ! dimensions for hgrid + real(real64), allocatable :: dy(:,:) ! To store dy variable from hgrid + real(real64), allocatable :: dy_t(:,:) ! To store dy_t (new array) + + ! Read hgrid to get dy + print*, 'Attempting to open:', trim(hgrid) + call handle_error(nf90_open(trim(hgrid), nf90_nowrite, ncid_hgrid)) + call handle_error(nf90_inq_varid(ncid_hgrid, 'dy', dy_id)) + call handle_error(nf90_inquire_variable(ncid_hgrid, dy_id, dimids=dids_dy)) + call handle_error(nf90_inquire_dimension(ncid_hgrid, dids_dy(1), len=ny_len)) + call handle_error(nf90_inquire_dimension(ncid_hgrid, dids_dy(2), len=nxp_len)) + + ! Allocate memory for dy based on its dimensions + allocate(dy(ny_len, nxp_len)) + + ! Read the dy variable from hgrid + call handle_error(nf90_get_var(ncid_hgrid, dy_id, dy)) + call handle_error(nf90_close(ncid_hgrid)) + + ! Calculate dy_t based on dy + ! dy_t = dy[::2, 1::2] + dy[1::2, 1::2] + ! This means dy_t will have half the number of rows and columns as dy + allocate(dy_t(int(ny_len / 2), int((nxp_len - 1) / 2))) + + do i = 1, int(ny_len / 2) + do j = 1, int((nxp_len - 1) / 2) + dy_t(i, j) = dy(2 * i - 1, 2 * j) + dy(2 * i, 2 * j) + end do + end do + + ! Apply cutoff to depth based on the provided T-cell cutoff value in kilometers + do i = 1, int(ny_len / 2) + do j = 1, int((nxp_len - 1) / 2) + if (dy_t(i, j) < cutoff*1000.0) then !Input cutoff in Kilometers covert it to meters + this%depth(i, j) = MISSING_VALUE ! Set values below cutoff to zero or another value as needed + end if + end do + end do + +end subroutine topography_cut_off_T_cells + !------------------------------------------------------------------------- subroutine topography_fill_fraction(this, sea_area_fraction) class(topography_t), intent(inout) :: this diff --git a/src/topogtools.f90 b/src/topogtools.f90 index dbc4313..c5ecf7c 100644 --- a/src/topogtools.f90 +++ b/src/topogtools.f90 @@ -8,12 +8,13 @@ program topogtools character(len=5), PARAMETER :: VERSION = "1.0.0" character(len=:), allocatable :: name - character(len=:), allocatable :: help_general(:), help_gen_topo(:), help_deseas(:), help_min_max_depth(:) + character(len=:), allocatable :: help_general(:), help_gen_topo(:), help_deseas(:), help_min_max_depth(:), help_cutoff(:) character(len=:), allocatable :: help_fill_fraction(:), help_fix_nonadvective(:), help_check_nonadvective(:), help_mask(:) character(len=80) :: version_text(1) character(len=:), allocatable :: file_in, file_out, hgrid, vgrid type(topography_t) :: topog real(real32) :: sea_area_fraction + real(real64) :: cutoff integer :: ii version_text(1) = 'topogtools version '//VERSION @@ -33,6 +34,7 @@ program topogtools ' check_nonadvective - Check for non-advective cells ', & ' fix_nonadvective - Fix non-advective cells ', & ' mask - Generate mask ', & + ' cut_off_T_cells - Cut off T cells below a certain cell size ', & ''] help_gen_topo = [character(len=80) :: & 'usage: topogtools gen_topo --input --output ', & @@ -109,6 +111,14 @@ program topogtools 'Creates a land mask from a topography. ', & ''] + help_cutoff = [character(len=80) :: & + 'usage: topogtools cut_off_T_cells --input --output ', & + ' --hgrid --cutoff ', & + ' ', & + 'Cut off T cells with size smaller than . Writes the ', & + 'result to . ', & + 'Cut off should be in kilometers'] + ! Read command line name = get_subcommand() select case (name) @@ -130,6 +140,8 @@ program topogtools help_check_nonadvective, version_text) case ('mask') call set_args('--input:i "unset" --output:o "unset"', help_mask, version_text) + case ('cut_off_T_cells') + call set_args('--input:i "unset" --output:o "unset" --hgrid "ocean_hgrid.nc" --cutoff 0.0', help_cutoff, version_text) case ('') ! Print help in case the user specified the --help flag call set_args(' ', help_general, version_text) @@ -210,6 +222,24 @@ program topogtools topog = topography_t(file_in) call topog%mask(file_out) + case ('cut_off_T_cells') + hgrid = sget('hgrid') + call check_file_exist(hgrid) + cutoff = rget('cutoff') + if (cutoff <= 0.0) then + write(error_unit,'(a)') "ERROR: cutoff value must be larger than 0 " + error stop + end if + file_out = sget('output') + if (file_out == 'unset') then + write(error_unit,'(a)') 'ERROR: no output file specified' + error stop + end if + topog = topography_t(file_in) + call topog%cut_off_T_cells(hgrid,cutoff) + call topog%update_history(get_mycommand()) + call topog%write(file_out) + end select end program topogtools From d1116288246800736ccd0fbf84af617d2aabaa39 Mon Sep 17 00:00:00 2001 From: ezhilsabareesh8 <108497463+ezhilsabareesh8@users.noreply.github.com> Date: Fri, 25 Oct 2024 14:04:02 +1100 Subject: [PATCH 02/25] Tidy up src/topography.f90 Co-authored-by: Micael Oliveira --- src/topography.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/topography.f90 b/src/topography.f90 index b411a1c..360dd8e 100644 --- a/src/topography.f90 +++ b/src/topography.f90 @@ -470,7 +470,7 @@ subroutine topography_cut_off_T_cells(this, hgrid, cutoff) character(len=*), intent(in) :: hgrid real(real64), intent(in) :: cutoff - integer(int32) :: i,j + integer(int32) :: i, j integer(int32) :: ncid_hgrid, dy_id ! NetCDF ids for hgrid integer(int32) :: dids_dy(2) ! NetCDF ids for dimensions integer(int32) :: ny_len, nxp_len, nx_len ! dimensions for hgrid From 708b1ea694f8fefc6f635a5f247635c75ea2ab9b Mon Sep 17 00:00:00 2001 From: ezhilsabareesh8 <108497463+ezhilsabareesh8@users.noreply.github.com> Date: Fri, 25 Oct 2024 14:05:10 +1100 Subject: [PATCH 03/25] Change single to double precision for unit coversion Co-authored-by: Micael Oliveira --- src/topography.f90 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/topography.f90 b/src/topography.f90 index 360dd8e..d9311d1 100644 --- a/src/topography.f90 +++ b/src/topography.f90 @@ -506,10 +506,10 @@ subroutine topography_cut_off_T_cells(this, hgrid, cutoff) ! Apply cutoff to depth based on the provided T-cell cutoff value in kilometers do i = 1, int(ny_len / 2) do j = 1, int((nxp_len - 1) / 2) - if (dy_t(i, j) < cutoff*1000.0) then !Input cutoff in Kilometers covert it to meters - this%depth(i, j) = MISSING_VALUE ! Set values below cutoff to zero or another value as needed - end if - end do + if (dy_t(i, j) < cutoff*1000.0_real64) then !Input cutoff in Kilometers covert it to meters + this%depth(i, j) = MISSING_VALUE ! Set values below cutoff to zero or another value as needed + end if + end do end do end subroutine topography_cut_off_T_cells From 8fb623c317bb89725156db156843f13c06da8adc Mon Sep 17 00:00:00 2001 From: ezhilsabareesh8 <108497463+ezhilsabareesh8@users.noreply.github.com> Date: Fri, 25 Oct 2024 14:05:53 +1100 Subject: [PATCH 04/25] Tidy up src/topography.f90 Co-authored-by: Micael Oliveira --- src/topography.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/topography.f90 b/src/topography.f90 index d9311d1..22e442d 100644 --- a/src/topography.f90 +++ b/src/topography.f90 @@ -499,7 +499,7 @@ subroutine topography_cut_off_T_cells(this, hgrid, cutoff) do i = 1, int(ny_len / 2) do j = 1, int((nxp_len - 1) / 2) - dy_t(i, j) = dy(2 * i - 1, 2 * j) + dy(2 * i, 2 * j) + dy_t(i, j) = dy(2 * i - 1, 2 * j) + dy(2 * i, 2 * j) end do end do From 07b135f2d20a1e456085c078804a679ef8fa388d Mon Sep 17 00:00:00 2001 From: ezhilsabareesh8 <108497463+ezhilsabareesh8@users.noreply.github.com> Date: Fri, 25 Oct 2024 14:06:52 +1100 Subject: [PATCH 05/25] Tidy up src/topography.f90 Co-authored-by: Micael Oliveira --- src/topography.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/topography.f90 b/src/topography.f90 index 22e442d..8e1af2f 100644 --- a/src/topography.f90 +++ b/src/topography.f90 @@ -478,7 +478,7 @@ subroutine topography_cut_off_T_cells(this, hgrid, cutoff) real(real64), allocatable :: dy_t(:,:) ! To store dy_t (new array) ! Read hgrid to get dy - print*, 'Attempting to open:', trim(hgrid) + write(output_unit,'(3a)') "Attempting to open file '", trim(hgrid), "'" call handle_error(nf90_open(trim(hgrid), nf90_nowrite, ncid_hgrid)) call handle_error(nf90_inq_varid(ncid_hgrid, 'dy', dy_id)) call handle_error(nf90_inquire_variable(ncid_hgrid, dy_id, dimids=dids_dy)) From 63bc14f5d0d4b08020458310fdf88e11ba03355c Mon Sep 17 00:00:00 2001 From: ezhilsabareesh8 Date: Fri, 25 Oct 2024 14:30:13 +1100 Subject: [PATCH 06/25] Remove intermediate array dy_t --- src/topography.f90 | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/src/topography.f90 b/src/topography.f90 index 8e1af2f..60271ba 100644 --- a/src/topography.f90 +++ b/src/topography.f90 @@ -475,7 +475,6 @@ subroutine topography_cut_off_T_cells(this, hgrid, cutoff) integer(int32) :: dids_dy(2) ! NetCDF ids for dimensions integer(int32) :: ny_len, nxp_len, nx_len ! dimensions for hgrid real(real64), allocatable :: dy(:,:) ! To store dy variable from hgrid - real(real64), allocatable :: dy_t(:,:) ! To store dy_t (new array) ! Read hgrid to get dy write(output_unit,'(3a)') "Attempting to open file '", trim(hgrid), "'" @@ -492,25 +491,16 @@ subroutine topography_cut_off_T_cells(this, hgrid, cutoff) call handle_error(nf90_get_var(ncid_hgrid, dy_id, dy)) call handle_error(nf90_close(ncid_hgrid)) - ! Calculate dy_t based on dy - ! dy_t = dy[::2, 1::2] + dy[1::2, 1::2] - ! This means dy_t will have half the number of rows and columns as dy - allocate(dy_t(int(ny_len / 2), int((nxp_len - 1) / 2))) - - do i = 1, int(ny_len / 2) - do j = 1, int((nxp_len - 1) / 2) - dy_t(i, j) = dy(2 * i - 1, 2 * j) + dy(2 * i, 2 * j) - end do - end do - + ! Calculate T cell size based on dy + ! For each point, the T cell size is a sum of dy(2*i-1, 2*j) and dy(2*i, 2*j) ! Apply cutoff to depth based on the provided T-cell cutoff value in kilometers - do i = 1, int(ny_len / 2) - do j = 1, int((nxp_len - 1) / 2) - if (dy_t(i, j) < cutoff*1000.0_real64) then !Input cutoff in Kilometers covert it to meters - this%depth(i, j) = MISSING_VALUE ! Set values below cutoff to zero or another value as needed - end if - end do - end do + do i = 1, ny_len / 2 + do j = 1, (nxp_len - 1) / 2 + if (dy(2 * i - 1, 2 * j) + dy(2 * i, 2 * j) < cutoff*1000.0_real64) then !Input cutoff in Kilometers covert it to meters + this%depth(i, j) = MISSING_VALUE ! Set values below cutoff to zero or another value as needed + end if + end do + end do end subroutine topography_cut_off_T_cells From 51daab299228e58879a4755cf5aebe7715a2e0e9 Mon Sep 17 00:00:00 2001 From: ezhilsabareesh8 <108497463+ezhilsabareesh8@users.noreply.github.com> Date: Fri, 1 Nov 2024 16:24:11 +1100 Subject: [PATCH 07/25] Tidy up src/topogtools.f90 Co-authored-by: Andrew Kiss <31054815+aekiss@users.noreply.github.com> --- src/topogtools.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/topogtools.f90 b/src/topogtools.f90 index c5ecf7c..321eafd 100644 --- a/src/topogtools.f90 +++ b/src/topogtools.f90 @@ -236,7 +236,7 @@ program topogtools error stop end if topog = topography_t(file_in) - call topog%cut_off_T_cells(hgrid,cutoff) + call topog%cut_off_T_cells(hgrid, cutoff) call topog%update_history(get_mycommand()) call topog%write(file_out) From 3fcc49d4e915190351aa389de0af116e4d5101fc Mon Sep 17 00:00:00 2001 From: ezhilsabareesh8 <108497463+ezhilsabareesh8@users.noreply.github.com> Date: Fri, 1 Nov 2024 16:24:31 +1100 Subject: [PATCH 08/25] Tidy up src/topography.f90 Co-authored-by: Andrew Kiss <31054815+aekiss@users.noreply.github.com> --- src/topography.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/topography.f90 b/src/topography.f90 index 60271ba..562f573 100644 --- a/src/topography.f90 +++ b/src/topography.f90 @@ -471,7 +471,7 @@ subroutine topography_cut_off_T_cells(this, hgrid, cutoff) real(real64), intent(in) :: cutoff integer(int32) :: i, j - integer(int32) :: ncid_hgrid, dy_id ! NetCDF ids for hgrid + integer(int32) :: ncid_hgrid, dy_id ! NetCDF ids for hgrid and dy integer(int32) :: dids_dy(2) ! NetCDF ids for dimensions integer(int32) :: ny_len, nxp_len, nx_len ! dimensions for hgrid real(real64), allocatable :: dy(:,:) ! To store dy variable from hgrid From ce6d2ceb344f426062865139001305f3bf9d638d Mon Sep 17 00:00:00 2001 From: ezhilsabareesh8 <108497463+ezhilsabareesh8@users.noreply.github.com> Date: Tue, 5 Nov 2024 11:04:00 +1100 Subject: [PATCH 09/25] tidy up src/topogtools.f90 Co-authored-by: Andrew Kiss <31054815+aekiss@users.noreply.github.com> --- src/topogtools.f90 | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/topogtools.f90 b/src/topogtools.f90 index 321eafd..1c6ce92 100644 --- a/src/topogtools.f90 +++ b/src/topogtools.f90 @@ -115,9 +115,12 @@ program topogtools 'usage: topogtools cut_off_T_cells --input --output ', & ' --hgrid --cutoff ', & ' ', & - 'Cut off T cells with size smaller than . Writes the ', & - 'result to . ', & - 'Cut off should be in kilometers'] + 'Convert ocean cells into land if their y size is less than in ', & + 'kilometres. Writes the result to . ', & + ' ', & + 'Options ', & + ' --hgrid horizontal supergrid (default ''ocean_hgrid.nc'') ', & + ''] ! Read command line name = get_subcommand() From 5895de699ce720ee9723e16ebb2222f359757778 Mon Sep 17 00:00:00 2001 From: ezhilsabareesh8 <108497463+ezhilsabareesh8@users.noreply.github.com> Date: Tue, 5 Nov 2024 11:04:53 +1100 Subject: [PATCH 10/25] tidy up src/topogtools.f90 Co-authored-by: Andrew Kiss <31054815+aekiss@users.noreply.github.com> --- src/topogtools.f90 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/topogtools.f90 b/src/topogtools.f90 index 1c6ce92..c6e76bd 100644 --- a/src/topogtools.f90 +++ b/src/topogtools.f90 @@ -113,7 +113,8 @@ program topogtools help_cutoff = [character(len=80) :: & 'usage: topogtools cut_off_T_cells --input --output ', & - ' --hgrid --cutoff ', & + ' --cutoff ', & + ' [--hgrid ] ', & ' ', & 'Convert ocean cells into land if their y size is less than in ', & 'kilometres. Writes the result to . ', & From 85a795e1edefcb0aa9c14963a2c48ce488233562 Mon Sep 17 00:00:00 2001 From: ezhilsabareesh8 <108497463+ezhilsabareesh8@users.noreply.github.com> Date: Tue, 5 Nov 2024 11:05:24 +1100 Subject: [PATCH 11/25] change cut_off_T_cells to min_dy Co-authored-by: Andrew Kiss <31054815+aekiss@users.noreply.github.com> --- src/topogtools.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/topogtools.f90 b/src/topogtools.f90 index c6e76bd..9f7394b 100644 --- a/src/topogtools.f90 +++ b/src/topogtools.f90 @@ -34,7 +34,7 @@ program topogtools ' check_nonadvective - Check for non-advective cells ', & ' fix_nonadvective - Fix non-advective cells ', & ' mask - Generate mask ', & - ' cut_off_T_cells - Cut off T cells below a certain cell size ', & + ' min_dy - Set small ocean cells to land ', & ''] help_gen_topo = [character(len=80) :: & 'usage: topogtools gen_topo --input --output ', & From 4fa6969cf57349e8d30da71a2421c4285c7ae7d8 Mon Sep 17 00:00:00 2001 From: ezhilsabareesh8 <108497463+ezhilsabareesh8@users.noreply.github.com> Date: Tue, 5 Nov 2024 11:05:48 +1100 Subject: [PATCH 12/25] change cut_off_T_cells to min_dy Co-authored-by: Andrew Kiss <31054815+aekiss@users.noreply.github.com> --- src/topogtools.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/topogtools.f90 b/src/topogtools.f90 index 9f7394b..5c1494a 100644 --- a/src/topogtools.f90 +++ b/src/topogtools.f90 @@ -112,7 +112,7 @@ program topogtools ''] help_cutoff = [character(len=80) :: & - 'usage: topogtools cut_off_T_cells --input --output ', & + 'usage: topogtools min_dy --input --output ', & ' --cutoff ', & ' [--hgrid ] ', & ' ', & From 6c02b48c85fcd6ef37299c099a8e46bf5707e7c3 Mon Sep 17 00:00:00 2001 From: ezhilsabareesh8 Date: Tue, 5 Nov 2024 11:27:40 +1100 Subject: [PATCH 13/25] change cut_off_T_cells to min_dy --- README.md | 4 ++-- src/topography.f90 | 6 +++--- src/topogtools.f90 | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 71da438..79214cb 100644 --- a/README.md +++ b/README.md @@ -137,10 +137,10 @@ double-precision topography file. Options * `--vgrid ` vertical grid (default 'ocean_vgrid.nc') -## cut_off_T_cells +## min_dy ``` -usage: topogtools cut_off_T_cells --input --output --hgrid --cutoff +usage: topogtools min_dy --input --output --hgrid --cutoff ``` Cut off T cells with size smaller than . Cut off should be in kilometers diff --git a/src/topography.f90 b/src/topography.f90 index 562f573..e602787 100644 --- a/src/topography.f90 +++ b/src/topography.f90 @@ -35,7 +35,7 @@ module topography procedure :: nonadvective => topography_nonadvective procedure :: min_max_depth => topography_min_max_depth procedure :: mask => topography_mask - procedure :: cut_off_T_cells => topography_cut_off_T_cells + procedure :: min_dy => topography_min_dy end type topography_t interface topography_t @@ -465,7 +465,7 @@ subroutine topography_min_max_depth(this, vgrid_file, vgrid_type, level) end subroutine topography_min_max_depth - subroutine topography_cut_off_T_cells(this, hgrid, cutoff) + subroutine topography_min_dy(this, hgrid, cutoff) class(topography_t), intent(inout) :: this character(len=*), intent(in) :: hgrid real(real64), intent(in) :: cutoff @@ -502,7 +502,7 @@ subroutine topography_cut_off_T_cells(this, hgrid, cutoff) end do end do -end subroutine topography_cut_off_T_cells +end subroutine topography_min_dy !------------------------------------------------------------------------- subroutine topography_fill_fraction(this, sea_area_fraction) diff --git a/src/topogtools.f90 b/src/topogtools.f90 index 5c1494a..bb54131 100644 --- a/src/topogtools.f90 +++ b/src/topogtools.f90 @@ -144,7 +144,7 @@ program topogtools help_check_nonadvective, version_text) case ('mask') call set_args('--input:i "unset" --output:o "unset"', help_mask, version_text) - case ('cut_off_T_cells') + case ('min_dy') call set_args('--input:i "unset" --output:o "unset" --hgrid "ocean_hgrid.nc" --cutoff 0.0', help_cutoff, version_text) case ('') ! Print help in case the user specified the --help flag @@ -226,7 +226,7 @@ program topogtools topog = topography_t(file_in) call topog%mask(file_out) - case ('cut_off_T_cells') + case ('min_dy') hgrid = sget('hgrid') call check_file_exist(hgrid) cutoff = rget('cutoff') @@ -240,7 +240,7 @@ program topogtools error stop end if topog = topography_t(file_in) - call topog%cut_off_T_cells(hgrid, cutoff) + call topog%min_dy(hgrid, cutoff) call topog%update_history(get_mycommand()) call topog%write(file_out) From 61f9e7f6fb0aa5574ebef666c73722a31e502e99 Mon Sep 17 00:00:00 2001 From: ezhilsabareesh8 <108497463+ezhilsabareesh8@users.noreply.github.com> Date: Tue, 5 Nov 2024 11:30:35 +1100 Subject: [PATCH 14/25] Tidy up README.md Co-authored-by: Andrew Kiss <31054815+aekiss@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 79214cb..a3b568c 100644 --- a/README.md +++ b/README.md @@ -143,7 +143,7 @@ Options usage: topogtools min_dy --input --output --hgrid --cutoff ``` -Cut off T cells with size smaller than . Cut off should be in kilometers +Convert ocean cells into land if their y size is smaller than kilometres. # Building and Installation From 5ff9cfe3d6dbcc6a820f4dcb8f4f0823cf1b9885 Mon Sep 17 00:00:00 2001 From: ezhilsabareesh8 Date: Tue, 5 Nov 2024 11:56:50 +1100 Subject: [PATCH 15/25] Change cut_off value to meters --- README.md | 2 +- src/topography.f90 | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a3b568c..9796103 100644 --- a/README.md +++ b/README.md @@ -143,7 +143,7 @@ Options usage: topogtools min_dy --input --output --hgrid --cutoff ``` -Convert ocean cells into land if their y size is smaller than kilometres. +Convert ocean cells into land if their y size is smaller than metres. # Building and Installation diff --git a/src/topography.f90 b/src/topography.f90 index e602787..3dcf6f5 100644 --- a/src/topography.f90 +++ b/src/topography.f90 @@ -493,10 +493,10 @@ subroutine topography_min_dy(this, hgrid, cutoff) ! Calculate T cell size based on dy ! For each point, the T cell size is a sum of dy(2*i-1, 2*j) and dy(2*i, 2*j) - ! Apply cutoff to depth based on the provided T-cell cutoff value in kilometers + ! Apply cutoff to depth based on the provided T-cell cutoff value in meters do i = 1, ny_len / 2 do j = 1, (nxp_len - 1) / 2 - if (dy(2 * i - 1, 2 * j) + dy(2 * i, 2 * j) < cutoff*1000.0_real64) then !Input cutoff in Kilometers covert it to meters + if (dy(2 * i - 1, 2 * j) + dy(2 * i, 2 * j) < cutoff) then !Input cutoff in meters this%depth(i, j) = MISSING_VALUE ! Set values below cutoff to zero or another value as needed end if end do From a33cbb4045a0bc834070266a3f1f9d6c5ca926a6 Mon Sep 17 00:00:00 2001 From: ezhilsabareesh8 Date: Tue, 5 Nov 2024 13:39:59 +1100 Subject: [PATCH 16/25] Swap indicies --- src/topography.f90 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/topography.f90 b/src/topography.f90 index 3dcf6f5..76a08b6 100644 --- a/src/topography.f90 +++ b/src/topography.f90 @@ -485,7 +485,7 @@ subroutine topography_min_dy(this, hgrid, cutoff) call handle_error(nf90_inquire_dimension(ncid_hgrid, dids_dy(2), len=nxp_len)) ! Allocate memory for dy based on its dimensions - allocate(dy(ny_len, nxp_len)) + allocate(dy(nxp_len, ny_len)) ! Read the dy variable from hgrid call handle_error(nf90_get_var(ncid_hgrid, dy_id, dy)) @@ -494,8 +494,8 @@ subroutine topography_min_dy(this, hgrid, cutoff) ! Calculate T cell size based on dy ! For each point, the T cell size is a sum of dy(2*i-1, 2*j) and dy(2*i, 2*j) ! Apply cutoff to depth based on the provided T-cell cutoff value in meters - do i = 1, ny_len / 2 - do j = 1, (nxp_len - 1) / 2 + do j = 1, ny_len / 2 + do i = 1, (nxp_len - 1) / 2 if (dy(2 * i - 1, 2 * j) + dy(2 * i, 2 * j) < cutoff) then !Input cutoff in meters this%depth(i, j) = MISSING_VALUE ! Set values below cutoff to zero or another value as needed end if From 2833aeb03b4f1789e8a8d092ab7de4989e48cb58 Mon Sep 17 00:00:00 2001 From: ezhilsabareesh8 Date: Tue, 5 Nov 2024 14:25:11 +1100 Subject: [PATCH 17/25] Swap nx and ny at inquire dimension --- src/topography.f90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/topography.f90 b/src/topography.f90 index 76a08b6..82db473 100644 --- a/src/topography.f90 +++ b/src/topography.f90 @@ -481,8 +481,8 @@ subroutine topography_min_dy(this, hgrid, cutoff) call handle_error(nf90_open(trim(hgrid), nf90_nowrite, ncid_hgrid)) call handle_error(nf90_inq_varid(ncid_hgrid, 'dy', dy_id)) call handle_error(nf90_inquire_variable(ncid_hgrid, dy_id, dimids=dids_dy)) - call handle_error(nf90_inquire_dimension(ncid_hgrid, dids_dy(1), len=ny_len)) - call handle_error(nf90_inquire_dimension(ncid_hgrid, dids_dy(2), len=nxp_len)) + call handle_error(nf90_inquire_dimension(ncid_hgrid, dids_dy(1), len=nxp_len)) + call handle_error(nf90_inquire_dimension(ncid_hgrid, dids_dy(2), len=ny_len)) ! Allocate memory for dy based on its dimensions allocate(dy(nxp_len, ny_len)) From 57100e122e0b800bacabea5e8790bfbe503350f9 Mon Sep 17 00:00:00 2001 From: ezhilsabareesh8 Date: Tue, 5 Nov 2024 14:41:20 +1100 Subject: [PATCH 18/25] Add optional commands --- README.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 9796103..dbd106b 100644 --- a/README.md +++ b/README.md @@ -116,15 +116,10 @@ Options ``` usage: topogtools mask --input --output - [--fraction ] ``` Creates a land mask from a topography. -Options - * `--fraction ` cells with a fraction of sea area smaller than `` will be set as land (default '0.0') - - ## float_vgrid ``` @@ -145,6 +140,9 @@ usage: topogtools min_dy --input --output --hgrid metres. +Options + * `--hgrid ` vertical grid (default 'ocean_hgrid.nc') + # Building and Installation ## General Instructions From 34129c1d8d9f56d5e5b58b01b1b74d90137ed12e Mon Sep 17 00:00:00 2001 From: ezhilsabareesh8 <108497463+ezhilsabareesh8@users.noreply.github.com> Date: Thu, 7 Nov 2024 10:42:17 +1100 Subject: [PATCH 19/25] Tidy up README.md Co-authored-by: Andrew Kiss <31054815+aekiss@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index dbd106b..4cf1d6a 100644 --- a/README.md +++ b/README.md @@ -138,7 +138,7 @@ Options usage: topogtools min_dy --input --output --hgrid --cutoff ``` -Convert ocean cells into land if their y size is smaller than metres. +Convert ocean cells into land if their y size is smaller than ``, expressed in the same units as `dy` in `` (typically metres). Options * `--hgrid ` vertical grid (default 'ocean_hgrid.nc') From d0c399aeaca86c606826c3abd46de0fe5eec84d9 Mon Sep 17 00:00:00 2001 From: ezhilsabareesh8 <108497463+ezhilsabareesh8@users.noreply.github.com> Date: Thu, 7 Nov 2024 10:42:43 +1100 Subject: [PATCH 20/25] Tidy up README.md Co-authored-by: Andrew Kiss <31054815+aekiss@users.noreply.github.com> --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4cf1d6a..0d978c8 100644 --- a/README.md +++ b/README.md @@ -135,7 +135,8 @@ Options ## min_dy ``` -usage: topogtools min_dy --input --output --hgrid --cutoff +usage: topogtools min_dy --input --output --cutoff + [--hgrid ] ``` Convert ocean cells into land if their y size is smaller than ``, expressed in the same units as `dy` in `` (typically metres). From e1f8af8e92074946dfc2692b4bc4f7ecb8d9c9e1 Mon Sep 17 00:00:00 2001 From: ezhilsabareesh8 <108497463+ezhilsabareesh8@users.noreply.github.com> Date: Thu, 7 Nov 2024 10:43:11 +1100 Subject: [PATCH 21/25] Tidy up src/topogtools.f90 Co-authored-by: Andrew Kiss <31054815+aekiss@users.noreply.github.com> --- src/topogtools.f90 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/topogtools.f90 b/src/topogtools.f90 index bb54131..ee3fd19 100644 --- a/src/topogtools.f90 +++ b/src/topogtools.f90 @@ -116,8 +116,9 @@ program topogtools ' --cutoff ', & ' [--hgrid ] ', & ' ', & - 'Convert ocean cells into land if their y size is less than in ', & - 'kilometres. Writes the result to . ', & + 'Convert ocean cells into land if their y size is less than , ', & + 'expressed in the same units as dy in (typically metres). ', & + 'Writes the result to . ', & ' ', & 'Options ', & ' --hgrid horizontal supergrid (default ''ocean_hgrid.nc'') ', & From ee2737f2c1c2410b07534d8f0dca147a76fd9f9f Mon Sep 17 00:00:00 2001 From: ezhilsabareesh8 <108497463+ezhilsabareesh8@users.noreply.github.com> Date: Thu, 7 Nov 2024 10:43:56 +1100 Subject: [PATCH 22/25] Tidy up README.md Co-authored-by: Andrew Kiss <31054815+aekiss@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0d978c8..0ace1d4 100644 --- a/README.md +++ b/README.md @@ -142,7 +142,7 @@ usage: topogtools min_dy --input --output --cutoff `, expressed in the same units as `dy` in `` (typically metres). Options - * `--hgrid ` vertical grid (default 'ocean_hgrid.nc') + * `--hgrid ` horizontal supergrid file (default 'ocean_hgrid.nc') # Building and Installation From e369d0c1bd4f2456a775657c7f1d63f0df0cc16b Mon Sep 17 00:00:00 2001 From: ezhilsabareesh8 <108497463+ezhilsabareesh8@users.noreply.github.com> Date: Thu, 7 Nov 2024 10:45:25 +1100 Subject: [PATCH 23/25] Tidy up src/topography.f90 Co-authored-by: Andrew Kiss <31054815+aekiss@users.noreply.github.com> --- src/topography.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/topography.f90 b/src/topography.f90 index 82db473..a9c0835 100644 --- a/src/topography.f90 +++ b/src/topography.f90 @@ -493,7 +493,7 @@ subroutine topography_min_dy(this, hgrid, cutoff) ! Calculate T cell size based on dy ! For each point, the T cell size is a sum of dy(2*i-1, 2*j) and dy(2*i, 2*j) - ! Apply cutoff to depth based on the provided T-cell cutoff value in meters + ! Apply cutoff to depth based on the provided T-cell cutoff value do j = 1, ny_len / 2 do i = 1, (nxp_len - 1) / 2 if (dy(2 * i - 1, 2 * j) + dy(2 * i, 2 * j) < cutoff) then !Input cutoff in meters From f773227ab04b9c6d4afb8799fd990ab5ee7f6147 Mon Sep 17 00:00:00 2001 From: ezhilsabareesh8 <108497463+ezhilsabareesh8@users.noreply.github.com> Date: Thu, 7 Nov 2024 10:45:39 +1100 Subject: [PATCH 24/25] Tidy up src/topogtools.f90 Co-authored-by: Andrew Kiss <31054815+aekiss@users.noreply.github.com> --- src/topogtools.f90 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/topogtools.f90 b/src/topogtools.f90 index ee3fd19..92d24f7 100644 --- a/src/topogtools.f90 +++ b/src/topogtools.f90 @@ -112,9 +112,9 @@ program topogtools ''] help_cutoff = [character(len=80) :: & - 'usage: topogtools min_dy --input --output ', & - ' --cutoff ', & - ' [--hgrid ] ', & + 'usage: topogtools min_dy --input --output ', & + ' --cutoff ', & + ' [--hgrid ] ', & ' ', & 'Convert ocean cells into land if their y size is less than , ', & 'expressed in the same units as dy in (typically metres). ', & From 979afabeeee80a559b94fd7fc5bd6d09ebb15db1 Mon Sep 17 00:00:00 2001 From: ezhilsabareesh8 <108497463+ezhilsabareesh8@users.noreply.github.com> Date: Thu, 7 Nov 2024 10:45:57 +1100 Subject: [PATCH 25/25] Tidy up src/topography.f90 Co-authored-by: Andrew Kiss <31054815+aekiss@users.noreply.github.com> --- src/topography.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/topography.f90 b/src/topography.f90 index a9c0835..62af6e3 100644 --- a/src/topography.f90 +++ b/src/topography.f90 @@ -496,7 +496,7 @@ subroutine topography_min_dy(this, hgrid, cutoff) ! Apply cutoff to depth based on the provided T-cell cutoff value do j = 1, ny_len / 2 do i = 1, (nxp_len - 1) / 2 - if (dy(2 * i - 1, 2 * j) + dy(2 * i, 2 * j) < cutoff) then !Input cutoff in meters + if (dy(2 * i - 1, 2 * j) + dy(2 * i, 2 * j) < cutoff) then this%depth(i, j) = MISSING_VALUE ! Set values below cutoff to zero or another value as needed end if end do