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

In program test_good_contour, choose more general default values of

namelist input. Also, choose name of primary NetCDF variable in
namelist and read only this variable, not its coordinates. This makes
it easier to use an arbitrary NetCDF file.

In program test_set_outermost_contour, it is hard to remember the
order of positional arguments so we rather use fixed input file names
and no arguments.

In JSON input file for tests, it is simpler to use the "input" key
than creating a one-line input file, in some cases.
parent 7d99eff6
No related branches found
No related tags found
No related merge requests found
&main_nml /
1e-3
0.
&MAIN_NML
INSIDE_POINT=-0.7,0
LEVEL=5
STEP=2*0.08
CORNER=-2,-2 /
&MAIN_NML INSIDE_POINT=0.3,0,
LEVEL=5
corner = -2., -2., step = 0.08, 0.08 /
&MAIN_NML corner = -2., -2., step = 0.08, 0.08 /
! Case where one of the contours tested does not contain inside point.
&MAIN_NML INSIDE_POINT=0.3,0, corner = -2., -2., step = 0.08, 0.08/
&MAIN_NML LEVEL= 5, corner = -2., -2., step = 0.08, 0.08 /
! Case where there is no good contour
&MAIN_NML INSIDE_POINT=0.,0. /
...@@ -3,10 +3,9 @@ ...@@ -3,10 +3,9 @@
"""Plots outermost contours and max-speed contours. """Plots outermost contours and max-speed contours.
Red for anti-cyclones, blue for cyclones. Squares for an outermost Red for anti-cyclones, blue for cyclones. Squares for an outermost
contour of insufficient amplitudes. Crosses for an outermost contour contour of insufficient amplitude. Crosses for an outermost contour of
of sufficient amplitude but with no associated max-speed sufficient amplitude but with no associated max-speed contour. Filled
contour. Filled circles for sufficient amplitude with max-speed circles for sufficient amplitude with max-speed contour.
contour.
""" """
......
...@@ -4,8 +4,8 @@ program test_good_contour ...@@ -4,8 +4,8 @@ program test_good_contour
use good_contour_m, only: good_contour use good_contour_m, only: good_contour
use jumble, only: new_unit, count_lines use jumble, only: new_unit, count_lines
use netcdf, only: nf90_nowrite use netcdf, only: nf90_nowrite
use netcdf95, only: nf95_open, nf95_inq_dimid, nf95_inquire_dimension, & use netcdf95, only: nf95_open, nf95_inquire_dimension, nf95_get_var, &
nf95_get_var, nf95_inq_varid, nf95_close nf95_inq_varid, nf95_close, nf95_inquire_variable
use nr_util, only: assert use nr_util, only: assert
use shapelib, only: shpt_polygon, shpfileobject, ftdouble, shpclose use shapelib, only: shpt_polygon, shpfileobject, ftdouble, shpclose
use shapelib_03, only: shp_create_03, dbf_add_field_03, & use shapelib_03, only: shp_create_03, dbf_add_field_03, &
...@@ -16,17 +16,19 @@ program test_good_contour ...@@ -16,17 +16,19 @@ program test_good_contour
character(len = :), allocatable:: filename character(len = :), allocatable:: filename
integer nx, ny, n_out, i integer nx, ny, n_out, i
type(polyline) c type(polyline) c
real:: level = 5. real:: level = 0.
real, allocatable:: Z(:, :) real, allocatable:: Z(:, :)
real:: inside_point(2) = [- 0.7, 0.] real:: inside_point(2) = [0., 0.]
real, allocatable:: outside_points(:, :) ! (2, n_out) real, allocatable:: outside_points(:, :) ! (2, n_out)
real:: step(2) = [0.04363323129985824, 0.04363323129985824] ! in rad real:: step(2) = [1., 1.]
real:: corner(2) = [0.002181662, - 0.72213] ! in rad real:: corner(2) = [1., 1.]
TYPE(shpfileobject) shphandle TYPE(shpfileobject) shphandle
integer field_number, shape_number integer field_number, shape_number
integer length, status, ncid, varid, dimid, unit integer length, status, ncid, varid, unit
integer, allocatable:: dimids(:)
character(len = 10):: varname = "z"
namelist /main_nml/ inside_point, level, step, corner namelist /main_nml/ inside_point, level, step, corner, varname
!------------------------------------------------------------------- !-------------------------------------------------------------------
...@@ -35,27 +37,23 @@ program test_good_contour ...@@ -35,27 +37,23 @@ program test_good_contour
allocate(character(len = length):: filename) allocate(character(len = length):: filename)
call get_command_argument(1, filename) call get_command_argument(1, filename)
write(unit = *, nml = main_nml)
print *, "Enter namelist main_nml."
read(unit = *, nml = main_nml)
write(unit = *, nml = main_nml)
print *, "Reading from ", filename, "..." print *, "Reading from ", filename, "..."
call nf95_open(filename, nf90_nowrite, ncid) call nf95_open(filename, nf90_nowrite, ncid)
call nf95_inq_varid(ncid, varname, varid)
call nf95_inq_dimid(ncid, "x", dimid) ! Assume ndims >= 2 and take the first 2D slice:
call nf95_inquire_dimension(ncid, dimid, nclen = nx) call nf95_inquire_variable(ncid, varid, dimids = dimids)
call nf95_inquire_dimension(ncid, dimids(1), nclen = nx)
call nf95_inq_dimid(ncid, "y", dimid) call nf95_inquire_dimension(ncid, dimids(2), nclen = ny)
call nf95_inquire_dimension(ncid, dimid, nclen = ny)
allocate(z(nx, ny)) allocate(z(nx, ny))
call nf95_inq_varid(ncid, "z", varid)
call nf95_get_var(ncid, varid, z) call nf95_get_var(ncid, varid, z)
call nf95_close(ncid) call nf95_close(ncid)
write(unit = *, nml = main_nml)
print *, "Enter namelist main_nml."
read(unit = *, nml = main_nml)
write(unit = *, nml = main_nml)
print *, 'Reading from "outside_points.csv"...' print *, 'Reading from "outside_points.csv"...'
call new_unit(unit) call new_unit(unit)
open(unit, file = "outside_points.csv", status = "old", action = "read", & open(unit, file = "outside_points.csv", status = "old", action = "read", &
......
[ [
{ {
"stdin" : "$stdin_dir/good_contour_nml_1.txt", "stdin" : "$stdin_dir/good_contour.txt",
"args" : ["$compil_prod_dir/test_good_contour", "args" : ["$compil_prod_dir/test_good_contour",
"$input_dir/example.nc"], "$input_dir/example.nc"],
"title" : "Good_contour", "title" : "Good_contour",
...@@ -8,15 +8,15 @@ ...@@ -8,15 +8,15 @@
"description": "3 contours at that level. 2 contain the inside point, one of which contains the 2 outside points." "description": "3 contours at that level. 2 contain the inside point, one of which contains the 2 outside points."
}, },
{ {
"stdin" : "$stdin_dir/good_contour_nml_2.txt", "stdin" : "$stdin_dir/good_contour_2.txt",
"args" : ["$compil_prod_dir/test_good_contour", "args" : ["$compil_prod_dir/test_good_contour",
"$input_dir/example.nc"], "$input_dir/example.nc"],
"title" : "Good_contour_2", "title" : "Good_contour_2",
"required": [["$stdin_dir/outside_points_2.csv", "outside_points.csv"]], "required": [["$stdin_dir/outside_points_2.csv", "outside_points.csv"]],
"description": "Select another good contour." "description": "Select another good contour. Case where one of the contours tested does not contain inside point."
}, },
{ {
"stdin" : "$stdin_dir/no_good_contour_nml.txt", "stdin" : "$stdin_dir/no_good_contour.txt",
"args" : ["$compil_prod_dir/test_good_contour", "args" : ["$compil_prod_dir/test_good_contour",
"$input_dir/example.nc"], "$input_dir/example.nc"],
"title" : "No_good_contour", "title" : "No_good_contour",
...@@ -33,31 +33,31 @@ ...@@ -33,31 +33,31 @@
"title" : "Local_extrema_larger" "title" : "Local_extrema_larger"
}, },
{ {
"args" : ["$compil_prod_dir/test_set_outermost_contour", "args" : "$compil_prod_dir/test_set_outermost_contour",
"$input_dir/h_test_region.nc", "required": [["$input_dir/h_test_region.nc", "h.nc"],
"$tests_old_dir/Local_extrema/test_local_extrema.nc"], ["$tests_old_dir/Local_extrema/test_local_extrema.nc", "extr_map.nc"]],
"title" : "Set_outermost_contour", "title" : "Set_outermost_contour",
"stdin" : "$stdin_dir/default_main_nml.txt" "input" : "&main_nml /\n"
}, },
{ {
"args" : ["$compil_prod_dir/test_set_outermost_contour", "args" : "$compil_prod_dir/test_set_outermost_contour",
"$input_dir/h_test_region.nc", "required": [["$input_dir/h_test_region.nc", "h.nc"],
"$input_dir/extr_map_negative_2_8.nc"], ["$input_dir/extr_map_negative_2_8.nc", "extr_map.nc"]],
"title" : "Set_outermost_contour_noise_2_8", "title" : "Set_outermost_contour_noise_2_8",
"stdin" : "$stdin_dir/default_main_nml.txt" "input" : "&main_nml /\n"
}, },
{ {
"args" : ["$compil_prod_dir/test_set_outermost_contour", "args" : "$compil_prod_dir/test_set_outermost_contour",
"$input_dir/h_test_region.nc", "required": [["$input_dir/h_test_region.nc", "h.nc"],
"$input_dir/extr_map_negative_2.nc"], ["$input_dir/extr_map_negative_2.nc", "extr_map.nc"]],
"title" : "Set_outermost_contour_noise_2", "title" : "Set_outermost_contour_noise_2",
"stdin" : "$stdin_dir/default_main_nml.txt" "input" : "&main_nml /\n"
}, },
{ {
"args" : ["$compil_prod_dir/test_max_speed_contour_ssh", "args" : ["$compil_prod_dir/test_max_speed_contour_ssh",
"$input_dir/h_2006_01_01.nc", "$input_dir/uv_2006_01_01.nc"], "$input_dir/h_2006_01_01.nc", "$input_dir/uv_2006_01_01.nc"],
"title" : "Max_speed_contour_ssh", "title" : "Max_speed_contour_ssh",
"stdin" : "$stdin_dir/default_main_nml.txt" "input" : "&main_nml /\n"
}, },
{ {
"args" : ["$compil_prod_dir/test_max_speed_contour_ssh", "args" : ["$compil_prod_dir/test_max_speed_contour_ssh",
...@@ -70,14 +70,14 @@ ...@@ -70,14 +70,14 @@
"$input_dir/uv_test_region.nc", "$input_dir/uv_test_region.nc",
"$tests_old_dir/Set_outermost_contour/test_set_outermost_contour"], "$tests_old_dir/Set_outermost_contour/test_set_outermost_contour"],
"title" : "Mean_speed", "title" : "Mean_speed",
"stdin" : "$stdin_dir/default_main_nml.txt" "input" : "&main_nml /\n"
}, },
{ {
"args" : ["$compil_prod_dir/test_mean_speed", "args" : ["$compil_prod_dir/test_mean_speed",
"$input_dir/uv_test_region.nc", "$input_dir/uv_test_region.nc",
"$input_dir/outermost_contour_alt"], "$input_dir/outermost_contour_alt"],
"title" : "Mean_speed_alt", "title" : "Mean_speed_alt",
"stdin" : "$stdin_dir/default_main_nml.txt" "input" : "&main_nml /\n"
}, },
{ {
"args": ["$compil_prod_dir/test_set_max_speed", "args": ["$compil_prod_dir/test_set_max_speed",
...@@ -87,7 +87,7 @@ ...@@ -87,7 +87,7 @@
"required": ["$tests_old_dir/Set_outermost_contour/test_set_outermost_contour.shp", "required": ["$tests_old_dir/Set_outermost_contour/test_set_outermost_contour.shp",
"$tests_old_dir/Set_outermost_contour/test_set_outermost_contour.shx", "$tests_old_dir/Set_outermost_contour/test_set_outermost_contour.shx",
"$tests_old_dir/Set_outermost_contour/test_set_outermost_contour.dbf"], "$tests_old_dir/Set_outermost_contour/test_set_outermost_contour.dbf"],
"stdin": "$stdin_dir/default_main_nml.txt" "input" : "&main_nml /\n"
}, },
{ {
"args": ["$compil_prod_dir/test_set_max_speed", "args": ["$compil_prod_dir/test_set_max_speed",
...@@ -105,28 +105,28 @@ ...@@ -105,28 +105,28 @@
"title": "Get_snapshot", "title": "Get_snapshot",
"required": [["$input_dir/h_test_get_snapshot.nc", "h.nc"], "required": [["$input_dir/h_test_get_snapshot.nc", "h.nc"],
["$input_dir/uv_test_get_snapshot.nc", "uv.nc"]], ["$input_dir/uv_test_get_snapshot.nc", "uv.nc"]],
"stdin": "$stdin_dir/get_snaphot_stdin.txt" "input": "0.\n"
}, },
{ {
"args": "$compil_prod_dir/test_get_snapshot", "args": "$compil_prod_dir/test_get_snapshot",
"title": "Get_snapshot_noise", "title": "Get_snapshot_noise",
"required": [["$input_dir/h_test_get_snapshot.nc", "h.nc"], "required": [["$input_dir/h_test_get_snapshot.nc", "h.nc"],
["$input_dir/uv_test_get_snapshot.nc", "uv.nc"]], ["$input_dir/uv_test_get_snapshot.nc", "uv.nc"]],
"stdin": "$stdin_dir/get_snaphot_noise_stdin.txt" "input": "1e-3\n"
}, },
{ {
"args": "$compil_prod_dir/test_get_snapshot", "args": "$compil_prod_dir/test_get_snapshot",
"title": "Get_snapshot_larger", "title": "Get_snapshot_larger",
"required": [["$input_dir/h_test_get_snapshot_larger.nc", "h.nc"], "required": [["$input_dir/h_test_get_snapshot_larger.nc", "h.nc"],
["$input_dir/uv_test_get_snapshot_larger.nc", "uv.nc"]], ["$input_dir/uv_test_get_snapshot_larger.nc", "uv.nc"]],
"stdin": "$stdin_dir/get_snaphot_stdin.txt" "input": "0.\n"
}, },
{ {
"args": "$compil_prod_dir/test_get_snapshot", "args": "$compil_prod_dir/test_get_snapshot",
"title": "Get_snapshot_larger_noise", "title": "Get_snapshot_larger_noise",
"required": [["$input_dir/h_test_get_snapshot_larger.nc", "h.nc"], "required": [["$input_dir/h_test_get_snapshot_larger.nc", "h.nc"],
["$input_dir/uv_test_get_snapshot_larger.nc", "uv.nc"]], ["$input_dir/uv_test_get_snapshot_larger.nc", "uv.nc"]],
"stdin": "$stdin_dir/get_snaphot_noise_stdin.txt" "input": "1e-3\n"
}, },
{ {
"args": ["$compil_prod_dir/test_inside_4", "$input_dir/outermost_5"], "args": ["$compil_prod_dir/test_inside_4", "$input_dir/outermost_5"],
...@@ -143,7 +143,7 @@ ...@@ -143,7 +143,7 @@
"title": "Get_snapshot_120", "title": "Get_snapshot_120",
"required": [["$input_dir/h_comparison_region.nc", "h.nc"], "required": [["$input_dir/h_comparison_region.nc", "h.nc"],
["$input_dir/uv_comparison_region.nc", "uv.nc"]], ["$input_dir/uv_comparison_region.nc", "uv.nc"]],
"stdin": "$stdin_dir/get_snaphot_stdin.txt", "input": "0.\n",
"description": "Larger region, 120 x 120. Includes degenerate extrema." "description": "Larger region, 120 x 120. Includes degenerate extrema."
}, },
{ {
...@@ -151,7 +151,7 @@ ...@@ -151,7 +151,7 @@
"title": "Get_snapshot_120_min", "title": "Get_snapshot_120_min",
"required": [["$input_dir/h_comparison_region.nc", "h.nc"], "required": [["$input_dir/h_comparison_region.nc", "h.nc"],
["$input_dir/uv_comparison_region.nc", "uv.nc"]], ["$input_dir/uv_comparison_region.nc", "uv.nc"]],
"stdin": "$stdin_dir/get_snaphot_noise_stdin.txt", "input": "1e-3\n",
"description": "Same as Get_snapshot_120 except with 1 mm minimum amplitude." "description": "Same as Get_snapshot_120 except with 1 mm minimum amplitude."
} }
] ]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment