Clean up e3sm_coupling script and config#506
Clean up e3sm_coupling script and config#506mark-petersen merged 5 commits intoMPAS-Dev:ocean/developfrom
Conversation
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.
xylar
left a comment
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Until we get the MPICH compass environment working (hopefully soon!) I think this is safer.
| # the file name of the initial condition, possibly after spin-up | ||
| initial_condition = ../initial_state/initial_state.nc |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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(): # {{{ |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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') |
There was a problem hiding this comment.
Wherever we need ice_shelf_cavities, we do a getboolean instead of a get.
| nomaskStr='.nomask' | ||
| nomaskStr = '.nomask' | ||
| else: | ||
| nomaskStr='' | ||
| nomaskStr = '' |
There was a problem hiding this comment.
Equals signs always get space around them unless they are keyword arguments to a function, in which case they never get spaces.
There was a problem hiding this comment.
Strange, I always try to use autopep8 before I check in python code. I must have added these lines after that.
|
|
||
| except OSError: | ||
| print('mapping must be run on one compute node') |
There was a problem hiding this comment.
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?
| def domain_CORE_Gcase(config): # {{{ | ||
| make_domain_files(config, 'CORE_Gcase') | ||
| # }}} |
There was a problem hiding this comment.
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): # {{{ |
There was a problem hiding this comment.
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.
| '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', |
There was a problem hiding this comment.
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.
mark-petersen
left a comment
There was a problem hiding this comment.
@xylar thanks for your careful review of the coupling file script.
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.
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:
cull_cells.pyintoocean/global_ocean/scripts, where it seems to belonginit.nctomesh.ncto distinguish the "mesh" from the "initial condition" during the E3SM coupling step.