From 796219d30e4e67984d95607a1c565ca1ac54c966 Mon Sep 17 00:00:00 2001 From: Lionel GUEZ <guez@lmd.ens.fr> Date: Tue, 26 Jul 2022 13:31:05 +0200 Subject: [PATCH] Read date from a namelist in program `inst_eddies` --- Inst_eddies/Tests/long_tests.json | 6 +++--- Inst_eddies/Tests/short_tests.json | 8 ++++---- Inst_eddies/inst_eddies.f90 | 8 +++++--- Inst_eddies/inst_eddies.py.in | 4 ++-- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Inst_eddies/Tests/long_tests.json b/Inst_eddies/Tests/long_tests.json index c24c09bd..ea8f7c77 100644 --- a/Inst_eddies/Tests/long_tests.json +++ b/Inst_eddies/Tests/long_tests.json @@ -26,7 +26,7 @@ ["$src_dir/Inst_eddies/Tests/Input/uv_region_3.nc", "uv.nc"] ], "create_file": ["main_nml.txt", "&main_nml min_amp = 0./\n"], - "input": "20454\n", + "input": "&dates_nml date = 20454/\n", "description": "Larger region, 120 x 120. Includes degenerate extrema." }, { @@ -42,7 +42,7 @@ ["$src_dir/Inst_eddies/Tests/Input/uv_region_3.nc", "uv.nc"] ], "create_file": ["main_nml.txt", "&main_nml /\n"], - "input": "20454\n", + "input": "&dates_nml date = 20454/\n", "description": "Same as Extraction_eddies_region_3 except with 1 mm minimum amplitude." }, @@ -59,7 +59,7 @@ ["$src_dir/Inst_eddies/Tests/Input/uv_region_5.nc", "uv.nc"] ], "create_file": ["main_nml.txt", "&main_nml /\n"], - "input": "20454\n", + "input": "&dates_nml date = 20454/\n", "description": "Same as Extraction_eddies_region_4 with larger domain." }, { diff --git a/Inst_eddies/Tests/short_tests.json b/Inst_eddies/Tests/short_tests.json index b694ce08..adad7bac 100644 --- a/Inst_eddies/Tests/short_tests.json +++ b/Inst_eddies/Tests/short_tests.json @@ -311,7 +311,7 @@ }, { "create_file": ["main_nml.txt", "&main_nml min_amp = 0./\n"], - "input": "20454\n", + "input": "&dates_nml date = 20454/\n", "symlink": [ [ "$src_dir/Inst_eddies/Tests/Input/Region_1/huv_region_1_2006_01_01.nc", @@ -332,7 +332,7 @@ "description": "Same as Extraction_eddies_region_1 but with non-zero minimal amplitude.", "create_file": ["main_nml.txt", "&main_nml /\n"], - "input": "20454\n", + "input": "&dates_nml date = 20454/\n", "symlink": [ [ @@ -352,7 +352,7 @@ }, { "create_file": ["main_nml.txt", "&main_nml min_amp = 0./\n"], - "input": "20454\n", + "input": "&dates_nml date = 20454/\n", "symlink": [ ["$src_dir/Inst_eddies/Tests/Input/h_region_2.nc", "h.nc"], ["$src_dir/Inst_eddies/Tests/Input/uv_region_2.nc", "uv.nc"] @@ -438,7 +438,7 @@ "main_nml.txt", "&main_nml min_amp = 0., MAX_RADIUS_deg = 80., 72./\n" ], - "input": "20454\n", + "input": "&dates_nml date = 20454/\n", "symlink": [ [ "$src_dir/Inst_eddies/Tests/Input/h_2006_01_01_coarse.nc", diff --git a/Inst_eddies/inst_eddies.f90 b/Inst_eddies/inst_eddies.f90 index 4c28beb2..4bf367db 100644 --- a/Inst_eddies/inst_eddies.f90 +++ b/Inst_eddies/inst_eddies.f90 @@ -24,7 +24,7 @@ program inst_eddies type(snapshot) s TYPE(shpc_slice_handler) hshpc_cyclo, hshpc_anti - integer i, date, iostat + integer i, iostat integer unit integer nlon, nlat @@ -60,6 +60,8 @@ program inst_eddies logical exist real t0, t1 ! CPU times, in s + integer:: date = 0 + namelist /dates_nml/ date !-------------------------------------------------------------- @@ -78,8 +80,8 @@ program inst_eddies "inst_eddies: not enough IEEE support") inquire(file = "SHPC_cyclo/extremum.shp", exist = exist) call config(exist) ! We need main_nml before looking at the input files. - print *, "date = ?" - read *, date + print *, "inst_eddies: Enter dates_nml:" + read(unit = *, nml = dates_nml) call input_ssh(corner, step, nlon, nlat, periodic, ssh, u, v, corner_deg, & step_deg) diff --git a/Inst_eddies/inst_eddies.py.in b/Inst_eddies/inst_eddies.py.in index 1148e8fc..ad8a5e5c 100644 --- a/Inst_eddies/inst_eddies.py.in +++ b/Inst_eddies/inst_eddies.py.in @@ -66,8 +66,8 @@ def loop_inst_eddies(files, bbox, d): os.symlink("unpacked.nc", "uv.nc") elapsed_NCO = time.perf_counter() - my_pc my_pc = time.perf_counter() - subprocess.run(inst_eddies_exe, check = True, input = str(d) + "\n", - text = True) + subprocess.run(inst_eddies_exe, check = True, input = "&dates_nml " + f"date = {d}/\n", text = True) elapsed_Fortran = time.perf_counter() - my_pc os.remove("h.nc") os.remove("uv.nc") -- GitLab