Run SCREAM processes in standalone mode for science research #2845
Replies: 9 comments 18 replies
-
I'm definitely against providing wrappers for each individual functions. If you go there, you open a can of worms that nobody (at least, not me) want to develop/maintain. I am not sure I understand the "uniform driver" solution. As for the other approaches, using existing single-process tests should probably be the way to go. Users can still call the standalone executables from python. They just need to provide the input.yaml file, but that can be done by reading in a sample one, modifying the few params they want to modify, and dump it again. Loading a yaml file produces a python dict, so navigating the yaml tree is quick, once one knows the main structure. I would try to stand away from calling processes from python via c-py bindings. EAMxx has a non-trivial initialization sequence, as well as a non-trivial infrastructure for running a process. I am a bit wary of giving the user the ability to call functions at will. My fear is that things won't work, and we'll spend lots of time debugging these wrappers. Since I think performance is not key here, I think running standalone execs via subprocess pipes is plenty good. |
Beta Was this translation helpful? Give feedback.
-
I did an initial exploration of the python package idea. I will first describe what I tried doing, and then I will go over the challenges and potential solutions. What I tried:
What I concluded (for now): Looking ahead: Something I'd like to look into soon-ish: |
Beta Was this translation helpful? Give feedback.
-
This is awesome, thanks Naser! If I understand correctly, my "python is written in C and our code is C++ so it should be easy to bridge from one to the other" thinking is wrong because of the complexities our code needs to run on a supercomputer (e.g. MPI, possibly Kokkos, initialization, etc). My feeling is that if we need to modify EAMxx source code in order to get this functionality working, we should abandon the effort... maintaining 2 similar but not identical code bases is not an efficient use of our time for enabling a "bonus" capability. I'm curious whether any of you disagree or have a more nuanced view. Luckily, I asked @hassanbeydoun and @AaronDonahue to explore the much simpler approach of hijacking an existing standalone test to run a process with user-defined input. |
Beta Was this translation helpful? Give feedback.
-
@mahf708 , some quick thoughts:
|
Beta Was this translation helpful? Give feedback.
-
Oh I thought it was some SCREAM policy at higher-up dirs... so we could potentially try dynamic linking later to see how things turn out. Btw, I did this for dynamic linking:
No, this was calling cpp from python:
|
Beta Was this translation helpful? Give feedback.
-
So, I got convinced that we can easily-ish achieve something that allows this kind of usage from python import pyscream as ps
import pyp3 as P3
import numpy as np
ncols = 100
nlevs = 128
v1 = np.zeros(shape=(ncols,nlevs))
v2 = np.zeros(shape=(ncols,nlevs))
for i in range(0,ncols):
for j in range(0,nlevs):
v1[i,j] = i*nlevs + j + 1
v2[i,j] = j*ncols + i + 1
f1 = ps.Field("T_mid",v1)
f 2= ps.Field("qv",v2)
...
params = {}
p3 = P3.P3(params)
p3.set_fields(f1,f2,...)
t0 = ps.TimeStamp(...)
dt = 100
for val in range(blah1, blah2):
p3.set_param('blah',val)
p3.set_time(t0)
p3.run(dt)
# analyze f1,f2,...
# Avoid errors from kokkos
f1.cleanup()
f2.cleanup() |
Beta Was this translation helpful? Give feedback.
-
This is an neat capability! I wanted to up-vote Hassan's use case of running standalone RRTMGP that @PeterCaldwell brought up in the original post. This will be analysis that we'd want to include in the Cess overview paper. |
Beta Was this translation helpful? Give feedback.
-
For reference, the PR with the initial impl is here: #2851. For more technical comments, like code, etc., please also consider adding them there if you have opinions... |
Beta Was this translation helpful? Give feedback.
-
@mahf708 I think we could integrate that PR sooner than later, but if you want to wait so we can reorganize the pyXYZ files, so that they all lie in |
Beta Was this translation helpful? Give feedback.
-
Ability to run a single SCREAM process with user-defined inputs and use their outputs for evaluation would be very useful.
As an example, @hassanbeydoun currently wants to run RRTMGP in standalone mode with and without our moisture profile corrected to get rid of our dry bias at mid-levels and moist bias at high levels. I've also benefited greatly from running microphysics iteratively within a bespoke/idealized column driver (as advocated by Adrian Hill's KiD driver). This allows us to deeply investigate whether microphysics is working correctly. One could imagine a similar functionality for SHOC (or any other process).
One (easy?) pathway to this would be to just run an existing process test with the input hacked. Does anyone have a good sense of what would be involved in this?
A more awesome solution would be to develop a strategy for calling a process from python since that's the language everyone will be using to evaluate this output. @mahf708 envisions creating a python package that links to pre-compiled C++. EAMxx staff would create this package monthly or so so folks could just pip-install it rather than having to muck about themselves.
As a 3rd solution, Aaron suggested a uniform driver (in C++?) where a user could specify which process they want to run (at run time?). A challenge is that passing input vars to the proc might get confusing since they would be different for each proc and there could be a lot of them.
Open questions:
Beta Was this translation helpful? Give feedback.
All reactions