Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add nudgecoeffs_e and wgtfac_c #322

Merged
merged 27 commits into from
Feb 19, 2024
Merged

add nudgecoeffs_e and wgtfac_c #322

merged 27 commits into from
Feb 19, 2024

Conversation

jonasjucker
Copy link
Contributor

@jonasjucker jonasjucker commented Nov 29, 2023

Port interpolation fields nudgecoeffs_e from src/shr_horizontal/mo_intp_coeffs.f90.

Indices are used not only for accessing arrays, but also to do computations.
In order to get the correct result in Python, the indices have to be translated to true Fortran values.

Port stencil for field wgtfac_c from src/atm_dyn_iconam/mo_vertical_grid.f90

@jonasjucker jonasjucker marked this pull request as draft November 29, 2023 10:28
nudge_max_coeffs: wpfloat,
) -> Field[[EdgeDim], wpfloat]:

return nudge_max_coeffs * EXP(-(refin_ctrl - grf_nudge_start_e)/ 4.0)
Copy link
Contributor

Choose a reason for hiding this comment

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

there is an exp builtin in gt4py that you might need to use here and import here.
from gt4py.next.ffront.fbuiltins import Field, int32, neighbor_sum, exp

Copy link
Contributor

Choose a reason for hiding this comment

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

In case you need floating points for the args to exp there is an astype function for casting in gt4py (also in fbuiltins I believe)

nudge_max_coeffs: wpfloat,
) -> Field[[EdgeDim], wpfloat]:

return nudge_max_coeffs * EXP(-(refin_ctrl - grf_nudge_start_e)/ 4.0)
Copy link
Contributor

Choose a reason for hiding this comment

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

There is this if condition on the refin_ctl in the icon code:

IF (ptr_patch%edges%refin_ctrl(je,jb) > 0 .AND. &
            & ptr_patch%edges%refin_ctrl(je,jb) <= grf_nudge_start_e+9)

you could include this in the calculation by using a where something like

where(refin_ctl > int32(0) & refin_ctl <= upper_bound, true-case, false-case)

dann kannst du die upper_bound als Argument mit uebergeben. Der false-case ist wahrscheinlich einfach 0?



@field_operator
def _mo_intp_coeffs_nudgecoeff_e(
Copy link
Contributor

Choose a reason for hiding this comment

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

Ich persoenlich wuerde es eher so def calc_nudgecoeffs nennen, ich finde diese icon Referenz mit mo_intp nicht sehr hilfreich, und in the long run eher unverstaendlich.

Wahrscheinlich kannst du die Berechnung der nudgeing coeff in den andern Dimensionen mit dem gleichen stencil erschlagen, dann auf jeden Fall die _e in den Namen weg. (Zumindest sieht die Berechnung von den Zellen dort drueber beim schnell drueber fliegen in der Struktur in etwa gleich aus.

@halungge
Copy link
Contributor

halungge commented Nov 29, 2023

Kannst du noch einen test dafuer schreiben?
Falls du mit den serialisierten Daten vergleichen willst:

  • weiss grad nicht, ob wir die Referenz da haben. Kann die sonst noch ergaenzen. Fuer edges ist die Referenz: interpolation_savepoint.nudgecoeff_e()
  • Die refin_ctl Werte gibts da: grid_savepoint.refin_ctrl(EdgeDim) . grid_savepoint und interpolation_savepoint sind test fixtures in datatest_fixtures.py.
  • grf_nudge_start_e = HorizontalMarkerIndex.nudgeing(EdgeDim) ,
  • nudge_max_coeffs ist glaub ich ein namelist parameter. Wir verwenden das mch_ch_r04b09_dsl Experiment.

@jonasjucker
Copy link
Contributor Author

launch jenkins spack

@jonasjucker
Copy link
Contributor Author

cscs-ci run default

@jonasjucker
Copy link
Contributor Author

launch jenkins spack

@jonasjucker jonasjucker marked this pull request as ready for review January 17, 2024 14:26
@jonasjucker
Copy link
Contributor Author

cscs-ci run default

@jonasjucker
Copy link
Contributor Author

launch jenkins spack

@jonasjucker jonasjucker requested a review from halungge January 17, 2024 14:31
@jonasjucker
Copy link
Contributor Author

launch jenkins spack

@jonasjucker
Copy link
Contributor Author

cscs-ci run default

@jonasjucker
Copy link
Contributor Author

cscs-ci run default

@jonasjucker
Copy link
Contributor Author

launch jenkins spack

@jonasjucker jonasjucker changed the title add nudgecoeffs_e add nudgecoeffs_e and wgtfac_c Feb 13, 2024
@jonasjucker
Copy link
Contributor Author

cscs-ci run default

@jonasjucker jonasjucker requested a review from halungge February 13, 2024 11:47
@jonasjucker
Copy link
Contributor Author

@halungge Due to the many fixes in icon4py recently I merged the branch for wgtfac_c into this branch as well.

Please only revisit these files for the review.

@C2SM C2SM deleted a comment from github-actions bot Feb 13, 2024
Copy link
Contributor

@halungge halungge left a comment

Choose a reason for hiding this comment

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

I only have some renamings...

@field_operator
def _calc_wgtfac_c(
z_ifc: Field[[CellDim, KDim], wpfloat],
k_field: Field[[KDim], int32],
Copy link
Contributor

Choose a reason for hiding this comment

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

Currently in most of the dycore stencils they just call it 'k' we should stick to this convention.

@jonasjucker
Copy link
Contributor Author

launch jenkins spack

@jonasjucker
Copy link
Contributor Author

cscs-ci run default

@jonasjucker jonasjucker requested a review from halungge February 13, 2024 15:34
@jonasjucker
Copy link
Contributor Author

cscs-cu run default

@jonasjucker
Copy link
Contributor Author

launch jenkins spack

@jonasjucker
Copy link
Contributor Author

cscs-ci run default

Copy link

Mandatory Tests

Please make sure you run these tests via comment before you merge!

  • cscs-ci run default
  • launch jenkins spack

Optional Tests

To run benchmarks you can use:

  • cscs-ci run benchmark

To run tests and benchmarks with the DaCe backend you can use:

  • cscs-ci run dace

In case your change might affect downstream icon-exclaim, please consider running

  • launch jenkins icon

For more detailed information please look at CI in the EXCLAIM universe.

@jonasjucker
Copy link
Contributor Author

launch jenkins spack

@jonasjucker
Copy link
Contributor Author

cscs-ci run default

@jonasjucker jonasjucker merged commit f8ca7be into main Feb 19, 2024
5 checks passed
@jonasjucker jonasjucker deleted the port_nudgecoeff_e branch February 19, 2024 13:44
OngChia pushed a commit that referenced this pull request Jan 14, 2025
* add nudgecoeffs_e

* add test

* test parses

* remove horizontal bounds

* stencil runs

* second implementation of stencil

* cleanup stencil

* correct indexing for end_index and refin_ctrl

* remove unused import

* import all fixtures, format

* hardcode grf_nudge_start_e to 10

* translate index to Fortran value

* Introduce RefinCtrlLevel

* formatting

* add dot

* review suggestions

* Port wgtfac_c (#365)

* cleanup

* formatting

* rename stencils, review suggestions

* formatting

---------

Co-authored-by: Jonas Jucker <jonas.jucker@c2sm.ethz.ch>
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.

2 participants