Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@mcgibbon
Copy link
Collaborator

@mcgibbon mcgibbon commented Feb 9, 2022

Purpose

This PR adds a script to generate a report with all stencil call signatures showing in/out/inout intents, and makes use of its output to update fv3core (outside of remapping, which will be done in another PR).

Code changes:

  • added an example script in driver which reports the call signature of each stencil, and aggregated call signatures for classes containing stencils
  • added and updated all docstrings outside of remapping in fv3core with in/out/inout based on report and manual inspection
  • re-ordered object creation and stencil function definitions to match call order
  • inlined some helper methods in fv3core
  • added Driver and DriverConfig to pace.driver namespace

Infrastructure changes:

  • enabled mypy for driver in pre-commit config

Checklist

Before submitting this PR, please make sure:

  • You have followed the coding standards guidelines established at Code Review Checklist.
  • Docstrings and type hints are added to new and updated routines, as appropriate
  • All relevant documentation has been updated or added (e.g. README, CONTRIBUTING docs)
  • For each public change and fix in pace-util, HISTORY has been updated
  • Unit tests are added or updated for non-stencil code changes

@mcgibbon mcgibbon changed the title Feature/report stencil signatures Report stencil argument intents, update fv3core docstrings Feb 9, 2022
@mcgibbon mcgibbon requested a review from oelbert February 9, 2022 00:03
Copy link
Contributor

@oelbert oelbert left a comment

Choose a reason for hiding this comment

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

A few small changes, mostly just cleanup for duplicated in/out hinting. I didn't double-check the signatures, but I think it's ok and I could go back over it if you want.

# lon_agrid (in):
# lat_agrid (in):
# lon (in):
# lat (in):
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the use of these comments separate from the docstring?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll delete this for now. I put it in because this is probably what we'll want to do when refactoring (put all the signatures in one place, then reason about data flow), but I think it's premature for this step.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

self._qout_y_edge_north(
qin, self._dya, self._edge_n, qout, self._tmp_qout_edges
)

Copy link
Contributor

Choose a reason for hiding this comment

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

Presumably this is to make fusion easier?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes.

)

def _vorticity_calc(self, wk, vort, delpc, dt):
# this function is kept because it has a translate test, if its
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess it's ok to keep this but it seems strange and I would want to cut it in a future PR

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I could move this to the translate class itself, if that would be better?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I think that would be better

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

OK, updated here and where I did a similar thing in c_sw.

vc (in): covariant c-grid y-wind (in)
cosa_u (in): ??? (in)
rsin_u (in): ??? (in)
uc_contra (out): contravariant c-grid x-wind (out)
Copy link
Contributor

Choose a reason for hiding this comment

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

remove duplicated in/out information

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Will fix.

pk3 (inout): gets updated to B-grid
delp: vertical delta in pressure (in)
dt: model atmospheric timestep (in)
ptop: pressure at top of atmosphere (in)
Copy link
Contributor

Choose a reason for hiding this comment

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

Fix formatting/duplication here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Will fix.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

Comment on lines 673 to 682
w: vertical velocity (in)
uc: C-grid x-velocity (inout)
vc: C-grid y-velocity (inout)
ua: A-grid x-velocity (in)
va: A-grid y-velocity (in)
ut: u * dx (inout)
vt: v * dy (inout)
divgd: D-grid horizontal divergence (inout)
omga: Vertical pressure velocity (inout)
ua: A-grid x-velocity (inout)
va: A-grid y-velocity (inout)
ut: u * dx (out)
vt: v * dy (out)
divgd: D-grid horizontal divergence (out)
omga: Vertical pressure velocity (out)
dt2: Half a model timestep in seconds (in)
Copy link
Contributor

Choose a reason for hiding this comment

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

The layouts of these are inconsistent with the other in/out documentation

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Will fix, and will double-check their values.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

Comment on lines 1001 to 1014
delpc (inout): C-grid vertical delta in pressure (inout)
delp (inout): D-grid vertical delta in pressure (inout),
ptc : C-grid potential temperature (inout)
pt (inout): D-grid potential teperature
u (inout): D-grid x-velocity (inout)
v (inout): D-grid y-velocity (inout)
w (inout): vertical velocity (inout)
uc (in): C-grid x-velocity (in)
vc (in): C-grid y-velocity (in)
ua (in): A-grid x-velocity (in)
va (in) A-grid y-velocity (in)
divgd: D-grid horizontal divergence (inout)
mfx: accumulated x mass flux (inout)
mfy: accumulated y mass flux (inout)
cx: accumulated Courant number in the x direction (inout)
cy: accumulated Courant number in the y direction (inout)
crx: local courant number in the x direction (inout)
cry: local courant number in the y direction (inout)
xfx: flux of area in x-direction, in units of m^2 (in)
yfx: flux of area in y-direction, in units of m^2 (in)
q_con: total condensate mixing ratio (inout)
zh: geopotential height defined on layer interfaces (in)
heat_source: accumulated heat source (inout)
diss_est: dissipation estimate (inout)
dt: acoustic timestep in seconds (in)
mfx (inout): accumulated x mass flux (inout)
mfy (inout): accumulated y mass flux (inout)
Copy link
Contributor

Choose a reason for hiding this comment

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

More duplication

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Will fix.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

@mcgibbon
Copy link
Collaborator Author

mcgibbon commented Feb 9, 2022

launch jenkins

Copy link
Contributor

@oelbert oelbert left a comment

Choose a reason for hiding this comment

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

Looks good!

@mcgibbon mcgibbon merged commit 1d50a1c into main Feb 10, 2022
@mcgibbon mcgibbon deleted the feature/report_stencil_signatures branch February 10, 2022 21:32
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.

3 participants