From a8b790ef23396a816cba769b0131607a05695eed Mon Sep 17 00:00:00 2001 From: netosylvio Date: Tue, 28 Jul 2026 19:30:41 +0000 Subject: [PATCH 1/2] bug fix init ugwp --- .../mpas_gsl_oro_data_sm_scale.F | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/core_init_atmosphere/mpas_gsl_oro_data_sm_scale.F b/src/core_init_atmosphere/mpas_gsl_oro_data_sm_scale.F index de5802ec9..7dfc03b08 100644 --- a/src/core_init_atmosphere/mpas_gsl_oro_data_sm_scale.F +++ b/src/core_init_atmosphere/mpas_gsl_oro_data_sm_scale.F @@ -711,17 +711,19 @@ function nearest_j_south(lat_in) integer :: j lat = lat_in -if ( abs(lat_in).gt.p5*Pi ) then - nearest_j_south = -999 -elseif ( lat_in.le.lat1d_fine(1) ) then - nearest_j_south = 1 -else - j = 2 - do while ( (lat1d_fine(j).le.lat).and.(j.le.topo_y) ) - j = j + 1 - end do - nearest_j_south = j - 1 -end if + if ( abs(lat_in).gt.p5*Pi ) then + nearest_j_south = -999 + elseif ( lat.le.lat1d_fine(1) ) then + nearest_j_south = 1 + elseif ( lat.ge.lat1d_fine(topo_y) ) then + ! Usa os dois últimos pontos para extrapolar no polo Norte + nearest_j_south = topo_y - 1 + else + do j = 2, topo_y + if (lat1d_fine(j).gt.lat) exit + end do + nearest_j_south = j - 1 + end if end function nearest_j_south From f1f281b3bf0699ce2d38e985b42390dd70e0b839 Mon Sep 17 00:00:00 2001 From: netosylvio Date: Wed, 29 Jul 2026 00:17:22 +0000 Subject: [PATCH 2/2] bug fix 2 init ugwp --- .../mpas_gsl_oro_data_sm_scale.F | 34 ++++++++++++------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/src/core_init_atmosphere/mpas_gsl_oro_data_sm_scale.F b/src/core_init_atmosphere/mpas_gsl_oro_data_sm_scale.F index 7dfc03b08..19c938b36 100644 --- a/src/core_init_atmosphere/mpas_gsl_oro_data_sm_scale.F +++ b/src/core_init_atmosphere/mpas_gsl_oro_data_sm_scale.F @@ -711,19 +711,27 @@ function nearest_j_south(lat_in) integer :: j lat = lat_in - if ( abs(lat_in).gt.p5*Pi ) then - nearest_j_south = -999 - elseif ( lat.le.lat1d_fine(1) ) then - nearest_j_south = 1 - elseif ( lat.ge.lat1d_fine(topo_y) ) then - ! Usa os dois últimos pontos para extrapolar no polo Norte - nearest_j_south = topo_y - 1 - else - do j = 2, topo_y - if (lat1d_fine(j).gt.lat) exit - end do - nearest_j_south = j - 1 - end if + +if (abs(lat_in).gt.p5*Pi) then + nearest_j_south = -999 + +elseif (lat.le.lat1d_fine(1)) then + nearest_j_south = 1 + +else + j = 2 + + do while (j.le.topo_y) + if (lat1d_fine(j).gt.lat) then + nearest_j_south = j - 1 + return + end if + j = j + 1 + end do + + ! Latitude ao norte do último ponto da grade fina + nearest_j_south = topo_y +end if end function nearest_j_south