From 70fbeb95aa1b789942964763630fa5681a1ebe50 Mon Sep 17 00:00:00 2001 From: Lionel GUEZ <guez@lmd.ens.fr> Date: Mon, 22 Jul 2024 14:43:40 +0200 Subject: [PATCH] Do not use type snapshot in program `inst_eddies` This was not useful since we do not need an array of snapshots in `inst_eddies`. It is clearer without the integration in a snapshot variable. The integration in a snapshot variable came from initial commit, when there was only one program for detection of instantaneous eddies and overlapping. --- Inst_eddies/inst_eddies.f90 | 55 +++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/Inst_eddies/inst_eddies.f90 b/Inst_eddies/inst_eddies.f90 index b3df3a15..5b970538 100644 --- a/Inst_eddies/inst_eddies.f90 +++ b/Inst_eddies/inst_eddies.f90 @@ -11,7 +11,7 @@ program inst_eddies use numer_rec_95, only: indexx use config_m, only: config, max_radius - use derived_types, only: snapshot, shpc_slice_handler + use derived_types, only: eddy, shpc_slice_handler use input_ssh_m, only: input_ssh, nlon, nlat use nearby_extr_m, only: nearby_extr use set_all_extr_m, only: set_all_extr @@ -23,7 +23,20 @@ program inst_eddies implicit none - type(snapshot) s + type(eddy), allocatable:: 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. + + integer number_extr ! number of extrema + + integer, allocatable:: 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(shpc_slice_handler) hshpc_cyclo, hshpc_anti integer iostat, i, l character(len = 200) iomsg @@ -46,7 +59,7 @@ program inst_eddies integer:: date = 0, slice = 0 namelist /dates_nml/ date, slice - integer, allocatable:: sorted_extr(:) ! (s%number_extr) + integer, allocatable:: sorted_extr(:) ! (number_extr) ! Sorted identifying number of extrema: first, minima sorted in ! order of decreasing SSH, and second, maxima sorted in order of ! increasing SSH. @@ -112,35 +125,35 @@ program inst_eddies write(unit, fmt = *) "CPU time for preamble, before computation:", t1 - t0, & "s" t0 = t1 - call set_all_extr(s%extr_map, s%list, step, periodic, ssh) - s%number_extr = size(s%list) - allocate(sorted_extr(s%number_extr)) + call set_all_extr(extr_map, list, step, periodic, ssh) + number_extr = size(list) + allocate(sorted_extr(number_extr)) - forall (i = 1:s%number_extr) - s%list(i)%out_cont%closed = .true. + forall (i = 1:number_extr) + list(i)%out_cont%closed = .true. ! must be intialized to true because it is used in nearby_extr end forall ! Double sort of extrema on cyclonicity and SSH value: - selection = argwhere(s%list%cyclone) + selection = argwhere(list%cyclone) n_cycl = size(selection) - selection = selection(indexx(s%list(selection)%extr%ssh)) + selection = selection(indexx(list(selection)%extr%ssh)) sorted_extr(:n_cycl) = selection(n_cycl:1:- 1) ! descending order of ssh - selection = argwhere(.not. s%list%cyclone) - selection = selection(indexx(s%list(selection)%extr%ssh)) + selection = argwhere(.not. list%cyclone) + selection = selection(indexx(list(selection)%extr%ssh)) sorted_extr(n_cycl + 1:) = selection ! Done sorting - do l = 1, s%number_extr + do l = 1, number_extr i = sorted_extr(l) ! Define the geographical window around each eddy extremum: - llc = s%list(i)%extr%coord_proj - max_radius - urc = s%list(i)%extr%coord_proj + max_radius + llc = list(i)%extr%coord_proj - max_radius + urc = list(i)%extr%coord_proj + max_radius llc(2) = max(llc(2), 1) urc(2) = min(urc(2), nlat) @@ -153,16 +166,16 @@ program inst_eddies ! Done defining geographical window outside_points & - = nearby_extr(s%extr_map(llc(1):urc(1), llc(2):urc(2)), s%list, i) + = nearby_extr(extr_map(llc(1):urc(1), llc(2):urc(2)), list, i) ! Shift the x coordinate of each point to a value close to the ! coordinate of the target extremum: if (periodic) outside_points(1, :) = outside_points(1, :) & + ceiling((llc(1) - outside_points(1, :)) / real(nlon)) * nlon - call set_contours(s%list(i)%out_cont, s%list(i)%speed_cont, & - s%list(i)%max_speed, s%list(i)%cyclone, s%list(i)%extr, & - s%list(i)%innermost_level, step, ssh(llc(1):urc(1), llc(2):urc(2)), & + call set_contours(list(i)%out_cont, list(i)%speed_cont, & + list(i)%max_speed, list(i)%cyclone, list(i)%extr, & + list(i)%innermost_level, step, ssh(llc(1):urc(1), llc(2):urc(2)), & u(llc(1):urc(1), llc(2):urc(2)), v(llc(1):urc(1), llc(2):urc(2)), & llc, outside_points) end do @@ -170,8 +183,8 @@ program inst_eddies call cpu_time(t1) write(unit, fmt = *) "CPU time for computation, before output:", t1 - t0, "s" t0 = t1 - print *, "inst_eddies: s%number_extr = ", s%number_extr - call write_snapshot(s%list, hshpc_cyclo, hshpc_anti, date) + print *, "inst_eddies: number_extr = ", number_extr + call write_snapshot(list, hshpc_cyclo, hshpc_anti, date) CALL shpc_close(hshpc_cyclo) CALL shpc_close(hshpc_anti) -- GitLab