Skip to content

Commit

Permalink
Merge branch 'main' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
mathomp4 committed Mar 20, 2024
2 parents 7764546 + c5707a2 commit c729866
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 11 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,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 @@ -3267,7 +3267,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 @@ -3656,13 +3657,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 @@ -5184,7 +5208,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 @@ -5195,10 +5219,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

0 comments on commit c729866

Please sign in to comment.