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

bug: formatted write too long for specified number of characters #2329

Open
hwreeves-USGS opened this issue Oct 8, 2024 · 0 comments
Open
Labels

Comments

@hwreeves-USGS
Copy link

hwreeves-USGS commented Oct 8, 2024

I ran into an error in formatted write for a MT3D-USGS SSM file.
Flopy is using util_list.py, write_transient() function to
generate the package.

For large values, the writing using %10G format does not stay in
10 characters:

    92         0 # stress period 20
     1        63       253    604784        15
     1        63       254    604784        15
     1        63       255    604784        15
     1        63       256    604784        15
     1        64       252    604784        15
     1        64       253    604784        15
     1        64       254    604784        15
     1        64       255    604784        15
     1        64       256    604784        15
     1        64       257    604784        15
     1        65       252    604784        15
     1        65       253    604784        15
     1        65       254    604784        15
     1        65       255    604784        15
     1        65       256    604784        15
     1        65       257    604784        15
     1        66       252    604784        15
     1        66       253    604784        15
     1        66       254    604784        15
     1        66       255    604784        15
     1        66       256    604784        15
     1        66       257    604784        15
     1       125       2041.21784E+06        15
     1       125       2051.21784E+06        15
     1       126       2041.21784E+06        15

The exponential is not read correctly by MT3D-USGS,
so the specified loading is taken as
1.21784 and the source type is wrong to the output file.
MT3D-USGS is not throwing an error. Note that flopy throws and
error when trying to read this file back in because it
is getting '6 1' where it expects an integer.

If the specification for ftm_string property is updated in flopy util_list.py
elif vtype == "f":
if use_free:
fmts.append("%15s")
else:
fmts.append("%10G")

is updated to
elif vtype == "f":
if use_free:
fmts.append("%15s")
else:
fmts.append("%10.4G")

then the input file looks OK.

    92         0 # stress period 20
     1        63       253 6.048E+05        15
     1        63       254 6.048E+05        15
     1        63       255 6.048E+05        15
     1        63       256 6.048E+05        15
     1        64       252 6.048E+05        15
     1        64       253 6.048E+05        15
     1        64       254 6.048E+05        15
     1        64       255 6.048E+05        15
     1        64       256 6.048E+05        15
     1        64       257 6.048E+05        15
     1        65       252 6.048E+05        15
     1        65       253 6.048E+05        15
     1        65       254 6.048E+05        15
     1        65       255 6.048E+05        15
     1        65       256 6.048E+05        15
     1        65       257 6.048E+05        15
     1        66       252 6.048E+05        15
     1        66       253 6.048E+05        15
     1        66       254 6.048E+05        15
     1        66       255 6.048E+05        15
     1        66       256 6.048E+05        15
     1        66       257 6.048E+05        15
     1       125       204 1.218E+06        15
     1       125       205 1.218E+06        15

I didn't submit it as a pull request in case this change might
cause problems for other cases. I've only tested this
on Windows but can check if the same happens for linux
if that is helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant