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

fix(urword): increase number of characters for integers and floats #2067

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

langevin-usgs
Copy link
Contributor

@langevin-usgs langevin-usgs commented Nov 21, 2024

There was a 30 character limit hardwired into urword. This seemed arbitrary and could cause problems for programs like PEST as described in #1638. This PR relieves this restriction and instead defers to the Fortran casting from a string to an integer to determine if there is a problem.

Simple fix is to change from

100 if (ncode == 2 .or. ncode == 3) then
      rw = ' '
      l = 30 - istop + istart
      if (l < 1) go to 200
      rw(l:30) = line(istart:istop)
      if (ncode == 2) read (rw, '(i30)', err=200) n
      if (ncode == 3) read (rw, '(f30.0)', err=200) r
    end if
    return

to

100 if (ncode == 2 .or. ncode == 3) then
      l = istop - istart + 1
      if (l < 1) go to 200
      if (istart > linlen) then
        ! support legacy urword behavior to return a zero value when
        ! no more data is on the line
        if (ncode == 2) n = 0
        if (ncode == 3) r = DZERO
      else
        if (ncode == 2) read (line(istart:istop), *, err=200) n
        if (ncode == 3) read (line(istart:istop), *, err=200) r
      end if
    end if
    return

Checklist of items for pull request

For additional information see instructions for contributing and instructions for developing.

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

Successfully merging this pull request may close these issues.

1 participant