CTSM icon indicating copy to clipboard operation
CTSM copied to clipboard

Make endrun calls consistently use errMsg which gives line number, remove subname, and "ERROR::" prepending it

Open ekluzek opened this issue 4 years ago • 0 comments

@billsacks did some work on this in #1447. In there I suggested a few other changes that would be good to do.

Make sure errMsg is always used which gives the line number of the file, so allows you to easily find the problem. As such we should remove the use of "subname" which needs to be maintained if the subroutine name changes whereas the errMsg automatically updates the line number. We can also remove prepending the error message to endrun with a "ERROR::" as it's already in the shr_sys_abort call in endrun.

Also note that for unit testing to work, and to check error messaging, you have to have fixed text. So the endrun call should have a fixed message, and a separate line should give the line number and file info. So you should do something like this:

             write(iulog,*) errMsg(sourcefile, __LINE__)
             call endrun(msg=subname// &
                  ' ERROR: Cannot find any input points matching output point')

Alternatively we could add file and line to endrun as optional arguments.

Definition of done:

  • [ ] Agree on the right way to do this
  • [ ] Implement a change to endrun arguments if we decide to go that way
  • [ ] Start using this pattern for new code coming in
  • [ ] Apply this change everywhere

ekluzek avatar Aug 04 '21 21:08 ekluzek