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..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,16 +711,26 @@ function nearest_j_south(lat_in) integer :: j lat = lat_in -if ( abs(lat_in).gt.p5*Pi ) then + +if (abs(lat_in).gt.p5*Pi) then nearest_j_south = -999 -elseif ( lat_in.le.lat1d_fine(1) ) then + +elseif (lat.le.lat1d_fine(1)) then nearest_j_south = 1 + else j = 2 - do while ( (lat1d_fine(j).le.lat).and.(j.le.topo_y) ) + + 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 - nearest_j_south = j - 1 + + ! Latitude ao norte do último ponto da grade fina + nearest_j_south = topo_y end if end function nearest_j_south