diff --git a/Common/derived_types.f90 b/Common/derived_types.f90 index bf15e871e232276a31943ca9dfafe702395686fc..478754155919a15072ded7240c7a4a8cbfee6c4c 100644 --- a/Common/derived_types.f90 +++ b/Common/derived_types.f90 @@ -70,10 +70,11 @@ module derived_types TYPE(shpfileobject) extremum ! shapefile extremum TYPE(shpfileobject) outermost ! shapefile outermost_contour TYPE(shpfileobject) max_speed ! shapefile max_speed_contour - + logical cyclone + ! Field identifiers: - integer extr_ssh, extr_date, extr_eddy_index, extr_interp, extr_cycl, & - extr_valid, extr_speed + integer extr_ssh, extr_date, extr_eddy_index, extr_interp, extr_valid, & + extr_speed integer out_r_eq_area, out_ssh, out_date, out_eddy_index, out_radius4 integer max_speed_r_eq_area, max_speed_ssh, max_speed_date, & max_speed_eddy_index diff --git a/Common/read_eddy.f90 b/Common/read_eddy.f90 index 3bb7486c30e1f75316920d489ed3a95307697773..3636367b24336571ca0ba68509315afcad7280b7 100644 --- a/Common/read_eddy.f90 +++ b/Common/read_eddy.f90 @@ -44,9 +44,7 @@ contains ishape) e%interpolated = int_attr == 1 - call dbf_read_attribute_03(int_attr, hshp%extremum, hshp%extr_cycl, & - ishape) - e%cyclone = int_attr == 1 + e%cyclone = hshp%cyclone call dbf_read_attribute_03(int_attr, hshp%extremum, hshp%extr_valid, & ishape) diff --git a/Common/read_field_indices.f90 b/Common/read_field_indices.f90 index 3ff2a9f13579be245f225c70f61dbf1dce83ce7b..5e12fc4b000838f2b60e0b76486958ad462f49a8 100644 --- a/Common/read_field_indices.f90 +++ b/Common/read_field_indices.f90 @@ -25,7 +25,6 @@ contains hshp%extr_eddy_index) call dbf_get_field_index_03(hshp%extremum, "interpolat", & hshp%extr_interp) - call dbf_get_field_index_03(hshp%extremum, "cyclone", hshp%extr_cycl) call dbf_get_field_index_03(hshp%extremum, "valid", hshp%extr_valid) call dbf_get_field_index_03(hshp%extremum, "speed", hshp%extr_speed) @@ -44,7 +43,6 @@ contains call ezmpi_bcast(hshp%extr_date, root = 0) call ezmpi_bcast(hshp%extr_eddy_index, root = 0) call ezmpi_bcast(hshp%extr_interp, root = 0) - call ezmpi_bcast(hshp%extr_cycl, root = 0) call ezmpi_bcast(hshp%extr_valid, root = 0) call ezmpi_bcast(hshp%extr_speed, root = 0) call ezmpi_bcast(hshp%out_r_eq_area, root = 0) diff --git a/Common/shpc_create.f90 b/Common/shpc_create.f90 index 0967bef51dd745dfa85dca3d5fc6883d5882faa9..094f68dbcce21248869149f5ff06d9b5b0917f35 100644 --- a/Common/shpc_create.f90 +++ b/Common/shpc_create.f90 @@ -4,9 +4,10 @@ module shpc_create_m contains - subroutine shpc_create(hshp, shpc_dir) + subroutine shpc_create(hshp, shpc_dir, cyclone) ! Libraries: + use jumble, only: new_unit use shapelib, only: shpt_point, shpt_polygon, ftdouble, ftinteger use shapelib_03, only: shp_create_03, dbf_add_field_03 @@ -14,6 +15,10 @@ contains TYPE(shpc), intent(out):: hshp character(len = *), intent(in):: shpc_dir + logical, intent(in):: cyclone + + ! Local: + integer unit !--------------------------------------------------------------------- @@ -27,8 +32,6 @@ contains ftinteger, nwidth = 5, ndecimals = 0) call dbf_add_field_03(hshp%extr_interp, hshp%extremum, 'interpolat', & ftinteger, nwidth = 1, ndecimals = 0) - call dbf_add_field_03(hshp%extr_cycl, hshp%extremum, 'cyclone', & - ftinteger, nwidth = 1, ndecimals = 0) call dbf_add_field_03(hshp%extr_valid, hshp%extremum, 'valid', & ftinteger, nwidth = 1, ndecimals = 0) call dbf_add_field_03(hshp%extr_speed, hshp%extremum, 'speed', ftdouble, & @@ -58,6 +61,19 @@ contains call dbf_add_field_03(hshp%max_speed_eddy_index, hshp%max_speed, & 'eddy_index', ftinteger, nwidth = 5, ndecimals = 0) + hshp%cyclone = cyclone + call new_unit(unit) + open(unit, file = shpc_dir // "/orientation.txt", status = "replace", & + action = "write") + + if (cyclone) then + write(unit, fmt = *) "cyclones" + else + write(unit, fmt = *) "anticyclones" + end if + + close(unit) + end subroutine shpc_create end module shpc_create_m diff --git a/Common/shpc_open.f90 b/Common/shpc_open.f90 index a0e5af20d90ed1ecbf551b78a2d644138b9c7d93..7639b1f08bb82edae7b1b5e75e7fe914a7f49173 100644 --- a/Common/shpc_open.f90 +++ b/Common/shpc_open.f90 @@ -7,6 +7,8 @@ contains subroutine shpc_open(hshp, shpc_dir, rank) ! Libraries: + use ezmpi, only: ezmpi_bcast + USE jumble, only: new_unit use shapelib_03, only: shp_open_03 use derived_types, only: shpc @@ -16,6 +18,10 @@ contains character(len = *), intent(in):: shpc_dir integer, intent(in):: rank + ! Local: + integer unit + character(len = 12) orientation + !-------------------------------------------------------------------- call shp_open_03(hshp%extremum, shpc_dir // "/extremum", & @@ -26,6 +32,17 @@ contains pszaccess = "rb") call read_field_indices(hshp, rank) + if (rank == 0) then + call new_unit(unit) + open(unit, file = shpc_dir // "/orientation.txt", status = "old", & + action = "read", position = "rewind") + read(unit, fmt = *) orientation + close(unit) + hshp%cyclone = trim(adjustl(orientation)) == "cyclones" + end if + + call ezmpi_bcast(hshp%cyclone, root = 0) + end subroutine shpc_open end module shpc_open_m diff --git a/Common/write_eddy.f90 b/Common/write_eddy.f90 index 841fc8d90b1cf406cad4e225590e740cd0a15bd1..a730a1be6c630ed863b79818bc9c5015fb6b1c2c 100644 --- a/Common/write_eddy.f90 +++ b/Common/write_eddy.f90 @@ -9,7 +9,7 @@ contains use, intrinsic:: ieee_arithmetic, only: ieee_is_nan ! Libraries: - use nr_util, only: pi, rad_to_deg + use nr_util, only: pi, rad_to_deg, assert use shapelib, only: shpt_polygon use shapelib_03, only: shp_append_point_03, dbf_write_attribute_03, & shp_append_object_03, shp_append_null_03 @@ -26,6 +26,8 @@ contains !------------------------------------------------------------- + call assert(hshp%cyclone .eqv. e%cyclone, & + "write_eddy: orientation mismatch") call shp_append_point_03(ishape, hshp%extremum, e%coord_extr * rad_to_deg) call dbf_write_attribute_03(hshp%extremum, ishape, hshp%extr_ssh, & @@ -35,8 +37,6 @@ contains call dbf_write_attribute_03(hshp%extremum, ishape, hshp%extr_eddy_index, i) call dbf_write_attribute_03(hshp%extremum, ishape, hshp%extr_interp, & merge(1, 0, e%interpolated)) - call dbf_write_attribute_03(hshp%extremum, ishape, hshp%extr_cycl, & - merge(1, 0, e%cyclone)) call dbf_write_attribute_03(hshp%extremum, ishape, hshp%extr_valid, & merge(1, 0, e%valid)) diff --git a/Inst_eddies/Tests/test_get_1_outerm.f90 b/Inst_eddies/Tests/test_get_1_outerm.f90 index 18ac59bb2069debdc51625e6ecf576d6693def12..ad696689c8f810275a1b3a135edec8d7fc1e076b 100644 --- a/Inst_eddies/Tests/test_get_1_outerm.f90 +++ b/Inst_eddies/Tests/test_get_1_outerm.f90 @@ -110,7 +110,7 @@ program test_get_1_outerm e%radius4 = - 1 e%valid = .true. e%interpolated = .false. - call shpc_create(hshp, shpc_dir = "SHPC") + call shpc_create(hshp, shpc_dir = "SHPC", cyclone = cyclone) call write_eddy(e, hshp, days_1950, i = 1) CALL shpc_close(hshp) print *, 'Created "SHPC".' diff --git a/Inst_eddies/Tests/test_set_all_outerm.f90 b/Inst_eddies/Tests/test_set_all_outerm.f90 index 2aab08d802dcb811720b9938317f861727bf9228..970c2b598d27913fe67a6ab179d357359c6616de 100644 --- a/Inst_eddies/Tests/test_set_all_outerm.f90 +++ b/Inst_eddies/Tests/test_set_all_outerm.f90 @@ -88,8 +88,8 @@ program test_set_all_outerm s%list_vis(i)%radius4 = 0 end do - call shpc_create(hshp_cyclo, shpc_dir = "SHPC_cyclo") - call shpc_create(hshp_anti, shpc_dir = "SHPC_anti") + call shpc_create(hshp_cyclo, shpc_dir = "SHPC_cyclo", cyclone = .true.) + call shpc_create(hshp_anti, shpc_dir = "SHPC_anti", cyclone = .false.) n_cyclo = 0 n_anti = 0 diff --git a/Inst_eddies/Tests/test_set_max_speed.f90 b/Inst_eddies/Tests/test_set_max_speed.f90 index 39f5dfc2dc2944c6c17e5382a8e976f6d822875b..58bf112ec7aaacee58b72fa9675c70ee7f05827c 100644 --- a/Inst_eddies/Tests/test_set_max_speed.f90 +++ b/Inst_eddies/Tests/test_set_max_speed.f90 @@ -104,7 +104,7 @@ program test_set_max_speed step = 0.25 * deg_to_rad call set_max_speed(e, nint((e%coord_extr - corner) / step) + 1, & outside_points, ssh, u, v, corner, step) - call shpc_create(hshp, shpc_dir = "SHPC") + call shpc_create(hshp, shpc_dir = "SHPC", cyclone = e%cyclone) call write_eddy(e, hshp, d, i) CALL shpc_close(hshp) print *, 'Created "SHPC".' diff --git a/Inst_eddies/inst_eddies.f90 b/Inst_eddies/inst_eddies.f90 index 2b7e9587d52d4e8717cb6533cc3e140f4e60ee39..d2bc8a7874908bbbe0355bded7a9e1326580c26a 100644 --- a/Inst_eddies/inst_eddies.f90 +++ b/Inst_eddies/inst_eddies.f90 @@ -177,8 +177,8 @@ program inst_eddies ! Write snapshot: - call shpc_create(hshp_cyclo, shpc_dir = "SHPC_cyclo") - call shpc_create(hshp_anti, shpc_dir = "SHPC_anti") + call shpc_create(hshp_cyclo, shpc_dir = "SHPC_cyclo", cyclone = .true.) + call shpc_create(hshp_anti, shpc_dir = "SHPC_anti", cyclone = .false.) n_cyclo = 0 n_anti = 0 diff --git a/Overlap/Tests/CMakeLists.txt b/Overlap/Tests/CMakeLists.txt index 46eb1020d337654292bd57b9cfadf7e625e733cf..23ec522f61f144b9865e5b40fe82bcb20b521e7e 100644 --- a/Overlap/Tests/CMakeLists.txt +++ b/Overlap/Tests/CMakeLists.txt @@ -73,7 +73,7 @@ add_executable(test_read_eddy ${CMAKE_SOURCE_DIR}/Common/shpc_close.f90) target_link_libraries(test_read_eddy shapelib_03 contour_531 gpc_f - ezmpi nr_util MPI::MPI_Fortran) + ezmpi nr_util MPI::MPI_Fortran jumble) target_include_directories(test_read_eddy PRIVATE ${fortrangis_INCLUDE_DIR}) diff --git a/Overlap/Tests/test_overlap.f90 b/Overlap/Tests/test_overlap.f90 index 72fdf9fd656064de9229876513fd4468ab23badf..7413a7a544bbec4a914e711b3beda30d6ea64e44 100644 --- a/Overlap/Tests/test_overlap.f90 +++ b/Overlap/Tests/test_overlap.f90 @@ -102,7 +102,7 @@ program test_overlap // '"successor eddy subscript"' write(unit_edge, fmt = *) "k1 i1 k2 i2 weight" - call shpc_create(hshp, shpc_dir = "SHPC") + call shpc_create(hshp, shpc_dir = "SHPC", cyclone = hshp%cyclone) call init_interpolated_eddy call overlap(flow, nlon, nlat, periodic, dist_lim, hshp, k = k_test_2, & delta = max_delta, j = max_delta + 1) diff --git a/Overlap/Tests/test_read_eddy.f90 b/Overlap/Tests/test_read_eddy.f90 index 0f84f54ae9d0b5e9edf005d542691b85e80a7374..44721a5337655af9abc70ad3af37b74658227571 100644 --- a/Overlap/Tests/test_read_eddy.f90 +++ b/Overlap/Tests/test_read_eddy.f90 @@ -23,7 +23,7 @@ program test_read_eddy call read_eddy(e, k, i, hshp, ishape = 0) CALL shpc_close(hshp) - call shpc_create(hshp, shpc_dir = "SHPC") + call shpc_create(hshp, shpc_dir = "SHPC", cyclone = hshp%cyclone) call write_eddy(e, hshp, k, i) CALL shpc_close(hshp) print *, 'Created shapefiles in SHPC.' diff --git a/Overlap/Tests/test_write_overlap.f90 b/Overlap/Tests/test_write_overlap.f90 index 3f1ae908a1f6a51ce7459b0578977304747153a4..e53957cb1a8382cdcb02411f30debd174c24ba67 100644 --- a/Overlap/Tests/test_write_overlap.f90 +++ b/Overlap/Tests/test_write_overlap.f90 @@ -33,7 +33,7 @@ program test_write_overlap // '"successor eddy subscript"' write(unit_edge, fmt = *) "k1 i1 k2 i2 weight" - call shpc_create(hshp, shpc_dir = "SHPC") + call shpc_create(hshp, shpc_dir = "SHPC", cyclone = .true.) call init_interpolated_eddy call write_overlap(hshp, k, delta, i1 = 1, i2 = 2, m = m, & i_interp = 10 + [(j_interp, j_interp = 1, delta - 1)], & diff --git a/Overlap/Tests/write_snapshot.f90 b/Overlap/Tests/write_snapshot.f90 index 9f22fcf5b684b6e930306d6371b5ac9ecb126ae8..69c8858f6636aaaef29303a061804eb9bff0986a 100644 --- a/Overlap/Tests/write_snapshot.f90 +++ b/Overlap/Tests/write_snapshot.f90 @@ -35,7 +35,7 @@ contains !----------------------------------------------------------------- - call shpc_create(hshp, shpc_dir = "SHPC") + call shpc_create(hshp, shpc_dir = "SHPC", cyclone = s%list_vis(1)%cyclone) ! Write snapshot: do i = 1, s%number_vis_extr diff --git a/Overlap/eddy_graph.f90 b/Overlap/eddy_graph.f90 index 996eb0506ef1602d0a87fa61485c9cd2204cea80..014ea25d4610c9a0c4436bf893e18b7a3c5455ba 100644 --- a/Overlap/eddy_graph.f90 +++ b/Overlap/eddy_graph.f90 @@ -135,7 +135,7 @@ program eddy_graph ! We do not write the title line. That will be handled by eddy_graph.sh. write(unit = file, fmt = '("SHPC_", i0)') rank - call shpc_create(hshp_interp, shpc_dir = trim(file)) + call shpc_create(hshp_interp, shpc_dir = trim(file), cyclone = hshp%cyclone) call init_interpolated_eddy k_begin = k1 + (rank * n_dates) / n_proc