diff --git a/Inst_eddies/Tests/examine_eddy.f90 b/Inst_eddies/Tests/examine_eddy.f90 index 501f704956b099bbd7bdc31a8ddce7843c7afc9f..c69e27d89989514ccf4f44157bdb99d14ed7520c 100644 --- a/Inst_eddies/Tests/examine_eddy.f90 +++ b/Inst_eddies/Tests/examine_eddy.f90 @@ -34,7 +34,7 @@ program examine_eddy use config_m, only: config use cont_list_m, only: create_cont_list, close_cont_list use derived_types, only: snapshot, shpc_slice_handler, eddy - use input_ssh_m, only: input_ssh, max_radius, corner + use input_ssh_m, only: input_ssh, max_radius, corner, nlon use read_eddy_m, only: read_eddy use shpc_create_m, only: shpc_create use set_all_extr_m, only: set_all_extr @@ -45,7 +45,7 @@ program examine_eddy implicit none integer:: date = huge(0), eddy_i_target = huge(0) - integer ishape_first, d0, ishape, i, l, n1, n2, number_extr, unit, nlon + integer ishape_first, d0, ishape, i, l, n1, n2, number_extr, unit logical:: cyclone = .true. ! orientation of target eddy namelist /main_nml/ cyclone, date, eddy_i_target TYPE(shpfileobject) hshp @@ -148,8 +148,6 @@ program examine_eddy ! Done defining geographical window - if (periodic) nlon = size(ssh, 1) - 2 * max_radius(1) - do i = 1, number_extr if (i /= eddy_i_target) then ! Shift the longitude to a value close to the longitude of the diff --git a/Inst_eddies/Tests/test_mean_speed.f90 b/Inst_eddies/Tests/test_mean_speed.f90 index 3bd133ba358a80b0d561954d66c854d27310102d..70983b794bc946c749ca129b347755a9b40f412a 100644 --- a/Inst_eddies/Tests/test_mean_speed.f90 +++ b/Inst_eddies/Tests/test_mean_speed.f90 @@ -8,7 +8,7 @@ program test_mean_speed use shapelib_03, only: shp_open_03 use config_m, only: config - use input_ssh_m, only: input_ssh, corner, max_radius + use input_ssh_m, only: input_ssh, corner, nlon use mean_speed_m, only: mean_speed implicit none @@ -54,8 +54,7 @@ program test_mean_speed ! Check that extremum is in polyline and grid: - lon_max = corner(1) + (size(ssh, 1) - 2 * merge(max_radius(1), 0, periodic) & - - 1) * step(1) + lon_max = corner(1) + (nlon - 1) * step(1) if (corner(1) > center(1) .or. center(1) > lon_max & .or. minval(p%part(1)%points(1, :)) > center(1) & diff --git a/Inst_eddies/Tests/test_set_max_speed.f90 b/Inst_eddies/Tests/test_set_max_speed.f90 index 7873ab0c80b9cc9e9fcf651547a75e47bb8bbdd8..72b8f600aef374ef74abfb4bef825eb7eb830954 100644 --- a/Inst_eddies/Tests/test_set_max_speed.f90 +++ b/Inst_eddies/Tests/test_set_max_speed.f90 @@ -15,7 +15,7 @@ program test_set_max_speed use config_m, only: config use cont_list_m, only: create_cont_list, close_cont_list use derived_types, only: eddy, shpc_slice_handler, ssh_contour - use input_ssh_m, only: input_ssh, corner + use input_ssh_m, only: input_ssh, corner, nlon, nlat use read_eddy_m, only: read_eddy use set_max_speed_m, only: set_max_speed use shpc_close_m, only: shpc_close @@ -27,7 +27,7 @@ program test_set_max_speed logical cyclone logical periodic ! grid is periodic in longitude - integer nlon, nlat, d, eddy_index, n_cont, i, ishape + integer d, eddy_index, n_cont, i, ishape real, allocatable:: ssh(:, :) ! (nlon, nlat) sea-surface height, in m real, allocatable:: u(:, :), v(:, :) ! (nlon, nlat) wind, in m s-1 type(eddy) e @@ -73,8 +73,6 @@ program test_set_max_speed call shpc_open(hshpc, path, cyclone, slice = 0, pszaccess = "rb") call read_eddy(e, d, eddy_index, hshpc, ishape = 0) CALL shpc_close(hshpc) - if (.not. periodic) nlon = size(ssh, 1) - nlat = size(ssh, 2) if (e%out_cont%closed) then e%extr%coord_proj = nint((e%extr%coord - corner) / step) + 1 diff --git a/Inst_eddies/input_ssh.f90 b/Inst_eddies/input_ssh.f90 index e1c04196bc188ef7dcc61f820ac124c9443d2eeb..78c3930f6ba0b5def6f96dea6ac66a86e59d71e8 100644 --- a/Inst_eddies/input_ssh.f90 +++ b/Inst_eddies/input_ssh.f90 @@ -5,6 +5,10 @@ module input_ssh_m real, protected:: corner(2) = huge(0.) ! longitude and latitude of the corner of the whole grid, in rad + integer, protected:: nlon = - huge(0), nlat = - huge(0) + ! size of ssh array in input NetCDF, assuming no repeated point if + ! the grid is global + integer, protected:: max_radius(2) = - huge(0) ! maximum radius of an eddy in longitude and latitude, in number of ! grid points @@ -36,10 +40,6 @@ contains ! Local: - integer nlon, nlat - ! size of ssh array in input NetCDF, assuming no repeated point if - ! the grid is global - logical exist integer unit integer ncid, dimid, varid @@ -66,8 +66,6 @@ contains if (exist) then print *, "input_ssh: Found SHPC/grid_nml.txt" - nlon = - huge(0) - nlat = - huge(0) open(unit, file = "SHPC/grid_nml.txt", status = "old", action = "read", & position = "rewind") read(unit, nml = grid_nml) @@ -136,7 +134,7 @@ contains ! Read ssh, u and v: - call get_var(periodic, max_radius(1), ssh, ncid, nlon, name = "adt", & + call get_var(periodic, max_radius(1), ssh, ncid, name = "adt", & new_fill_value = huge(0.)) ! (We cannot keep the original fill value because Contour_531 ! works with an upper limit for valid values.) @@ -144,9 +142,9 @@ contains call get_command_arg_dyn(2, fname, "Required arguments: h-file uv-file") call nf95_open(fname, nf95_nowrite, ncid) - call get_var(periodic, max_radius(1), u, ncid, nlon, name = "ugos", & + call get_var(periodic, max_radius(1), u, ncid, name = "ugos", & new_fill_value = ieee_value(0., IEEE_QUIET_NAN)) - call get_var(periodic, max_radius(1), v, ncid, nlon, name = "vgos", & + call get_var(periodic, max_radius(1), v, ncid, name = "vgos", & new_fill_value = ieee_value(0., IEEE_QUIET_NAN)) ! (We will need quiet NaNs rather the original fill values for u and ! v when we compute the max-speed contours and when we search the @@ -157,8 +155,7 @@ contains !********************************************************************* - subroutine get_var(periodic, max_rad_lon, values, ncid, nlon, name, & - new_fill_value) + subroutine get_var(periodic, max_rad_lon, values, ncid, name, new_fill_value) ! Read a NetCDF variable, change the missing value and extend it ! in longitude if periodic. @@ -177,7 +174,7 @@ contains ! first because the declaration references max_rad_lon and ! periodic. - integer, intent(in):: ncid, nlon + integer, intent(in):: ncid character(len = *), intent(in):: name ! of NetCDF variable real, intent(in):: new_fill_value diff --git a/Inst_eddies/inst_eddies.f90 b/Inst_eddies/inst_eddies.f90 index cb146bee0b5670ac72cde78b11ee8feed2ece379..d9e77c5b8b8bdc6601b60a92dbd7549db2a632a3 100644 --- a/Inst_eddies/inst_eddies.f90 +++ b/Inst_eddies/inst_eddies.f90 @@ -12,7 +12,7 @@ program inst_eddies use config_m, only: config use derived_types, only: snapshot, shpc_slice_handler - use input_ssh_m, only: input_ssh, max_radius + use input_ssh_m, only: input_ssh, max_radius, nlon, nlat use nearby_extr_m, only: nearby_extr use set_all_extr_m, only: set_all_extr use set_contours_m, only: set_contours @@ -25,7 +25,7 @@ program inst_eddies type(snapshot) s TYPE(shpc_slice_handler) hshpc_cyclo, hshpc_anti - integer iostat, i, l, nlon, nlat + integer iostat, i, l character(len = 200) iomsg integer unit @@ -133,9 +133,6 @@ program inst_eddies ! Done sorting - nlon = size(ssh, 1) - 2 * merge(max_radius(1), 0, periodic) - nlat = size(ssh, 2) - do l = 1, s%number_extr i = sorted_extr(l) diff --git a/Inst_eddies/set_all_extr.f90 b/Inst_eddies/set_all_extr.f90 index da24842593fb0fa9265814f4a519db36c82e72f3..4aed8d4852a0d8121663148ac558aae32c5a638e 100644 --- a/Inst_eddies/set_all_extr.f90 +++ b/Inst_eddies/set_all_extr.f90 @@ -12,7 +12,7 @@ contains ! the defined components of "s" because of allocations. use derived_types, only: snapshot - use input_ssh_m, only: max_radius, corner + use input_ssh_m, only: max_radius, corner, nlon, nlat use local_extrema_m, only: local_extrema type(snapshot), intent(out):: s @@ -28,7 +28,6 @@ contains ! Local: - integer nlon, nlat logical, allocatable:: cyclone(:) ! (s%number_extr) integer i, copy @@ -44,8 +43,6 @@ contains !-------------------------------------------------------------- copy = merge(max_radius(1), 0, periodic) - nlon = size(ssh, 1) - 2 * copy - nlat = size(ssh, 2) allocate(s%extr_map(1 - copy:nlon + copy, nlat)) copy = merge(1, 0, periodic) call local_extrema(s%extr_map(1 - copy:nlon + copy, :), ind_extr, &