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

Do not broadcast when opening SHPC

It was confusing to mix opening an SHPC with broadcasting some part of
the resulting shpc variable.
parent 2dd35e03
No related branches found
No related tags found
No related merge requests found
...@@ -4,61 +4,38 @@ module read_field_indices_m ...@@ -4,61 +4,38 @@ module read_field_indices_m
contains contains
subroutine read_field_indices(hshp, rank) subroutine read_field_indices(hshp)
! Libraries: ! Libraries:
#ifdef HAVE_MPI
use ezmpi, only: ezmpi_bcast
#endif
use shapelib_03, only: dbf_get_field_index_03 use shapelib_03, only: dbf_get_field_index_03
use derived_types, only: shpc use derived_types, only: shpc
TYPE(shpc), intent(inout):: hshp TYPE(shpc), intent(inout):: hshp
integer, intent(in):: rank ! should be 0 if not in MPI program
!--------------------------------------------------------------------- !---------------------------------------------------------------------
if (rank == 0) then call dbf_get_field_index_03(hshp%extremum, "ssh", hshp%extr_ssh)
call dbf_get_field_index_03(hshp%extremum, "ssh", hshp%extr_ssh) call dbf_get_field_index_03(hshp%extremum, "date", hshp%extr_date)
call dbf_get_field_index_03(hshp%extremum, "date", hshp%extr_date) call dbf_get_field_index_03(hshp%extremum, "eddy_index", &
call dbf_get_field_index_03(hshp%extremum, "eddy_index", & hshp%extr_eddy_index)
hshp%extr_eddy_index) call dbf_get_field_index_03(hshp%extremum, "valid", hshp%extr_valid)
call dbf_get_field_index_03(hshp%extremum, "valid", hshp%extr_valid) call dbf_get_field_index_03(hshp%extremum, "speed", hshp%extr_speed)
call dbf_get_field_index_03(hshp%extremum, "speed", hshp%extr_speed)
call dbf_get_field_index_03(hshp%outermost, "r_eq_area", &
call dbf_get_field_index_03(hshp%outermost, "r_eq_area", & hshp%out_r_eq_area)
hshp%out_r_eq_area) call dbf_get_field_index_03(hshp%outermost, "ssh", hshp%out_ssh)
call dbf_get_field_index_03(hshp%outermost, "ssh", hshp%out_ssh) call dbf_get_field_index_03(hshp%outermost, "date", hshp%out_date)
call dbf_get_field_index_03(hshp%outermost, "date", hshp%out_date) call dbf_get_field_index_03(hshp%outermost, "eddy_index", &
call dbf_get_field_index_03(hshp%outermost, "eddy_index", & hshp%out_eddy_index)
hshp%out_eddy_index) call dbf_get_field_index_03(hshp%outermost, "radius4", hshp%out_radius4)
call dbf_get_field_index_03(hshp%outermost, "radius4", hshp%out_radius4)
call dbf_get_field_index_03(hshp%max_speed, "r_eq_area", &
call dbf_get_field_index_03(hshp%max_speed, "r_eq_area", & hshp%max_speed_r_eq_area)
hshp%max_speed_r_eq_area) call dbf_get_field_index_03(hshp%max_speed, "ssh", hshp%max_speed_ssh)
call dbf_get_field_index_03(hshp%max_speed, "ssh", hshp%max_speed_ssh) call dbf_get_field_index_03(hshp%max_speed, "date", hshp%max_speed_date)
call dbf_get_field_index_03(hshp%max_speed, "date", hshp%max_speed_date) call dbf_get_field_index_03(hshp%max_speed, "eddy_index", &
call dbf_get_field_index_03(hshp%max_speed, "eddy_index", & hshp%max_speed_eddy_index)
hshp%max_speed_eddy_index)
end if
#ifdef HAVE_MPI
call ezmpi_bcast(hshp%extr_ssh, root = 0)
call ezmpi_bcast(hshp%extr_date, root = 0)
call ezmpi_bcast(hshp%extr_eddy_index, 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)
call ezmpi_bcast(hshp%out_ssh, root = 0)
call ezmpi_bcast(hshp%out_date, root = 0)
call ezmpi_bcast(hshp%out_eddy_index, root = 0)
call ezmpi_bcast(hshp%out_radius4, root = 0)
call ezmpi_bcast(hshp%max_speed_r_eq_area, root = 0)
call ezmpi_bcast(hshp%max_speed_ssh, root = 0)
call ezmpi_bcast(hshp%max_speed_date, root = 0)
call ezmpi_bcast(hshp%max_speed_eddy_index, root = 0)
#endif
end subroutine read_field_indices end subroutine read_field_indices
......
...@@ -4,12 +4,9 @@ module shpc_open_m ...@@ -4,12 +4,9 @@ module shpc_open_m
contains contains
subroutine shpc_open(hshp, shpc_dir, rank, pszaccess) subroutine shpc_open(hshp, shpc_dir, pszaccess)
! Libraries: ! Libraries:
#ifdef HAVE_MPI
use ezmpi, only: ezmpi_bcast
#endif
USE jumble, only: new_unit USE jumble, only: new_unit
use shapelib_03, only: shp_open_03 use shapelib_03, only: shp_open_03
...@@ -18,7 +15,6 @@ contains ...@@ -18,7 +15,6 @@ contains
TYPE(shpc), intent(out):: hshp TYPE(shpc), intent(out):: hshp
character(len = *), intent(in):: shpc_dir character(len = *), intent(in):: shpc_dir
integer, intent(in):: rank ! should be 0 if not in MPI program
character(len = *), intent(in):: pszaccess ! should be "rb" or "rb+" character(len = *), intent(in):: pszaccess ! should be "rb" or "rb+"
! Local: ! Local:
...@@ -32,20 +28,13 @@ contains ...@@ -32,20 +28,13 @@ contains
pszaccess) pszaccess)
call shp_open_03(hshp%max_speed, shpc_dir // "/max_speed_contour", & call shp_open_03(hshp%max_speed, shpc_dir // "/max_speed_contour", &
pszaccess) pszaccess)
call read_field_indices(hshp, rank) call read_field_indices(hshp)
call new_unit(unit)
if (rank == 0) then open(unit, file = shpc_dir // "/orientation.txt", status = "old", &
call new_unit(unit) action = "read", position = "rewind")
open(unit, file = shpc_dir // "/orientation.txt", status = "old", & read(unit, fmt = *) orientation
action = "read", position = "rewind") close(unit)
read(unit, fmt = *) orientation hshp%cyclone = trim(adjustl(orientation)) == "cyclones"
close(unit)
hshp%cyclone = trim(adjustl(orientation)) == "cyclones"
end if
#ifdef HAVE_MPI
call ezmpi_bcast(hshp%cyclone, root = 0)
#endif
end subroutine shpc_open end subroutine shpc_open
......
...@@ -48,7 +48,7 @@ program test_nearby_extr ...@@ -48,7 +48,7 @@ program test_nearby_extr
read(unit, fmt = *) ishape_last ! first date read(unit, fmt = *) ishape_last ! first date
close(unit) close(unit)
call shpc_open(hshp, trim(shpc_dir), rank = 0, pszaccess = "rb") call shpc_open(hshp, trim(shpc_dir), pszaccess = "rb")
call dbf_read_attribute_03(d_init, hshp%extremum, hshp%extr_date, ishape = 0) call dbf_read_attribute_03(d_init, hshp%extremum, hshp%extr_date, ishape = 0)
call read_snapshot(s, hshp, nlon, nlat, d_init, k = d_init, & call read_snapshot(s, hshp, nlon, nlat, d_init, k = d_init, &
corner = corner_deg * deg_to_rad, step = step_deg * deg_to_rad, & corner = corner_deg * deg_to_rad, step = step_deg * deg_to_rad, &
......
...@@ -73,7 +73,7 @@ program test_set_max_speed ...@@ -73,7 +73,7 @@ program test_set_max_speed
call nf95_close(ncid) call nf95_close(ncid)
print *, "Reading from shapefiles..." print *, "Reading from shapefiles..."
call shpc_open(hshp, shpc_dir, rank = 0, pszaccess = "rb") call shpc_open(hshp, shpc_dir, pszaccess = "rb")
call read_eddy(e, d, i, hshp, ishape = 0) call read_eddy(e, d, i, hshp, ishape = 0)
CALL shpc_close(hshp) CALL shpc_close(hshp)
......
...@@ -172,10 +172,8 @@ program inst_eddies ...@@ -172,10 +172,8 @@ program inst_eddies
! Write snapshot: ! Write snapshot:
if (exist) then if (exist) then
call shpc_open(hshpc_cyclo, shpc_dir = "SHPC_cyclo", rank = 0, & call shpc_open(hshpc_cyclo, shpc_dir = "SHPC_cyclo", pszaccess = "rb+")
pszaccess = "rb+") call shpc_open(hshpc_anti, shpc_dir = "SHPC_anti", pszaccess = "rb+")
call shpc_open(hshpc_anti, shpc_dir = "SHPC_anti", rank = 0, &
pszaccess = "rb+")
else else
call shpc_create(hshpc_cyclo, shpc_dir = "SHPC_cyclo", cyclone = .true.) call shpc_create(hshpc_cyclo, shpc_dir = "SHPC_cyclo", cyclone = .true.)
call shpc_create(hshpc_anti, shpc_dir = "SHPC_anti", cyclone = .false.) call shpc_create(hshpc_anti, shpc_dir = "SHPC_anti", cyclone = .false.)
......
...@@ -77,7 +77,7 @@ program test_get_dispatch_snap ...@@ -77,7 +77,7 @@ program test_get_dispatch_snap
copy = merge(dist_lim, 0, periodic) copy = merge(dist_lim, 0, periodic)
end if end if
call shpc_open(hshp, trim(shpc_dir), rank, pszaccess = "rb") call shpc_open(hshp, trim(shpc_dir), pszaccess = "rb")
if (rank == 0) then if (rank == 0) then
call dbf_read_attribute_03(d_init, hshp%extremum, hshp%extr_date, & call dbf_read_attribute_03(d_init, hshp%extremum, hshp%extr_date, &
......
...@@ -66,7 +66,7 @@ program test_overlap ...@@ -66,7 +66,7 @@ program test_overlap
corner = corner_deg * deg_to_rad corner = corner_deg * deg_to_rad
step = step_deg * deg_to_rad step = step_deg * deg_to_rad
allocate(flow(max_delta + 1)) allocate(flow(max_delta + 1))
call shpc_open(hshp, trim(shpc_dir), rank = 0, pszaccess = "rb") call shpc_open(hshp, trim(shpc_dir), pszaccess = "rb")
call dbf_read_attribute_03(d_init, hshp%extremum, hshp%extr_date, ishape = 0) call dbf_read_attribute_03(d_init, hshp%extremum, hshp%extr_date, ishape = 0)
call read_column(ishape_last, file = trim(shpc_dir) // "/ishape_last.txt", & call read_column(ishape_last, file = trim(shpc_dir) // "/ishape_last.txt", &
my_lbound = d_init) my_lbound = d_init)
......
...@@ -15,7 +15,7 @@ program test_read_eddy ...@@ -15,7 +15,7 @@ program test_read_eddy
!------------------------------------------------------------------------- !-------------------------------------------------------------------------
call shpc_open(hshp, "SHPC_old", rank = 0, pszaccess = "rb") call shpc_open(hshp, "SHPC_old", pszaccess = "rb")
call read_eddy(e, k, i, hshp, ishape = 0) call read_eddy(e, k, i, hshp, ishape = 0)
CALL shpc_close(hshp) CALL shpc_close(hshp)
......
...@@ -66,7 +66,7 @@ program test_read_snapshot ...@@ -66,7 +66,7 @@ program test_read_snapshot
read(unit, fmt = *) ishape_last ! first date read(unit, fmt = *) ishape_last ! first date
close(unit) close(unit)
call shpc_open(hshp, trim(shpc_dir), rank = 0, pszaccess = "rb") call shpc_open(hshp, trim(shpc_dir), pszaccess = "rb")
call dbf_read_attribute_03(d_init, hshp%extremum, hshp%extr_date, ishape = 0) call dbf_read_attribute_03(d_init, hshp%extremum, hshp%extr_date, ishape = 0)
call read_snapshot(s, hshp, nlon, nlat, d_init, k = d_init, & call read_snapshot(s, hshp, nlon, nlat, d_init, k = d_init, &
corner = corner_deg * deg_to_rad, step = step_deg * deg_to_rad, & corner = corner_deg * deg_to_rad, step = step_deg * deg_to_rad, &
......
...@@ -86,7 +86,7 @@ program test_send_recv ...@@ -86,7 +86,7 @@ program test_send_recv
copy = merge(dist_lim, 0, periodic) copy = merge(dist_lim, 0, periodic)
end if end if
call shpc_open(hshp, trim(shpc_dir), rank, pszaccess = "rb") call shpc_open(hshp, trim(shpc_dir), pszaccess = "rb")
if (rank == 0) then if (rank == 0) then
call dbf_read_attribute_03(d_init, hshp%extremum, hshp%extr_date, & call dbf_read_attribute_03(d_init, hshp%extremum, hshp%extr_date, &
......
...@@ -93,7 +93,7 @@ program eddy_graph ...@@ -93,7 +93,7 @@ program eddy_graph
copy = merge(dist_lim, 0, periodic) copy = merge(dist_lim, 0, periodic)
end if end if
call shpc_open(hshp, trim(shpc_dir), rank, pszaccess = "rb") call shpc_open(hshp, trim(shpc_dir), pszaccess = "rb")
if (rank == 0) then if (rank == 0) then
call dbf_read_attribute_03(d_init, hshp%extremum, hshp%extr_date, & call dbf_read_attribute_03(d_init, hshp%extremum, hshp%extr_date, &
......
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