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

Metadata corrections #474

Merged
merged 10 commits into from
Jul 15, 2020
Merged

Metadata corrections #474

merged 10 commits into from
Jul 15, 2020

Conversation

mcgibbon
Copy link
Contributor

@mcgibbon mcgibbon commented Jul 13, 2020

In using code generation to make Python wrappers for Fortran routines based on their .meta files, I have found some cases where dimension names are inaccurate or in the wrong order, or where intent and optional are missing as keys. In one case, a routine name was inaccurate, and in a couple cases an input was duplicated. I've also corrected the argument order for some (but not all edit: done) routines where they were out of order.

Let me know if you'd like this merged to a different branch, or not merged at all.

@mcgibbon
Copy link
Contributor Author

Closing as I've found some more errors from updating to the latest physics code, until those are fixed (and my auto-generated code compiles again).

@mcgibbon mcgibbon closed this Jul 13, 2020
@mcgibbon
Copy link
Contributor Author

Fixed the remaining out-of-order arguments.

@mcgibbon mcgibbon reopened this Jul 13, 2020
Copy link
Collaborator

@climbfuji climbfuji left a comment

Choose a reason for hiding this comment

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

Thanks for submitting this PR. There are quite a few places where you actually found inconsistencies in our metadata (correct intent, for example). Let me note, however, that for some metadata attributes, there are default values in case they are not specified, for example:

  • default for optional is F
  • default for intent is in

I personally prefer to spell the attributes out, even if they match the default value, which is what your PR does.

I left a few comments with one change that needs to be reverted.

Thanks for fixing the order of arguments in the metadata files, in particular for RUC LSM.

@@ -1,10 +1,10 @@
[ccpp-arg-table]
name = gscond_init
name = zhaocarr_gscond_init
Copy link
Collaborator

Choose a reason for hiding this comment

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

This [ccpp-arg-table] section should be removed altogether, there are no hooks in gscond.f that would trigger reading it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there a standard rule for this? I included these since in sfc_ocean (the module I was testing on), these init and finalize sections are included in the meta file despite the routines being empty.

Copy link
Collaborator

Choose a reason for hiding this comment

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

No, there isn't - at least in the current ccpp_prebuild.py version, because the parser goes through the Fortran scheme files that contain the CCPP entry points and only if it finds a metadata table hook (\section arg_table ... \htmlinclude) it will look for the corresponding entry in the .meta file. For the new cap_gen.py, this may be slightly different.

@@ -101,7 +101,7 @@
standard_name = minimum_large_ice_fraction
long_name = minimum large ice fraction in F-A mp scheme
units = frac
dimensions = (2)
dimensions = (horizontal_dimension)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is not correct. flgmin is - in FV3 - a control parameter that is independent of horizontal grid decomposition and has length 2. From GFS_typedefs.F90:

    real(kind=kind_phys) :: flgmin(2)      = (/0.180,0.220/)          !< [in] ice fraction bounds

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, fixed.

type = scheme

########################################################################
[ccpp-arg-table]
name = gscond_finalize
name = zhaocarr_gscond_finalize
Copy link
Collaborator

Choose a reason for hiding this comment

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

This [ccpp-arg-table] section should be removed altogether, there are no hooks in gscond.f that would trigger reading it.

@@ -77,7 +77,7 @@
standard_name = surface_air_pressure
long_name = surface pressure
units = Pa
dimensions = (horizontal_dimension)
dimensions = (horizontal_loop_extent)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Strictly speaking, all "horizontal_dimension" entries in any of the _run routines should use horizontal_loop_extent and not horizontal_dimension. Right now, we have a workaround in ccpp_prebuild.py that substitutes horizontal_loop_extent with horizontal_dimension for _init and _finalize routines, and vice versa for _run routines. It doesn't hurt at all making these changes here, but sfc_ocean.meta will be an outlier compared to all other schemes using (the incorrect) horizontal_dimension. But it would be better to not change it as part of this PR, so that we can make all adjustments of horizontal_loop_extent <-> horizontal_dimension in a single pull request.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will need these to be fixed in order for the wrapped routines to run, but I can fix the ones I'm testing on in a separate branch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok, thanks. We'll make this change everywhere soon.

@gold2718
Copy link

default for intent is in

capgen does not have a default for intent (I thought that is what we decided). That matches Fortran best practice (e.g., the modified Kalnay rules).

@climbfuji
Copy link
Collaborator

default for intent is in

capgen does not have a default for intent (I thought that is what we decided). That matches Fortran best practice (e.g., the modified Kalnay rules).

Thanks for correcting me - better trust your memory than mine. In any case, I prefer to spell out these attributes.

@climbfuji
Copy link
Collaborator

This PR was pulled into #470 and will be merged as part of it. Keeping this PR open, should be flagged as "merged" automatically once #470 gets merged.

Copy link
Collaborator

@climbfuji climbfuji 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. I pulled it into #470 so that it will be merged as part of it.

@climbfuji climbfuji merged commit b5580ce into NCAR:master Jul 15, 2020
@mcgibbon mcgibbon deleted the fix/meta_missing_args branch July 15, 2020 20:45
@mcgibbon mcgibbon restored the fix/meta_missing_args branch July 15, 2020 20:45
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