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

Generalize `test_read_snapshot` to several SHPC

Generalize `test_read_snapshot` to accept several SHPC onthe command line.
parent c8a8253c
Branches
No related tags found
No related merge requests found
...@@ -16,8 +16,9 @@ program test_read_snapshot ...@@ -16,8 +16,9 @@ program test_read_snapshot
character(len = :), allocatable:: shpc_dir character(len = :), allocatable:: shpc_dir
type(snapshot) s type(snapshot) s
TYPE(shpc) hshp TYPE(shpc), allocatable:: hshp(:) ! (n_shpc)
integer copy, unit, k integer copy, unit, k, i
integer n_shpc ! number of input SHPC directories
real:: corner_deg(2) = [0.125, - 59.875] real:: corner_deg(2) = [0.125, - 59.875]
! longitude and latitude of the corner of the whole grid in input ! longitude and latitude of the corner of the whole grid in input
...@@ -39,10 +40,19 @@ program test_read_snapshot ...@@ -39,10 +40,19 @@ program test_read_snapshot
!------------------------------------------------------------------------- !-------------------------------------------------------------------------
call get_command_arg_dyn(1, shpc_dir, "Required argument: SHPC-directory") n_shpc = COMMAND_ARGUMENT_COUNT()
call assert(n_shpc /= 0, &
"Required arguments: SHPC-directory [SHPC-directory] ...")
allocate(hshp(n_shpc))
do i = 1, n_shpc
call get_command_arg_dyn(i, shpc_dir)
call shpc_open(hshp(i), trim(shpc_dir), pszaccess = "rb")
end do
! Assuming grid_nml.txt is the same in all input SHPC:
call new_unit(unit) call new_unit(unit)
open(unit, file = shpc_dir // "/grid_nml.txt", status = "old", & open(unit, file = hshp(1)%dir // "/grid_nml.txt", status = "old", &
action = "read", position = "rewind") action = "read", position = "rewind")
read(unit, nml = grid_nml) read(unit, nml = grid_nml)
close(unit) close(unit)
...@@ -55,19 +65,20 @@ program test_read_snapshot ...@@ -55,19 +65,20 @@ program test_read_snapshot
"test_read_snapshot dist_lim") "test_read_snapshot dist_lim")
copy = merge(dist_lim, 0, periodic) copy = merge(dist_lim, 0, periodic)
call shpc_open(hshp, trim(shpc_dir), pszaccess = "rb")
! main_nml: ! main_nml:
k = hshp%d0 k = hshp(1)%d0
write(unit = error_unit, nml = main_nml) write(unit = error_unit, nml = main_nml)
write(unit = error_unit, fmt = *) "Enter namelist main_nml." write(unit = error_unit, fmt = *) "Enter namelist main_nml."
read(unit = *, nml = main_nml) read(unit = *, nml = main_nml)
write(unit = *, nml = main_nml) write(unit = *, nml = main_nml)
call read_snapshot(s, [hshp], nlon, nlat, k, & call read_snapshot(s, hshp, nlon, nlat, k, &
corner = corner_deg * deg_to_rad, step = step_deg * deg_to_rad, & corner = corner_deg * deg_to_rad, step = step_deg * deg_to_rad, &
copy = copy) copy = copy)
CALL shpc_close(hshp)
do i = 1, n_shpc
CALL shpc_close(hshp(i))
end do
call write_snapshot(s, corner_deg, step_deg, nlon, nlat, copy, k) call write_snapshot(s, corner_deg, step_deg, nlon, nlat, copy, k)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment