Skip to content

Commit 44ee2f8

Browse files
committed
Fix premature use of optional argument in mpas_get_stream_filename
If no optional `ierr` argument is provided in calling the subroutine `mpas_get_stream_filename()` the model segfaults by trying to assign to the nonexistent argument. Additionally, `ierr` is set to zero to initialize, but as this module uses its own error codes it should instead use `MPAS_STREAM_MGR_NOERR`. This change checks if `ierr` is present, and if so initializes it to `MPAS_STREAM_MGR_NOERR`.
1 parent db6dbba commit 44ee2f8

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/framework/mpas_stream_manager.F

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4073,7 +4073,9 @@ subroutine mpas_get_stream_filename(manager, streamID, when, blockID, filename,
40734073
type (MPAS_TimeInterval_type) :: filename_interval
40744074
type (MPAS_Time_type) :: now_time
40754075

4076-
ierr = 0
4076+
if ( present(ierr) ) then
4077+
ierr = MPAS_STREAM_MGR_NOERR
4078+
end if
40774079

40784080
if ( present(blockID) ) then
40794081
blockID_local = blockID

0 commit comments

Comments
 (0)