Skip to content
Snippets Groups Projects
Commit 9139054d authored by Lionel GUEZ's avatar Lionel GUEZ
Browse files

Replace argument `s` of `set_all_extr`

Replace argument `s` of `set_all_extr` by its components. The idea is
to remove the structure `snapshot` from program `inst_edddies`.
parent 5b62797c
No related branches found
No related tags found
No related merge requests found
......@@ -163,7 +163,8 @@ program examine_eddy
end do
n2 = count(in_window)
call set_all_extr(s, step, periodic, ssh)
call set_all_extr(s%extr_map, s%list, step, periodic, ssh)
s%number_extr = size(s%list)
selection = pack(s%extr_map(llc(1):urc(1), llc(2):urc(2)), &
s%extr_map(llc(1):urc(1), llc(2):urc(2)) /= 0)
selection = pack(selection, s%list(selection)%cyclone .neqv. cyclone)
......
......@@ -112,7 +112,8 @@ program inst_eddies
write(unit, fmt = *) "CPU time for preamble, before computation:", t1 - t0, &
"s"
t0 = t1
call set_all_extr(s, step, periodic, ssh)
call set_all_extr(s%extr_map, s%list, step, periodic, ssh)
s%number_extr = size(s%list)
allocate(sorted_extr(s%number_extr))
forall (i = 1:s%number_extr)
......
......@@ -4,21 +4,29 @@ module set_all_extr_m
contains
subroutine set_all_extr(s, step, periodic, ssh)
subroutine set_all_extr(extr_map, list, step, periodic, ssh)
! This procedures finds all the extrema of ssh. It is not a
! function because "s" is not completely defined. It would be
! difficult to replace argument "s" by arguments corresponding to
! the defined components of "s" because of allocations.
! This procedure finds all the extrema of ssh.
use config_m, only: max_radius
use derived_types, only: snapshot
use derived_types, only: eddy
use input_ssh_m, only: corner, nlon, nlat
use local_extrema_m, only: local_extrema
type(snapshot), intent(out):: s
! Define only s%extr_map, s%list%extr, s%number_extr,
! s%list%cyclone, s%list%innermost_level.
integer, allocatable, intent(out):: extr_map(:, :)
! (1 - max_radius(1):nlon + max_radius(1), nlat) if the grid is
! periodic in longitude, else (nlon, nlat). At a point of extremum
! SSH: identification number or this extremum. 0 at other points.
type(eddy), allocatable, intent(out):: list(:) ! (number_extr)
! "Eddies" at a given date. In general, there may be both cyclonic
! and anticyclonic eddies in the list. Eddies include "eddies"
! without an outermost contour, that is, only the extremum is
! defined. The subscript value in list is the "identification
! number" of the extremum. Define only list%extr, list%cyclone,
! list%innermost_level. It would be difficult to replace argument
! "list" by arguments corresponding to the defined components of
! "list" because of allocations.
real, intent(in):: step(:) ! (2) longitude and latitude steps, in rad
logical, intent(in):: periodic ! grid is periodic in longitude
......@@ -29,14 +37,14 @@ contains
! Local:
logical, allocatable:: cyclone(:) ! (s%number_extr)
integer i, copy
logical, allocatable:: cyclone(:) ! (number_extr)
integer i, copy, number_extr
integer, allocatable:: ind_extr(:, :) ! (2, n_extr)
! List of couple of subscripts of extrema of ssh, in the two
! dimensions.
real, allocatable:: innermost_level(:) ! (s%number_extr)
real, allocatable:: innermost_level(:) ! (number_extr)
! SSH level of the innermost contour around each extremum, in
! m. By construction, innermost_level < extremum for a maximum, >
! extremum for a minimum.
......@@ -44,9 +52,9 @@ contains
!--------------------------------------------------------------
copy = merge(max_radius(1), 0, periodic)
allocate(s%extr_map(1 - copy:nlon + copy, nlat))
allocate(extr_map(1 - copy:nlon + copy, nlat))
copy = merge(1, 0, periodic)
call local_extrema(s%extr_map(1 - copy:nlon + copy, :), ind_extr, &
call local_extrema(extr_map(1 - copy:nlon + copy, :), ind_extr, &
innermost_level, cyclone, ssh(1 - copy:nlon + copy, :), periodic, &
my_lbound = [1 - copy, 1])
! Assertion: \forall k, ind_extr(1, k) \in \{2 - copy, \dots,
......@@ -57,24 +65,23 @@ contains
if (periodic) then
! Extend in longitude:
s%extr_map(1 - max_radius(1):- 1, :) &
= s%extr_map(nlon + 1 - max_radius(1):nlon - 1, :)
s%extr_map(nlon + 2:nlon + max_radius(1), :) &
= s%extr_map(2:max_radius(1), :)
extr_map(1 - max_radius(1):- 1, :) &
= extr_map(nlon + 1 - max_radius(1):nlon - 1, :)
extr_map(nlon + 2:nlon + max_radius(1), :) = extr_map(2:max_radius(1), :)
end if
s%number_extr = size(ind_extr, 2)
allocate(s%list(s%number_extr))
s%list%innermost_level = innermost_level
number_extr = size(ind_extr, 2)
allocate(list(number_extr))
list%innermost_level = innermost_level
forall (i = 1:s%number_extr)
s%list(i)%extr%coord = corner + (ind_extr(:, i) - 1) * step
forall (i = 1:number_extr)
list(i)%extr%coord = corner + (ind_extr(:, i) - 1) * step
! (Even when periodic, this is within the original NetCDF grid,
! that is the grid without duplicated longitudes.)
s%list(i)%extr%coord_proj = ind_extr(:, i)
s%list(i)%extr%ssh = ssh(ind_extr(1, i), ind_extr(2, i))
s%list(i)%cyclone = cyclone(i)
list(i)%extr%coord_proj = ind_extr(:, i)
list(i)%extr%ssh = ssh(ind_extr(1, i), ind_extr(2, i))
list(i)%cyclone = cyclone(i)
end forall
end subroutine set_all_extr
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment