diff --git a/unit_tests/namelist_unit_test_offset.bdy b/unit_tests/namelist_unit_test_offset.bdy new file mode 100644 index 0000000000000000000000000000000000000000..b11b850c0cf00705fd82741e8704412ad45f4607 --- /dev/null +++ b/unit_tests/namelist_unit_test_offset.bdy @@ -0,0 +1,109 @@ +!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +!! NEMO/OPA : namelist for BDY generation tool +!! +!! User inputs for generating open boundary conditions +!! employed by the BDY module in NEMO. Boundary data +!! can be set up for v3.2 NEMO and above. +!! +!! More info here..... +!! +!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + +!------------------------------------------------------------------------------ +! vertical coordinate +!------------------------------------------------------------------------------ + ln_zco = .false. ! z-coordinate - full steps (T/F) + ln_zps = .true. ! z-coordinate - partial steps (T/F) + ln_sco = .false. ! s- or hybrid z-s-coordinate (T/F) + rn_hmin = -10 ! min depth of the ocean (>0) or + ! min number of ocean level (<0) + +!------------------------------------------------------------------------------ +! s-coordinate or hybrid z-s-coordinate +!------------------------------------------------------------------------------ + rn_sbot_min = 10. ! minimum depth of s-bottom surface (>0) (m) + rn_sbot_max = 7000. ! maximum depth of s-bottom surface + ! (= ocean depth) (>0) (m) + ln_s_sigma = .false. ! hybrid s-sigma coordinates + rn_hc = 150.0 ! critical depth with s-sigma + +!------------------------------------------------------------------------------ +! grid information +!------------------------------------------------------------------------------ + sn_src_hgr = '/Users/thopri/Projects/PyNEMO/unit_tests/test_data/test_src_hgr_zps.nc' + sn_src_zgr = '/Users/thopri/Projects/PyNEMO/unit_tests/test_data/test_src_zgr_zps.nc' + sn_dst_hgr = '/Users/thopri/Projects/PyNEMO/unit_tests/test_data/test_offset_dst_hgr_zps.nc' + sn_dst_zgr = '/Users/thopri/Projects/PyNEMO/unit_tests/test_data/test_offset_dst_zgr_zps.nc' + sn_src_msk = '/Users/thopri/Projects/PyNEMO/unit_tests/test_data/mask.nc' + sn_bathy = '/Users/thopri/Projects/PyNEMO/unit_tests/test_data/test_offset_dst_bathy.nc' + +!------------------------------------------------------------------------------ +! I/O +!------------------------------------------------------------------------------ + sn_src_dir = '/Users/thopri/Projects/PyNEMO/unit_tests/src_data_unit_tests.ncml' ! src_files/' + sn_dst_dir = '/Users/thopri/Projects/PyNEMO/unit_tests/test_outputs' + sn_fn = 'unit_test_offset' ! prefix for output files + nn_fv = -1e20 ! set fill value for output files + nn_src_time_adj = 0 ! src time adjustment + sn_dst_metainfo = 'Unit Test Data' + +!------------------------------------------------------------------------------ +! CMEMS Data Source Configuration +!------------------------------------------------------------------------------ + ln_use_cmems = .true. + +!------------------------------------------------------------------------------ +! unstructured open boundaries +!------------------------------------------------------------------------------ + ln_coords_file = .true. ! =T : produce bdy coordinates files + cn_coords_file = 'coordinates.bdy.nc' ! name of bdy coordinates files + ! (if ln_coords_file=.TRUE.) + ln_mask_file = .false. ! =T : read mask from file + cn_mask_file = 'mask.nc' ! name of mask file + ! (if ln_mask_file=.TRUE.) + ln_dyn2d = .false. ! boundary conditions for + ! barotropic fields + ln_dyn3d = .false. ! boundary conditions for + ! baroclinic velocities + ln_tra = .true. ! boundary conditions for T and S + ln_ice = .false. ! ice boundary condition + nn_rimwidth = 9 ! width of the relaxation zone + +!------------------------------------------------------------------------------ +! unstructured open boundaries tidal parameters +!------------------------------------------------------------------------------ + ln_tide = .false. ! =T : produce bdy tidal conditions + sn_tide_model = 'FES' ! Name of tidal model (FES|TPXO) + clname(1) = 'M2' ! constituent name + clname(2) = 'S2' + clname(3) = 'K2' + ln_trans = .true. ! interpolate transport rather than + ! velocities +!------------------------------------------------------------------------------ +! Time information +!------------------------------------------------------------------------------ + nn_year_000 = 2017 ! year start + nn_year_end = 2017 ! year end + nn_month_000 = 01 ! month start (default = 1 is years>1) + nn_month_end = 01 ! month end (default = 12 is years>1) + sn_dst_calendar = 'gregorian' ! output calendar format + nn_base_year = 1960 ! base year for time counter + sn_tide_grid = './src_data/tide/grid_tpxo7.2.nc' + sn_tide_h = './src_data/tide/h_tpxo7.2.nc' + sn_tide_u = './src_data/tide/u_tpxo7.2.nc' + +!------------------------------------------------------------------------------ +! Additional parameters +!------------------------------------------------------------------------------ + nn_wei = 1 ! smoothing filter weights + rn_r0 = 0.041666666 ! decorrelation distance use in gauss + ! smoothing onto dst points. Need to + ! make this a funct. of dlon + sn_history = 'Benchmarking test case' + ! history for netcdf file + ln_nemo3p4 = .true. ! else presume v3.2 or v3.3 + nn_alpha = 0 ! Euler rotation angle + nn_beta = 0 ! Euler rotation angle + nn_gamma = 0 ! Euler rotation angle + rn_mask_max_depth = 100.0 ! Maximum depth to be ignored for the mask + rn_mask_shelfbreak_dist = 20000.0 ! Distance from the shelf break diff --git a/unit_tests/namelist_unit_test.bdy b/unit_tests/namelist_unit_test_orth.bdy similarity index 97% rename from unit_tests/namelist_unit_test.bdy rename to unit_tests/namelist_unit_test_orth.bdy index d07f1db37789c52733acaa51856723bec50485e4..b1df9ab5eec3febf9800c277591f3c5691ef4611 100644 --- a/unit_tests/namelist_unit_test.bdy +++ b/unit_tests/namelist_unit_test_orth.bdy @@ -42,7 +42,7 @@ !------------------------------------------------------------------------------ sn_src_dir = '/Users/thopri/Projects/PyNEMO/unit_tests/src_data_unit_tests.ncml' ! src_files/' sn_dst_dir = '/Users/thopri/Projects/PyNEMO/unit_tests/test_outputs' - sn_fn = 'unit_test' ! prefix for output files + sn_fn = 'unit_test_orth' ! prefix for output files nn_fv = -1e20 ! set fill value for output files nn_src_time_adj = 0 ! src time adjustment sn_dst_metainfo = 'Unit Test Data' diff --git a/unit_tests/namelist_unit_test_rotated.bdy b/unit_tests/namelist_unit_test_rotated.bdy new file mode 100644 index 0000000000000000000000000000000000000000..063affb9b3cc076275e46dfe34f0959c16ff0da5 --- /dev/null +++ b/unit_tests/namelist_unit_test_rotated.bdy @@ -0,0 +1,109 @@ +!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +!! NEMO/OPA : namelist for BDY generation tool +!! +!! User inputs for generating open boundary conditions +!! employed by the BDY module in NEMO. Boundary data +!! can be set up for v3.2 NEMO and above. +!! +!! More info here..... +!! +!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + +!------------------------------------------------------------------------------ +! vertical coordinate +!------------------------------------------------------------------------------ + ln_zco = .false. ! z-coordinate - full steps (T/F) + ln_zps = .true. ! z-coordinate - partial steps (T/F) + ln_sco = .false. ! s- or hybrid z-s-coordinate (T/F) + rn_hmin = -10 ! min depth of the ocean (>0) or + ! min number of ocean level (<0) + +!------------------------------------------------------------------------------ +! s-coordinate or hybrid z-s-coordinate +!------------------------------------------------------------------------------ + rn_sbot_min = 10. ! minimum depth of s-bottom surface (>0) (m) + rn_sbot_max = 7000. ! maximum depth of s-bottom surface + ! (= ocean depth) (>0) (m) + ln_s_sigma = .false. ! hybrid s-sigma coordinates + rn_hc = 150.0 ! critical depth with s-sigma + +!------------------------------------------------------------------------------ +! grid information +!------------------------------------------------------------------------------ + sn_src_hgr = '/Users/thopri/Projects/PyNEMO/unit_tests/test_data/test_src_hgr_zps.nc' + sn_src_zgr = '/Users/thopri/Projects/PyNEMO/unit_tests/test_data/test_src_zgr_zps.nc' + sn_dst_hgr = '/Users/thopri/Projects/PyNEMO/unit_tests/test_data/test_rot_dst_hgr_zps.nc' + sn_dst_zgr = '/Users/thopri/Projects/PyNEMO/unit_tests/test_data/test_rot_dst_zgr_zps.nc' + sn_src_msk = '/Users/thopri/Projects/PyNEMO/unit_tests/test_data/mask.nc' + sn_bathy = '/Users/thopri/Projects/PyNEMO/unit_tests/test_data/test_rot_dst_bathy.nc' + +!------------------------------------------------------------------------------ +! I/O +!------------------------------------------------------------------------------ + sn_src_dir = '/Users/thopri/Projects/PyNEMO/unit_tests/src_data_unit_tests.ncml' ! src_files/' + sn_dst_dir = '/Users/thopri/Projects/PyNEMO/unit_tests/test_outputs' + sn_fn = 'unit_test_rotated' ! prefix for output files + nn_fv = -1e20 ! set fill value for output files + nn_src_time_adj = 0 ! src time adjustment + sn_dst_metainfo = 'Unit Test Data' + +!------------------------------------------------------------------------------ +! CMEMS Data Source Configuration +!------------------------------------------------------------------------------ + ln_use_cmems = .true. + +!------------------------------------------------------------------------------ +! unstructured open boundaries +!------------------------------------------------------------------------------ + ln_coords_file = .true. ! =T : produce bdy coordinates files + cn_coords_file = 'coordinates.bdy.nc' ! name of bdy coordinates files + ! (if ln_coords_file=.TRUE.) + ln_mask_file = .false. ! =T : read mask from file + cn_mask_file = 'mask.nc' ! name of mask file + ! (if ln_mask_file=.TRUE.) + ln_dyn2d = .false. ! boundary conditions for + ! barotropic fields + ln_dyn3d = .false. ! boundary conditions for + ! baroclinic velocities + ln_tra = .true. ! boundary conditions for T and S + ln_ice = .false. ! ice boundary condition + nn_rimwidth = 9 ! width of the relaxation zone + +!------------------------------------------------------------------------------ +! unstructured open boundaries tidal parameters +!------------------------------------------------------------------------------ + ln_tide = .false. ! =T : produce bdy tidal conditions + sn_tide_model = 'FES' ! Name of tidal model (FES|TPXO) + clname(1) = 'M2' ! constituent name + clname(2) = 'S2' + clname(3) = 'K2' + ln_trans = .true. ! interpolate transport rather than + ! velocities +!------------------------------------------------------------------------------ +! Time information +!------------------------------------------------------------------------------ + nn_year_000 = 2017 ! year start + nn_year_end = 2017 ! year end + nn_month_000 = 01 ! month start (default = 1 is years>1) + nn_month_end = 01 ! month end (default = 12 is years>1) + sn_dst_calendar = 'gregorian' ! output calendar format + nn_base_year = 1960 ! base year for time counter + sn_tide_grid = './src_data/tide/grid_tpxo7.2.nc' + sn_tide_h = './src_data/tide/h_tpxo7.2.nc' + sn_tide_u = './src_data/tide/u_tpxo7.2.nc' + +!------------------------------------------------------------------------------ +! Additional parameters +!------------------------------------------------------------------------------ + nn_wei = 1 ! smoothing filter weights + rn_r0 = 0.041666666 ! decorrelation distance use in gauss + ! smoothing onto dst points. Need to + ! make this a funct. of dlon + sn_history = 'Benchmarking test case' + ! history for netcdf file + ln_nemo3p4 = .true. ! else presume v3.2 or v3.3 + nn_alpha = 0 ! Euler rotation angle + nn_beta = 0 ! Euler rotation angle + nn_gamma = 0 ! Euler rotation angle + rn_mask_max_depth = 100.0 ! Maximum depth to be ignored for the mask + rn_mask_shelfbreak_dist = 20000.0 ! Distance from the shelf break diff --git a/unit_tests/test_gen.py b/unit_tests/test_gen.py index f7825cff442b98ba77f0f2df6cdaa4a13af77236..ade8acfe64e08b6d071e881b41ce15d812a28d75 100644 --- a/unit_tests/test_gen.py +++ b/unit_tests/test_gen.py @@ -100,8 +100,8 @@ def _main(): print("Success!") # plot orginal, rotatated and source lat and lon - gt.plot_grids(grid_h2['latt'],grid_h2['lont'],grid_rot['latt'],grid_rot['lont'],grid_h3['latt'], \ - grid_h3['lont'],grid_h1['latt'],grid_h1['lont']) + #gt.plot_grids(grid_h2['latt'],grid_h2['lont'],grid_rot['latt'],grid_rot['lont'],grid_h3['latt'], \ + # grid_h3['lont'],grid_h1['latt'],grid_h1['lont']) # write boundary files (constant parameters) out_fname = 'unit_tests/test_data/output_boundary_T.nc' diff --git a/unit_tests/unit_test.py b/unit_tests/unit_test.py index 7757c488d16b2a11d00ef6812bfb356b7e37845f..84fbbf37c9e6d21a06ff2c55339e5ab2a6a3090d 100644 --- a/unit_tests/unit_test.py +++ b/unit_tests/unit_test.py @@ -15,12 +15,19 @@ gen_data = tg._main() if gen_data != 0: raise Exception('DONT PANIC: Input data generation failed') +# TODO: run different bdy files or change bdy file for different grid types for testing. + # run PyNEMO with test data -stdout, stderr = Popen(['pynemo', '-s', 'unit_tests/namelist_unit_test.bdy'], stdout=PIPE, stderr=PIPE, +namelist_files = glob.glob('unit_tests/namelist*') +for n in namelist_files: + stdout, stderr = Popen(['pynemo', '-s', n], stdout=PIPE, stderr=PIPE, universal_newlines=True).communicate() if 'Execution Time' not in stdout: raise Exception('DONT PANIC: Test Run Failed') +# TODO: Learn about parameterising the tests so that different parameters can be checked +# with same code. Rather than having similar test functions repeated. + # perform tests def test_temp(): test_files = glob.glob('unit_tests/test_outputs/unit_test*')