Skip to content

Clean up e3sm_coupling script and config#506

Merged
mark-petersen merged 5 commits intoMPAS-Dev:ocean/developfrom
xylar:clean_up_e3sm_coupling
Apr 6, 2020
Merged

Clean up e3sm_coupling script and config#506
mark-petersen merged 5 commits intoMPAS-Dev:ocean/developfrom
xylar:clean_up_e3sm_coupling

Conversation

@xylar
Copy link
Collaborator

@xylar xylar commented Apr 3, 2020

Now that we have a little breathing room after getting EC60to30 initial conditions in place, I'd like to clean up the E3SM coupling step and a few other small things:

  • move cull_cells.py into ocean/global_ocean/scripts, where it seems to belong
  • fix some incorrect tabs in an XML file
  • switch init.nc to mesh.nc to distinguish the "mesh" from the "initial condition" during the E3SM coupling step.

xylar added 4 commits April 2, 2020 05:50
Most steps in E3SM need a mesh file, which can always come from
the end of `initial_state`.

Where an initial condition is needed instead of a mesh file, this
is taken from the config file.  Currently, the default is the same
as the mesh file: `../initial_state/initial_state.nc` but this
could be changed by the user (or a case-specific config file) in
the future.
Copy link
Collaborator Author

@xylar xylar left a comment

Choose a reason for hiding this comment

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

Some suggested changes. This is not just to be pedantic about this script but to hopefully help develop standard python coding practices across MPAS.

mesh_name = autodetect
date_string = autodetect
nprocs = 36
nprocs = 1
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Until we get the MPICH compass environment working (hopefully soon!) I think this is safer.

Comment on lines +8 to +9
# the file name of the initial condition, possibly after spin-up
initial_condition = ../initial_state/initial_state.nc
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For now, the initial condition is the same as the mesh. This will remain the default but will change for individual test cases in a subsequent pr.


[mapping_CORE_Gcase]
enable = true
enable = false
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 turned off a few of these (CORE_Gcase and salinity_restoring) by default because they depend on files and executables that are currently only available on LANL IC.

[prescribed_ismf]
# does nothing if ice-shelf cavities are not present
enable = true
enable = false
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 turned off prescribed ISMF for now because it is very slow without parallel mapping-file generation (waiting for compass MPI env.)


def main():
# {{{
def main(): # {{{
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 made a large number of clean-up changes to this script, most of which I will attempt to explain.

The opening bracket for folds (which I, as an only occasional vim user find pretty annoying...) need to be indented 4 spaces or moved up to the end of the previous line for PEP8 formatting. If they aren't indented, they really mess with my chosen IDE (pycharm), since I tries to unindent my code to match.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks. I'll keep that in mind. Folds are really great in vim, but I can see why they are excessive in other editors.


mesh_name = config.get('main', 'mesh_name')
date_string = config.get('main', 'date_string')
ice_shelf_cavities = config.getboolean('main', 'ice_shelf_cavities')
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Wherever we need ice_shelf_cavities, we do a getboolean instead of a get.

Comment on lines -228 to +248
nomaskStr='.nomask'
nomaskStr = '.nomask'
else:
nomaskStr=''
nomaskStr = ''
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Equals signs always get space around them unless they are keyword arguments to a function, in which case they never get spaces.

Copy link
Contributor

Choose a reason for hiding this comment

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

Strange, I always try to use autopep8 before I check in python code. I must have added these lines after that.

Comment on lines -389 to -391

except OSError:
print('mapping must be run on one compute node')
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This try / except around a do loop is something I would advise against. I appreciate that there was a meaningful exception name OSError here. But it would be fine to just let the OSError happen I think. I could imagine various sources of OSErrors here, only some of which would relate to not being on a compute node. It also is hard to figure out what went wrong if you catch the error and don't print the error message that was produced. Which call failed?

Comment on lines +453 to +455
def domain_CORE_Gcase(config): # {{{
make_domain_files(config, 'CORE_Gcase')
# }}}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There are 3 essentially identical functions with a single string that differs between them. It makes a lot more sense to have one function than 3 copies.

for file in files:
make_link('../../../../domain/' + file, './' + file)
# }}}
def make_domain_files(config, mapping_suffix): # {{{
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This function replaces the 3 domain functions above. We could add more arguments in the future if needed (e.g. different atmosphere grids.

Previously, we were removing fields, but this is unreliable.
Comment on lines +219 to +225
'areaCell,cellsOnCell,edgesOnCell,fCell,indexToCellID,latCell,'
'lonCell,meshDensity,nEdgesOnCell,verticesOnCell,xCell,yCell,zCell,'
'angleEdge,cellsOnEdge,dcEdge,dvEdge,edgesOnEdge,fEdge,'
'indexToEdgeID,latEdge,lonEdge,nEdgesOnCell,nEdgesOnEdge,'
'verticesOnEdge,weightsOnEdge,xEdge,yEdge,zEdge,areaTriangle,'
'cellsOnVertex,edgesOnVertex,fVertex,indexToVertexID,'
'kiteAreasOnVertex,latVertex,lonVertex,xVertex,yVertex,zVertex',
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 think this is the complete list of fields we want to keep for the sea-ice initial condition but this should definitely have another pair of eyes on it.

@xylar
Copy link
Collaborator Author

xylar commented Apr 5, 2020

Testing

I tested a merge of this PR, #507 , #508, #510 and #511 together through spin-up for the following test cases:

  • EC60to30
  • EC60to30wISC
  • SO60to10wISC

Copy link
Contributor

@mark-petersen mark-petersen left a comment

Choose a reason for hiding this comment

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

@xylar thanks for your careful review of the coupling file script.

@mark-petersen mark-petersen merged commit 07e9e53 into MPAS-Dev:ocean/develop Apr 6, 2020
@xylar xylar deleted the clean_up_e3sm_coupling branch April 7, 2020 06:37
caozd999 pushed a commit to caozd999/MPAS-Model that referenced this pull request Jan 14, 2021
Clean up e3sm_coupling script and config MPAS-Dev#506

Now that we have a little breathing room after getting EC60to30 initial
conditions in place, I'd like to clean up the E3SM coupling step and a
few other small things:
* move `cull_cells.py` into `ocean/global_ocean/scripts`, where it seems
* to belong
* fix some incorrect tabs in an XML file
* switch `init.nc` to `mesh.nc` to distinguish the "mesh" from the
* "initial condition" during the E3SM coupling step.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants