diff --git a/Common/derived_types.f90 b/Common/derived_types.f90 index 1a165e942c9a68aaff0493c483b785087c245396..87655a4531a0d7d4ee6b4e639df93a46ae900a0c 100644 --- a/Common/derived_types.f90 +++ b/Common/derived_types.f90 @@ -72,6 +72,7 @@ module derived_types TYPE(shpfileobject) extremum ! shapefile extremum TYPE(shpfileobject) outermost ! shapefile outermost_contour TYPE(shpfileobject) max_speed ! shapefile max_speed_contour + integer unit ! ishape_last.txt logical cyclone ! Field identifiers in the DBF files: diff --git a/Common/shpc_close.f90 b/Common/shpc_close.f90 index 7c43e2e8521e6efb213f95a86facc53c5ddb3eec..7fb38edee80894e21850f462bedf782c95569e90 100644 --- a/Common/shpc_close.f90 +++ b/Common/shpc_close.f90 @@ -18,6 +18,7 @@ contains CALL shpclose(hshp%extremum) CALL shpclose(hshp%outermost) CALL shpclose(hshp%max_speed) + close(hshp%unit) deallocate(hshp%dir) if (allocated(hshp%ishape_last)) deallocate(hshp%ishape_last) diff --git a/Common/shpc_create.f90 b/Common/shpc_create.f90 index 245c46f0b8329165d3a405fdd752f9e23f744299..b3e7df61d929d6fddca59c19581cfc4ab881a1ce 100644 --- a/Common/shpc_create.f90 +++ b/Common/shpc_create.f90 @@ -61,6 +61,9 @@ contains call dbf_add_field_03(hshp%max_speed_eddy_index, hshp%max_speed, & 'eddy_index', ftinteger, nwidth = 5, ndecimals = 0) + call new_unit(hshp%unit) + open(hshp%unit, file = hshp%dir // "/ishape_last.txt", status = "replace", & + action = "write") hshp%cyclone = cyclone call new_unit(unit) open(unit, file = shpc_dir // "/orientation.txt", status = "replace", & diff --git a/Common/shpc_open.f90 b/Common/shpc_open.f90 index 344d072e349b05689f86fc283c7601d718012189..654581acd86feaef4d2f6da68d0ca3b9a0e4bbaf 100644 --- a/Common/shpc_open.f90 +++ b/Common/shpc_open.f90 @@ -36,6 +36,15 @@ contains close(unit) hshp%cyclone = trim(adjustl(orientation)) == "cyclones" hshp%dir = shpc_dir + call new_unit(hshp%unit) + + if (pszaccess == "rb") then + open(hshp%unit, file = hshp%dir // "/ishape_last.txt", & + status = "old", action = "read", position = "rewind") + else + open(hshp%unit, file = hshp%dir // "/ishape_last.txt", & + status = "old", action = "readwrite", position = "append") + end if end subroutine shpc_open diff --git a/Inst_eddies/Tests/test_get_1_outerm.f90 b/Inst_eddies/Tests/test_get_1_outerm.f90 index bba5dba2a0f4bbb0d1abb74b37c27971624f9ec9..e4f7c764a4827a737dbf8355fb3db5cc55027867 100644 --- a/Inst_eddies/Tests/test_get_1_outerm.f90 +++ b/Inst_eddies/Tests/test_get_1_outerm.f90 @@ -99,9 +99,7 @@ program test_get_1_outerm e%valid = .true. call shpc_create(hshp, shpc_dir = "SHPC", cyclone = cyclone) call write_eddy(e, hshp, date, i = 1) - open(unit, file = "SHPC/ishape_last.txt", status = "replace", & - action = "write") - write(unit, fmt = *) 0 + write(hshp%unit, fmt = *) 0 CALL shpc_close(hshp) print *, 'Created "SHPC".' else diff --git a/Inst_eddies/Tests/test_nearby_extr.f90 b/Inst_eddies/Tests/test_nearby_extr.f90 index ad155d3b3e1d402204179de4006211f86309d4ee..63d95eb2bbcf387c01fd26990d1ad9c48039de35 100644 --- a/Inst_eddies/Tests/test_nearby_extr.f90 +++ b/Inst_eddies/Tests/test_nearby_extr.f90 @@ -1,7 +1,7 @@ program test_nearby_extr ! Libraries: - use jumble, only: get_command_arg_dyn, new_unit, read_column + use jumble, only: get_command_arg_dyn, new_unit, read_opcol use jumble, only: deg_to_rad, rad_to_deg use shapelib_03, only: dbf_read_attribute_03 @@ -45,8 +45,7 @@ program test_nearby_extr call shpc_open(hshp, trim(shpc_dir), pszaccess = "rb") call dbf_read_attribute_03(hshp%d0, hshp%extremum, hshp%extr_date, ishape = 0) - call read_column(hshp%ishape_last, file = shpc_dir // "/ishape_last.txt", & - my_lbound = hshp%d0) + call read_opcol(hshp%ishape_last, hshp%unit, my_lbound = hshp%d0) call read_snapshot(s, [hshp], nlon, nlat, k = hshp%d0, & corner = corner_deg * deg_to_rad, step = step_deg * deg_to_rad, & copy = 0) diff --git a/Inst_eddies/write_aux.f90 b/Inst_eddies/write_aux.f90 index d271e3eba8823b90773228610520b06af28540ce..ea8ace3ba25a0a41994c574e1c251c5c5a6606bb 100644 --- a/Inst_eddies/write_aux.f90 +++ b/Inst_eddies/write_aux.f90 @@ -39,22 +39,14 @@ contains !-------------------------------------------------------------------- call shp_get_info_03(hshpc%extremum, n_entities) - call new_unit(unit) + write(hshpc%unit, fmt = *) n_entities - 1 - if (exist) then - open(unit, file = hshpc%dir // "/ishape_last.txt", status = "old", & - action = "write", position = "append") - write(unit, fmt = *) n_entities - 1 - close(unit) - else + if (.not. exist) then + call new_unit(unit) open(unit, file = hshpc%dir // "/grid_nml.txt", status = "replace", & action = "write") write(unit, nml = grid_nml) close(unit) - open(unit, file = hshpc%dir // "/ishape_last.txt", status = "replace", & - action = "write") - write(unit, fmt = *) n_entities - 1 - close(unit) end if end subroutine write_aux diff --git a/Overlap/Tests/test_get_dispatch_snap.f90 b/Overlap/Tests/test_get_dispatch_snap.f90 index fbb12074e4275d9080940acee8f57d129f65b70d..9a6b245f53438233da0f704694185de6a575f8ba 100644 --- a/Overlap/Tests/test_get_dispatch_snap.f90 +++ b/Overlap/Tests/test_get_dispatch_snap.f90 @@ -4,7 +4,7 @@ program test_get_dispatch_snap ! Libraries: use ezmpi, only: ezmpi_bcast - use jumble, only: get_command_arg_dyn, read_column, new_unit, assert, & + use jumble, only: get_command_arg_dyn, read_opcol, new_unit, assert, & deg_to_rad use mpi_f08, only: mpi_init, mpi_finalize, MPI_Comm_rank, MPI_Comm_world, & MPI_Comm_size, mpi_abort @@ -74,8 +74,7 @@ program test_get_dispatch_snap call shpc_open(hshp, trim(shpc_dir), pszaccess = "rb") call dbf_read_attribute_03(hshp%d0, hshp%extremum, hshp%extr_date, ishape = 0) - call read_column(hshp%ishape_last, file = shpc_dir // "/ishape_last.txt", & - my_lbound = hshp%d0) + call read_opcol(hshp%ishape_last, hshp%unit, my_lbound = hshp%d0) if (rank == 0) then n_dates = size(hshp%ishape_last) diff --git a/Overlap/Tests/test_overlap.f90 b/Overlap/Tests/test_overlap.f90 index d20a3baebb14a88998db380b8cb833c056a5d14e..fe92043addd25aafe3f66344aeb909117cf632c2 100644 --- a/Overlap/Tests/test_overlap.f90 +++ b/Overlap/Tests/test_overlap.f90 @@ -3,7 +3,7 @@ program test_overlap use, intrinsic:: ISO_FORTRAN_ENV ! Libraries: - use jumble, only: get_command_arg_dyn, read_column, new_unit, ediff1d + use jumble, only: get_command_arg_dyn, read_opcol, new_unit, ediff1d use jumble, only: deg_to_rad, assert use shapelib_03, only: dbf_read_attribute_03 @@ -67,8 +67,7 @@ program test_overlap call shpc_open(hshp, trim(shpc_dir), pszaccess = "rb") call dbf_read_attribute_03(hshp%d0, hshp%extremum, hshp%extr_date, & ishape = 0) - call read_column(hshp%ishape_last, file = shpc_dir // "/ishape_last.txt", & - my_lbound = hshp%d0) + call read_opcol(hshp%ishape_last, hshp%unit, my_lbound = hshp%d0) n_dates = size(hshp%ishape_last) call assert(hshp%d0 <= [k_test_1, k_test_2] .and. [k_test_1, k_test_2] & < hshp%d0 + n_dates, "test_overlap k_test_1, k_test_2") diff --git a/Overlap/Tests/test_read_eddy.f90 b/Overlap/Tests/test_read_eddy.f90 index 838ca5bd9b958f02b2334ea10dc0d3d3e31007ba..a59d554d22b61112732b2018de2f10866b407ca0 100644 --- a/Overlap/Tests/test_read_eddy.f90 +++ b/Overlap/Tests/test_read_eddy.f90 @@ -1,7 +1,7 @@ program test_read_eddy ! Library: - use jumble, only: get_command_arg_dyn, read_column + use jumble, only: get_command_arg_dyn, read_opcol use shapelib_03, only: dbf_read_attribute_03 use derived_types, only: eddy, shpc_slice_handler @@ -27,8 +27,7 @@ program test_read_eddy read(unit = *, nml = main_nml) call shpc_open(hshp, shpc_dir, pszaccess = "rb") call dbf_read_attribute_03(hshp%d0, hshp%extremum, hshp%extr_date, ishape = 0) - call read_column(hshp%ishape_last, file = shpc_dir // "/ishape_last.txt", & - my_lbound = hshp%d0) + call read_opcol(hshp%ishape_last, hshp%unit, my_lbound = hshp%d0) call read_eddy(e, k, eddy_i, hshp, ishape) CALL shpc_close(hshp) diff --git a/Overlap/Tests/test_read_snapshot.f90 b/Overlap/Tests/test_read_snapshot.f90 index 82088b2476ea0977cb261b457c1965fe9980c243..b6a9783a81ce1b595f15767c118e60d4497291e4 100644 --- a/Overlap/Tests/test_read_snapshot.f90 +++ b/Overlap/Tests/test_read_snapshot.f90 @@ -4,7 +4,7 @@ program test_read_snapshot ! Libraries: use jumble, only: get_command_arg_dyn, new_unit, deg_to_rad, assert, & - read_column + read_opcol use shapelib_03, only: dbf_read_attribute_03 use derived_types, only: snapshot, shpc_slice_handler @@ -51,8 +51,7 @@ program test_read_snapshot call shpc_open(hshp(i), trim(shpc_dir), pszaccess = "rb") call dbf_read_attribute_03(hshp(i)%d0, hshp(i)%extremum, & hshp(i)%extr_date, ishape = 0) - call read_column(hshp(i)%ishape_last, & - file = shpc_dir // "/ishape_last.txt", my_lbound = hshp(i)%d0) + call read_opcol(hshp(i)%ishape_last, hshp(i)%unit, my_lbound = hshp(i)%d0) end do ! Assuming grid_nml.txt is the same in all input SHPC: diff --git a/Overlap/Tests/test_send_recv.f90 b/Overlap/Tests/test_send_recv.f90 index b88cd1eddf9161a12fc71a81322db5662b6c923f..a522354841f1c1f63a435235915d1479c29a3e70 100644 --- a/Overlap/Tests/test_send_recv.f90 +++ b/Overlap/Tests/test_send_recv.f90 @@ -4,7 +4,7 @@ program test_send_recv ! Libraries: use ezmpi, only: ezmpi_bcast - use jumble, only: get_command_arg_dyn, read_column, new_unit + use jumble, only: get_command_arg_dyn, read_opcol, new_unit use mpi_f08, only: mpi_init, mpi_finalize, MPI_Comm_rank, MPI_Comm_world, & MPI_Comm_size, mpi_abort, MPI_TAG_UB, MPI_Comm_get_attr, & MPI_ADDRESS_KIND, MPI_io, MPI_ANY_SOURCE @@ -84,8 +84,7 @@ program test_send_recv call shpc_open(hshp, trim(shpc_dir), pszaccess = "rb") call dbf_read_attribute_03(hshp%d0, hshp%extremum, hshp%extr_date, ishape = 0) - call read_column(hshp%ishape_last, file = shpc_dir // "/ishape_last.txt", & - my_lbound = hshp%d0) + call read_opcol(hshp%ishape_last, hshp%unit, my_lbound = hshp%d0) if (rank == 0) then n_dates = size(hshp%ishape_last) diff --git a/Overlap/eddy_graph.f90 b/Overlap/eddy_graph.f90 index 3f87fd42da58860586aa613ca4df7f18802a7b03..e0e1a432075eae3c50b0e8163abbbbebf31a1f6d 100644 --- a/Overlap/eddy_graph.f90 +++ b/Overlap/eddy_graph.f90 @@ -5,7 +5,7 @@ program eddy_graph ! Libraries: use ezmpi, only: ezmpi_bcast use jumble, only: get_command_arg_dyn, new_unit, ediff1d, assert, & - deg_to_rad, read_column + deg_to_rad, read_opcol use mpi_f08, only: mpi_init, mpi_finalize, MPI_Comm_rank, MPI_Comm_world, & MPI_Comm_size use shapelib_03, only: dbf_read_attribute_03 @@ -81,8 +81,8 @@ program eddy_graph call shpc_open(hshpc(i), trim(shpc_dir), pszaccess = "rb") call dbf_read_attribute_03(hshpc(i)%d0, hshpc(i)%extremum, & hshpc(i)%extr_date, ishape = 0) - call read_column(hshpc(i)%ishape_last, & - file = shpc_dir // "/ishape_last.txt", my_lbound = hshpc(i)%d0) + call read_opcol(hshpc(i)%ishape_last, hshpc(i)%unit, & + my_lbound = hshpc(i)%d0) end do if (rank == 0) then