From 086d52f5fb7bce35d53b5f39ef3908ccd3def71d Mon Sep 17 00:00:00 2001 From: Lionel GUEZ <guez@lmd.ipsl.fr> Date: Tue, 10 Sep 2024 12:51:01 +0200 Subject: [PATCH] Read periodic in a namelist Preparing to read a second input variable from stdin in procedure `input_ssh`. --- Inst_eddies/Tests/long_tests.json | 8 +++--- Inst_eddies/Tests/short_tests.json | 44 ++++++++++++++++-------------- Inst_eddies/input_ssh.f90 | 6 ++-- Inst_eddies/inst_eddies.py.in | 3 +- 4 files changed, 33 insertions(+), 28 deletions(-) diff --git a/Inst_eddies/Tests/long_tests.json b/Inst_eddies/Tests/long_tests.json index 13abd967..4896757f 100644 --- a/Inst_eddies/Tests/long_tests.json +++ b/Inst_eddies/Tests/long_tests.json @@ -13,7 +13,7 @@ "$src_dir/Inst_eddies/Tests/Input/uv_region_3.nc" ] ], - "input": "&dates_nml date = 1/\n&config_nml min_radius = 20./\nf\n", + "input": "&dates_nml date = 1/\n&config_nml min_radius = 20./\n&input_ssh_nml /\n", "sel_diff_args": {"exclude": ["timings.txt"]} }, "Extraction_eddies_region_3": { @@ -30,7 +30,7 @@ "$src_dir/Inst_eddies/Tests/Input/uv_region_3.nc" ] ], - "input": "&dates_nml date = 20454/\n&config_nml min_amp = 0./\nf\n", + "input": "&dates_nml date = 20454/\n&config_nml min_amp = 0./\n&input_ssh_nml /\n", "description": "Larger region, 120 x 120. Includes degenerate extrema.", "sel_diff_args": {"exclude": ["timings.txt"]} }, @@ -48,7 +48,7 @@ "$src_dir/Inst_eddies/Tests/Input/uv_region_3.nc" ] ], - "input": "&dates_nml date = 20454/\n&config_nml /\nf\n", + "input": "&dates_nml date = 20454/\n&config_nml /\n&input_ssh_nml /\n", "description": "Same as Extraction_eddies_region_3 except with 1 mm minimum amplitude.", "sel_diff_args": {"exclude": ["timings.txt"]} }, @@ -68,7 +68,7 @@ "mv grid_nml.txt SHPC" ], "main_command": 1, - "input": "&dates_nml date = 20454/\n&config_nml /\nf\n", + "input": "&dates_nml date = 20454/\n&config_nml /\n&input_ssh_nml /\n", "description": "Same as Extraction_eddies_region_4 with larger domain.", "sel_diff_args": {"exclude": ["n_slices.txt", "timings.txt"]} }, diff --git a/Inst_eddies/Tests/short_tests.json b/Inst_eddies/Tests/short_tests.json index 2b6ca78c..21e1258d 100644 --- a/Inst_eddies/Tests/short_tests.json +++ b/Inst_eddies/Tests/short_tests.json @@ -1,6 +1,7 @@ { "Extraction_eddies_region_1_noise": { - "input": "&dates_nml date = 20454/\n&config_nml /\nf\n", + "input": + "&dates_nml date = 20454/\n&config_nml /\n&input_ssh_nml /\n", "commands": [ [ "mkdir", @@ -27,13 +28,14 @@ ] ], "input": - "&config_nml /\nf\n&MAIN_NML DATE = 20454 EDDY_I_TARGET = 3/\n", + "&config_nml /\n&input_ssh_nml /\n&MAIN_NML DATE = 20454 EDDY_I_TARGET = 3/\n", "description": "The file outside_points created by this test is used in other tests." }, "Get_1_outerm": { "description": "Target eddy is cyclone number 3 in test Extraction_eddies_region_1_noise.", - "input": "&main_nml date = 20454/\n&config_nml /\nf\n", + "input": + "&main_nml date = 20454/\n&config_nml /\n&input_ssh_nml /\n", "symlink": ["$tests_old_dir/Region_1_20454_cyclone_3/outside_points.csv"], "commands": [ @@ -48,7 +50,8 @@ }, "Get_1_outerm_noise_2_8": { "description": "Same as test Get_1_outerm except that we have changed outside points: we have removed cyclone 4 in test Extraction_eddies_region_1_noise. We just want to see the target extremum grow its outermost contour.", - "input": "&main_nml date = 20454/\n&config_nml /\nf\n", + "input": + "&main_nml date = 20454/\n&config_nml /\n&input_ssh_nml /\n", "symlink": ["$src_dir/Inst_eddies/Tests/Input/Region_1/outside_points.csv"], "commands": [ @@ -142,7 +145,7 @@ ] }, "Mean_speed": { - "input": "&config_nml /\nf\n&main_nml /\n", + "input": "&config_nml /\n&input_ssh_nml /\n&main_nml /\n", "commands": [ "mkdir -p SHPC", @@ -155,7 +158,7 @@ ] }, "Mean_speed_alt": { - "input": "&config_nml /\nf\n&main_nml /\n", + "input": "&config_nml /\n&input_ssh_nml /\n&main_nml /\n", "commands": [ "mkdir -p SHPC", @@ -183,7 +186,7 @@ "$tests_old_dir/Get_1_outerm/cont_list_proj.shp" ] ], - "input": "t\n&config_nml /\nf\n", + "input": "t\n&config_nml /\n&input_ssh_nml /\n", "sel_diff_args": {"exclude": ["n_slices.txt"]} }, "Set_max_speed_noise": { @@ -198,7 +201,7 @@ "$tests_old_dir/Get_1_outerm_noise_2_8/cont_list_proj.shp" ] ], - "input": "t\n&config_nml /\nf\n", + "input": "t\n&config_nml /\n&input_ssh_nml /\n", "sel_diff_args": {"exclude": ["n_slices.txt"]} }, "SHPC_degenerate": @@ -213,7 +216,7 @@ ] ], "input": - "&MAIN_NML IND_TARG_EXTR = 5 3 INNERMOST_LEVEL = -1.2629 CYCLONE = f date = 15780/\n&config_nml /\nf\n", + "&MAIN_NML IND_TARG_EXTR = 5 3 INNERMOST_LEVEL = -1.2629 CYCLONE = f date = 15780/\n&config_nml /\n&input_ssh_nml /\n", "description": "This test is only useful to create input for test Set_max_speed_degenerate. Namelist values were obtained with test_local_extrema." }, "Set_max_speed_degenerate": { @@ -233,11 +236,12 @@ "$tests_old_dir/SHPC_degenerate/cont_list_proj.shp" ] ], - "input": "f\n&config_nml /\nf\n", + "input": "f\n&config_nml /\n&input_ssh_nml /\n", "sel_diff_args": {"exclude": ["n_slices.txt"]} }, "Extraction_eddies_region_2": { - "input": "&dates_nml date = 20454/\n&config_nml min_amp = 0./\nf\n", + "input": + "&dates_nml date = 20454/\n&config_nml min_amp = 0./\n&input_ssh_nml /\n", "commands": [ [ "mkdir", @@ -316,7 +320,7 @@ "Set_all_outerm_periodic": { "description": "inst_eddies with periodicity.", "input": - "&dates_nml date = 1/\n&config_nml MAX_RADIUS = 4, 4, min_radius = 20./\nt\n", + "&dates_nml date = 1/\n&config_nml MAX_RADIUS = 4, 4, min_radius = 20./\n&input_ssh_nml periodic=t/\n", "commands": [ [ "mkdir", @@ -335,7 +339,7 @@ "Extraction_eddies_periodic": { "description": "Periodic domain.", "input": - "&dates_nml date = 20454/\n&config_nml min_amp = 0., MAX_RADIUS = 4, 4/\nt\n", + "&dates_nml date = 20454/\n&config_nml min_amp = 0., MAX_RADIUS = 4, 4/\n&input_ssh_nml periodic=t/\n", "commands": [ [ "mkdir", @@ -356,7 +360,7 @@ "Extr_proj": { "description": "Create shapefile extr_proj.", "input": - "&main_nml date = 20454, grid_lon_lat = f/\n&config_nml /\nf\n", + "&main_nml date = 20454, grid_lon_lat = f/\n&config_nml /\n&input_ssh_nml /\n", "symlink": ["$tests_old_dir/Region_1_20454_cyclone_3/outside_points.csv"], "commands": [ @@ -405,7 +409,7 @@ ] ], "input": - "&config_nml /\nf\n&MAIN_NML DATE = 20456 EDDY_I_TARGET = 3/\n", + "&config_nml /\n&input_ssh_nml /\n&MAIN_NML DATE = 20456 EDDY_I_TARGET = 3/\n", "description": "This eddy is interesting because the maximum speed is a little lower (relative difference # 1e-3) than in version v0.26. SSH on maximum speed contour differs by about 2e-3 m from version v0.26. There are n_max_cont in cont_list." }, "Exam_eddy_outer": @@ -425,7 +429,7 @@ ] ], "input": - "&config_nml /\nf\n&MAIN_NML CYCLONE = f DATE = 20465 EDDY_I_TARGET = 12/\n", + "&config_nml /\n&input_ssh_nml /\n&MAIN_NML CYCLONE = f DATE = 20465 EDDY_I_TARGET = 12/\n", "description": "This eddy is interesting because the maximum speed is on the outermost contour, while in version v0.26, we found a slightly better maximum speed contour." }, "Exam_eddy_double": @@ -445,7 +449,7 @@ ] ], "input": - "&config_nml /\nf\n&MAIN_NML CYCLONE = f DATE = 20456 EDDY_I_TARGET = 48/\n", + "&config_nml /\n&input_ssh_nml /\n&MAIN_NML CYCLONE = f DATE = 20456 EDDY_I_TARGET = 48/\n", "description": "This eddy is interesting because the profile of speed versus ssh has two maxima and the maximum selected by master is not the same than the maximum selected in v0.26." }, "Proj_coord": @@ -463,7 +467,7 @@ ] ], "input": - "&config_nml /\nf\n&MAIN_NML CYCLONE=f DATE = 20454 EDDY_I_TARGET = 55/\n" + "&config_nml /\n&input_ssh_nml /\n&MAIN_NML CYCLONE=f DATE = 20454 EDDY_I_TARGET = 55/\n" }, "Speed_proj": { @@ -479,13 +483,13 @@ ] ], "input": - "&config_nml /\nf\n&MAIN_NML CYCLONE=f DATE=20454 EDDY_I_TARGET=3/\n" + "&config_nml /\n&input_ssh_nml /\n&MAIN_NML CYCLONE=f DATE=20454 EDDY_I_TARGET=3/\n" }, "Test_INALT60": { "description": "First test with non-uniform grid.", "input": - "&dates_nml /\n&config_nml min_radius=2.5 max_radius=150,150 /\nf\n", + "&dates_nml /\n&config_nml min_radius=2.5 max_radius=150,150 /\n&input_ssh_nml /\n", "commands": [ [ "mkdir", diff --git a/Inst_eddies/input_ssh.f90 b/Inst_eddies/input_ssh.f90 index 043b630d..2bda5ece 100644 --- a/Inst_eddies/input_ssh.f90 +++ b/Inst_eddies/input_ssh.f90 @@ -53,6 +53,7 @@ contains real lon_max, lat_max ! longitude and latitude, in degrees integer copy namelist /grid_nml/ corner_deg, step_deg, nlon, nlat, periodic + namelist /input_ssh_nml/ periodic !---------------------------------------------------------------------- @@ -76,8 +77,9 @@ contains write(unit, nml = grid_nml) close(unit) step = step_deg * deg_to_rad - print *, "input_ssh: periodic = ?" - read *, periodic + periodic = .false. ! default value + print *, "input_ssh: Enter input_ssh_nml:" + read(unit = *, nml = input_ssh_nml) if (periodic) call assert(4 * max_radius(1) < nlon, "input_ssh: max_radius") copy = merge(max_radius(1), 0, periodic) allocate(ssh(1 - copy:nlon + copy, nlat), u(1 - copy:nlon + copy, nlat), & diff --git a/Inst_eddies/inst_eddies.py.in b/Inst_eddies/inst_eddies.py.in index 90a130e8..9206649d 100644 --- a/Inst_eddies/inst_eddies.py.in +++ b/Inst_eddies/inst_eddies.py.in @@ -57,8 +57,7 @@ def process_1_file( check=True, input=f"&dates_nml date = {d}, slice = {my_slice}/\n" + config_nml_string - + periodic - + "\n", + + f"&input_ssh_nml periodic = {periodic}/\n", text=True, ) elapsed_Fortran = time.perf_counter() - t0 -- GitLab