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

Use procedures `config_graph` and `read_grid`

parent 5939685c
No related branches found
No related tags found
No related merge requests found
......@@ -26,7 +26,8 @@ target_sources(test_spher_polygon_area PRIVATE spher_polygon_area.f90)
target_sources(test_nearby_extr PRIVATE read_grid.F90 read_snapshot.f90
read_eddy.f90)
target_sources(test_set_max_speed PRIVATE read_eddy.f90)
target_sources(test_read_snapshot PRIVATE read_snapshot.f90 read_eddy.f90)
target_sources(test_read_snapshot PRIVATE read_snapshot.f90 read_eddy.f90
read_grid.F90 config_graph.F90)
if(MPI_Fortran_HAVE_F08_MODULE)
target_sources(test_send_recv PRIVATE send_snapshot.f90 recv_snapshot.f90)
......
......@@ -10,6 +10,7 @@ target_sources(test_read_snapshot PRIVATE test_read_snapshot.f90
target_link_libraries(test_read_snapshot NetCDF95::netcdf95
Shapelib_03::shapelib_03 Contour_531::contour_531 gpc_f
Jumble::jumble NetCDF_Fortran::netcdff Numer_Rec_95::numer_rec_95)
target_compile_definitions(test_read_snapshot PRIVATE CPP_SEQUENTIAL)
# test_spher_polygon_area
add_executable(test_spher_polygon_area test_spher_polygon_area.f90)
......
......@@ -3,11 +3,12 @@ program test_read_snapshot
use, intrinsic:: ISO_FORTRAN_ENV
! Libraries:
use jumble, only: get_command_arg_dyn, new_unit, deg_to_rad, assert, &
read_opcol
use jumble, only: get_command_arg_dyn, new_unit, read_opcol
use shapelib_03, only: dbf_read_attribute_03
use config_graph_m, only: config_graph, copy
use derived_types, only: snapshot, shpc_slice_handler, shpc_slice_meta
use read_grid_m, only: read_grid
use read_snapshot_m, only: read_snapshot
use shpc_close_m, only: shpc_close
use shpc_open_m, only: shpc_open
......@@ -19,39 +20,20 @@ program test_read_snapshot
type(snapshot) s
TYPE(shpc_slice_handler), allocatable:: hshp(:) ! (n_slices)
type(shpc_slice_meta), allocatable:: ssm(:) ! (n_slices)
integer copy, unit, k, i, iostat
integer unit, k, i, iostat
integer n_slices ! number of input SHPC directories
real:: corner_deg(2) = [0.125, - 59.875]
! longitude and latitude of the corner of the whole grid in input
! NetCDF, in degrees
real:: step_deg(2) = [0.25, 0.25] ! longitude and latitude steps, in degrees
logical periodic ! grid is periodic in longitude
integer:: nlon = 120, nlat = 120
! size of ssh array in input NetCDF, assuming no repeated point if
! the grid is global
integer:: dist_lim = 12
! We look for an overlapping eddy at dist_lim (in grid points) of
! the first extremum.
namelist /main_nml/ dist_lim, k
namelist /grid_nml/ corner_deg, step_deg, nlon, nlat
namelist /main_nml/ k
!-------------------------------------------------------------------------
call get_command_arg_dyn(1, shpc_dir, "Required argument: SHPC-directory")
call new_unit(unit)
open(unit, file = shpc_dir // "/grid_nml.txt", status = "old", &
action = "read", position = "rewind")
read(unit, nml = grid_nml)
close(unit)
call read_grid(rank = 0, shpc_dir = shpc_dir)
call config_graph(rank = 0)
! n_slices:
call new_unit(unit)
open(unit, file = shpc_dir // "/n_slices.txt", status = "old", &
action = "read", position = "rewind", iostat = iostat)
......@@ -81,17 +63,7 @@ program test_read_snapshot
read(unit = *, nml = main_nml)
write(unit = *, nml = main_nml)
! As we are requiring the grid spacing to be uniform, the value of
! "periodic" may be deduced from the values of step_deg(1) and nlon:
periodic = nint(360. / step_deg(1)) == nlon
print *, "test_read_snapshot: periodic = ", periodic
if (periodic) call assert(2 * dist_lim * step_deg(1) < 180., &
"test_read_snapshot dist_lim")
copy = merge(dist_lim, 0, periodic)
call read_snapshot(s, hshp, ssm, nlon, nlat, k, &
corner = corner_deg * deg_to_rad, step = step_deg * deg_to_rad, &
copy = copy)
call read_snapshot(s, hshp, ssm, k, copy)
do i = 1, n_slices
CALL shpc_close(hshp(i))
......
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