Closed bch0w closed 1 month ago
Hellow @bch0w,
Could this bug be related to the mpirun issue #194 using specfem2d?
@raulleoncz It may be! Your original error message in #194 matches the one seen in #214. I was unaware of this issue as I was always using uniformly distributed meshes. Are you able to re-test your problem with the latest devel branch of the code to see if you still have any issues?
Hello @bch0w, thanks for the answer.
I tried to simulate my problem using the new version of seisflows and this is what I got. First of all, I tried using python 3.12 and numpy 1.26.4 and I got the following error:
2024-06-05 17:37:53 [INFO] | checking true/target model parameters:
2024-06-05 17:37:53 [DEBU] | checkpointing workflow to seisflows state file
Traceback (most recent call last):
File "/Users/raul/anaconda3/envs/seisflows/bin/seisflows", line 8, in
At first, I thought this problem was related to the numpy version but after I downgraded it to numpy=1.23.5 the above error persisted. The original code in model.py was this:
assert(val.any()), (
f"SPECFEM_{self.flavor} model '{key}' has no values, please "
f"check your input model `path_model_init` and the chosen "
f"`material` which controls the expected parameters"
)
I tried using val.all() instead of val.any() but the error was still there. Since 'val' is a numpy array with more than one element, I thought we were not working with this variable correctly. After trying several ideas, I thought we could evaluate each of the individual arrays in the val list using:
for key, val in self.model.items():
# Modified
print("val:", val) # Just to see if val was an array with more than one element
for array in val:
assert array.all(), (
# Original part
# assert(val.any()), (
f"SPECFEM_{self.flavor} model '{key}' has no values, please "
f"check your input model `path_model_init` and the chosen "
f"`material` which controls the expected parameters"
)
# Make sure none of the values are NaNs
assert(not np.isnan(np.hstack(val).astype(float)).any()), (
f"SPECFEM_{self.flavor} model '{key}' contains NaN values and "
f"should not, please check your model construction"
)
# Check the physicality of the parameters
if self.flavor in ["2D", "3D"]:
self._check_2d3d_parameters(min_pr, max_pr)
elif self.flavor == "3DGLOBE":
self._check_3dglobe_parameters(min_pr, max_pr)
The above modification worked for my particular problem. I haven't analyzed if this can affect other parts of the workflow, but for now I was able to perform the simulation using NPROC > 1 when each processor has a variable workload.
Do you think this change can affect other parts of the seisflows workflow? If not, do you think it could be a solution?
UPDATE
/Users/raul/seisflows/seisflows/tools/model.py:362: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray. model[key] = np.array(model[key])
This warning is because I'm working with lists of different sizes. As far as I know, older version of numpy had no problem dealing with this but now this warning appears. Maybe modifying model[key] = np.array(model[key]) to model[key] = np.array(model[key], dtype=object) could work.
Traceback (most recent call last):
File "/Users/raul/anaconda3/envs/seisflows/bin/seisflows", line 8, in
Maybe a reshaping function could avoid this problem.
Hi @raulleoncz, thanks for the detailed error description. I'll share some thoughts here but would you mind opening this as a new issue as well so that we can continue the discussion outside of the closed PR? Thanks!
Related to #214, tested and contributed by @casarotti
Changelog: