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

fixes #2657 #2658

Merged
merged 3 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Deprecated

## [2.44.1] - 2024-03-19

### Fixed

- Fix bug where bit-shaved, instantaneous binary output in History was modifying the original export state passed

## [2.44.0] - 2024-02-08

### Added
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ endif ()

project (
MAPL
VERSION 2.44.0
VERSION 2.44.1
LANGUAGES Fortran CXX C) # Note - CXX is required for ESMF

# Set the possible values of build type for cmake-gui
Expand Down
40 changes: 30 additions & 10 deletions gridcomps/History/MAPL_HistoryGridComp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -3253,7 +3253,8 @@ subroutine Run ( gc, import, export, clock, rc )
integer :: n,m
logical, allocatable :: NewSeg(:)
logical, allocatable :: Writing(:)
type(ESMF_State) :: state_out
type(ESMF_State) :: state_out, final_state
type(ESMF_Field) :: temp_field, state_field
integer :: nymd, nhms
character(len=ESMF_MAXSTR) :: DateStamp
type(ESMF_Time) :: current_time
Expand Down Expand Up @@ -3626,13 +3627,36 @@ subroutine Run ( gc, import, export, clock, rc )
INTSTATE%LCTL(n) = .false.
endif

call shavebits(state_out, list(n), _RC)
if (list(n)%nbits_to_keep < MAPL_NBITS_UPPER_LIMIT) then
final_state = ESMF_StateCreate(_RC)
do m=1,list(n)%field_set%nfields
call ESMF_StateGet(state_out,trim(list(n)%field_set%fields(3,m)),state_field,_RC)
temp_field = MAPL_FieldCreate(state_field,list(n)%field_set%fields(3,m),DoCopy=.true.,_RC)
call ESMF_StateAdd(final_state,[temp_field],_RC)
enddo
call ESMF_AttributeCopy(state_out,final_state,_RC)
call shavebits(final_state,list(n),_RC)
end if

do m=1,list(n)%field_set%nfields
call MAPL_VarWrite ( list(n)%unit, STATE=state_out, &
NAME=trim(list(n)%field_set%fields(3,m)), &
forceWriteNoRestart=.true., _RC )
if (list(n)%nbits_to_keep >=MAPL_NBITS_UPPER_LIMIT) then
call MAPL_VarWrite ( list(n)%unit, STATE=state_out, &
NAME=trim(list(n)%field_set%fields(3,m)), &
forceWriteNoRestart=.true., _RC )
else
call MAPL_VarWrite ( list(n)%unit, STATE=final_state, &
NAME=trim(list(n)%field_set%fields(3,m)), &
forceWriteNoRestart=.true., _RC )
endif
enddo

if (list(n)%nbits_to_keep < MAPL_NBITS_UPPER_LIMIT) then
do m=1,list(n)%field_set%nfields
call ESMF_StateGet(final_state,trim(list(n)%field_set%fields(3,m)),temp_field,_RC)
call ESMF_FieldDestroy(temp_field,noGarbage=.true.,_RC)
enddo
call ESMF_StateDestroy(final_state,noGarbage=.true.,_RC)
end if
call WRITE_PARALLEL("Wrote GrADS Output for File: "//trim(filename(n)))

end if IOTYPE
Expand Down Expand Up @@ -5154,7 +5178,7 @@ subroutine checkIfStateHasField(state, fieldName, hasField, rc)
_RETURN(ESMF_SUCCESS)
end subroutine checkIfStateHasField

subroutine shavebits( state, list, rc)
subroutine shavebits( state, list, rc)
type(ESMF_state), intent(inout) :: state
type (HistoryCollection), intent(in) :: list
integer, optional, intent(out):: rc
Expand All @@ -5165,10 +5189,6 @@ subroutine shavebits( state, list, rc)
type(ESMF_VM) :: vm
integer :: comm

if (list%nbits_to_keep >=MAPL_NBITS_UPPER_LIMIT) then
_RETURN(ESMF_SUCCESS)
endif

call ESMF_VMGetCurrent(vm,_RC)
call ESMF_VMGet(vm,mpiCommunicator=comm,_RC)

Expand Down