Skip to content

Update HAFS RTs to use the new multi output grid capability#19

Merged
DusanJovic-NOAA merged 8 commits into
DusanJovic-NOAA:multiple_output_gridsfrom
BinLiu-NOAA:feature/multiple_output_grids
Feb 9, 2022
Merged

Update HAFS RTs to use the new multi output grid capability#19
DusanJovic-NOAA merged 8 commits into
DusanJovic-NOAA:multiple_output_gridsfrom
BinLiu-NOAA:feature/multiple_output_grids

Conversation

@BinLiu-NOAA

Copy link
Copy Markdown

Update/unify existing HAFS RTs to use the new capability of the write grid component to write out both parent and nested grids.

Comment thread tests/default_vars.sh Outdated
Comment thread tests/default_vars.sh Outdated
Comment thread tests/tests/hafs_regional_telescopic_2nests_atm
Comment thread tests/tests/hafs_global_1nest_atm
dx: @[DX] # grid cell size in x/y direction (meters)
dy: @[DY] # needed for lambert_conformal

<output_grid_02>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the hafs test with single domain output, will this section still show up? Can we remove this section using hafs run script if these output grids are not needed?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you think about fv3_conf/hafs_fv3_run.IN, this script doesn't now how many nests are configured. And by the time this script is executed module_configure is already created in the rundir.

@BinLiu-NOAA BinLiu-NOAA Feb 8, 2022

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@junwang-noaa and @DusanJovic-NOAA, this is one of the reasons I suggested using the column configuration method. We do not need to add these extra <output_grid_xx> sections. And if default values are the concern, we can just use empty as default values, for example:

output_grid:             'global_latlon', 'regional_latlon', 'rotated_latlon', 'rotated_latlon', 'rotated_latlon'
imo:                     360,   ,   ,   ,
jmo:                     181,   ,   ,   ,
cen_lon:                    , -175.00,  -86.00,  -86.00,  -86.00
cen_lat:                    ,    0.00,   23.00,   23.00,   23.00
lon1:                       , -220.00,  -45.00,  -45.00,  -35.00
lat1:                       ,  -45.00,  -45.00,  -45.00,  -30.00
lon2:                       , -130.00,   45.00,   45.00,   35.00
lat2:                       ,   45.00,   45.00,   45.00,   30.00
dlon:                       ,    0.25,    0.25,    0.10,    0.05
dlat:                       ,    0.25,    0.25,    0.10,    0.05

I personally think this will give us a much cleaner model_configure template/file. Thanks!

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@junwang-noaa and @DusanJovic-NOAA, this is one of the reasons I suggested using the column configuration method. We do not need to add these extra <output_grid_xx> sections. And if default values are the concern, we can just use empty as default values, for example:

output_grid:             'global_latlon', 'regional_latlon', 'rotated_latlon', 'rotated_latlon', 'rotated_latlon'
imo:                     360,   ,   ,   ,
jmo:                     181,   ,   ,   ,
cen_lon:                    , -175.00,  -86.00,  -86.00,  -86.00
cen_lat:                    ,    0.00,   23.00,   23.00,   23.00
lon1:                       , -220.00,  -45.00,  -45.00,  -35.00
lat1:                       ,  -45.00,  -45.00,  -45.00,  -30.00
lon2:                       , -130.00,   45.00,   45.00,   35.00
lat2:                       ,   45.00,   45.00,   45.00,   30.00
dlon:                       ,    0.25,    0.25,    0.10,    0.05
dlat:                       ,    0.25,    0.25,    0.10,    0.05

I personally think this will give us a much cleaner model_configure template/file. Thanks!

Are you sure this table, with 'empty values', will properly parse using ESMF config parser? Shouldn't all values at a given row be the same type i.e. float?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not very sure. I recall ESMF_config can treat every line as string, then one can parse it into variables (string, integer, float, etc.). But, @theurich probably know this better.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can certainly read in every line as a string. Of course, parsing this string, and tokenizing it then becomes your an application level responsibility.
If on the other hand you have as many elements in each line as there are columns, then you can use ESMF_Config API to read in each value. But that is where you would need dummies.

@junwang-noaa

junwang-noaa commented Feb 8, 2022 via email

Copy link
Copy Markdown

Comment thread tests/tests/hafs_regional_telescopic_2nests_atm Outdated
@BinLiu-NOAA

BinLiu-NOAA commented Feb 9, 2022

Copy link
Copy Markdown
Author

@junwang-noaa and @DusanJovic-NOAA, I added a few lines in run_test.sh to remove those unneeded the <output_grid_xx> sections from model_configure. For example,

if [[ "Q${INPUT_NEST03_NML:-}" != Q ]] ; then
    INPES_NEST=$INPES_NEST03; JNPES_NEST=$JNPES_NEST03
    NPX_NEST=$NPX_NEST03; NPY_NEST=$NPY_NEST03
    K_SPLIT_NEST=$K_SPLIT_NEST03; N_SPLIT_NEST=$N_SPLIT_NEST03
    atparse < ${PATHRT}/parm/${INPUT_NEST03_NML} > input_nest03.nml
else
    lnbeg=$(grep -i -n "<output_grid_03>" model_configure | cut -d: -f1)
    lnend=$(grep -i -n "</output_grid_03>" model_configure | cut -d: -f1)
    [[ ! -z "$lnbeg" ]] && [[ ! -z "$lnend" ]] && sed -i -e "${lnbeg},${lnend}d" model_configure
fi

It's not an elegant solution, but it at least works fine. Thanks!

@DusanJovic-NOAA

Copy link
Copy Markdown
Owner

@junwang-noaa and @DusanJovic-NOAA, I added a few lines in run_test.sh to remove those unneeded the <output_grid_xx> sections from model_configure. For example,

if [[ "Q${INPUT_NEST03_NML:-}" != Q ]] ; then
    INPES_NEST=$INPES_NEST03; JNPES_NEST=$JNPES_NEST03
    NPX_NEST=$NPX_NEST03; NPY_NEST=$NPY_NEST03
    K_SPLIT_NEST=$K_SPLIT_NEST03; N_SPLIT_NEST=$N_SPLIT_NEST03
    atparse < ${PATHRT}/parm/${INPUT_NEST03_NML} > input_nest03.nml
else
    lnbeg=$(grep -i -n "<output_grid_03>" model_configure | cut -d: -f1)
    lnend=$(grep -i -n "</output_grid_03>" model_configure | cut -d: -f1)
    [[ ! -z "$lnbeg" ]] && [[ ! -z "$lnend" ]] && sed -i -e "${lnbeg},${lnend}d" model_configure
fi

It's not an elegant solution, but it at least works fine. Thanks!

Thanks. Unnecessary complication that's not really necessary. But since it's been already added, let's leave it. This entire section is very repetitive, difficult to maintain, and error prone.

@DusanJovic-NOAA DusanJovic-NOAA merged commit f0af03e into DusanJovic-NOAA:multiple_output_grids Feb 9, 2022
Comment thread tests/run_test.sh
Comment on lines +140 to +142
lnbeg=$(grep -i -n "<output_grid_04>" model_configure | cut -d: -f1)
lnend=$(grep -i -n "</output_grid_04>" model_configure | cut -d: -f1)
[[ ! -z "$lnbeg" ]] && [[ ! -z "$lnend" ]] && sed -i -e "${lnbeg},${lnend}d" model_configure

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can these three lines be replaced by something like:
sed -i -e "/<output_grid_04>/,/<\/output_grid_04>/d" model_configure

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DusanJovic-NOAA, I think your solution is simpler and better. Since the PR is already merged, please commit your change directly into your branch. Thanks a lot!

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. f232add

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants