Skip to content

Commit

Permalink
Fix bug in TimeMethods
Browse files Browse the repository at this point in the history
  • Loading branch information
mathomp4 committed Feb 5, 2022
1 parent 070caf3 commit bca7d54
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
### Fixed

## [2.8.0.3] - 2022-02-05

### Fixed

- Fixed bug `MAPL_TimeMethods::define_time_variable` where metadata was set before Variable initialized

## [2.8.0.2] - 2022-01-19

### Changed
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cmake_policy (SET CMP0054 NEW)

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

# mepo can now clone subrepos in three styles
Expand Down
17 changes: 9 additions & 8 deletions base/MAPL_TimeMethods.F90
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,9 @@ function define_time_variable(this,rc) result(v)
integer :: status
character(len=ESMF_MAXSTR) :: startTime,timeUnits
type(ESMF_Time) :: currTime
integer :: i1,i2,i3,i123,ipos1,ipos2,isc,imn,ihr,ifreq
integer :: i1,i2,i3,i123,ipos1,ipos2,isc,imn,ihr,time_increment
logical :: integer_time
integer :: begin_date, begin_time

call ESMF_CLockGet(this%clock,currTime=currTime,rc=status)
_VERIFY(status)
Expand All @@ -100,16 +101,14 @@ function define_time_variable(this,rc) result(v)
read(startTime(1:ipos1-1),'(i4)')i1
read(startTime(ipos1+1:ipos2-1),'(i2)')i2
read(startTime(ipos2+1:10),'(i2)')i3
i123=10000*i1+100*i2+i3
call v%add_attribute('begin_date',i123)
begin_date=10000*i1+100*i2+i3

ipos1=index(startTime,":")
ipos2=index(startTime,":",back=.true.)
read(startTime(12:ipos1-1),'(i2)')i1
read(startTime(ipos1+1:ipos2-1),'(i2)')i2
read(startTime(ipos2+1:19),'(i2)')i3
i123=10000*i1+100*i2+i3
call v%add_attribute('begin_time',i123)
begin_time=10000*i1+100*i2+i3

select case(trim(this%funits))
case('minutes')
Expand All @@ -120,14 +119,13 @@ function define_time_variable(this,rc) result(v)
imn=mod(i2,60)
i2=i2-imn
ihr=i2/60
ifreq=10000*ihr+100*imn+isc
time_increment=10000*ihr+100*imn+isc
case('days')
ifreq = this%frequency/86400
time_increment = this%frequency/86400
integer_time = mod(this%frequency,86400) == 0
case default
_ASSERT(.false., 'Not supported yet')
end select
call v%add_attribute('time_increment',ifreq)

call this%tvec%clear()
this%tcount=0
Expand All @@ -141,6 +139,9 @@ function define_time_variable(this,rc) result(v)
end if
call v%add_attribute('long_name','time')
call v%add_attribute('units',trim(timeUnits))
call v%add_attribute('begin_date',begin_date)
call v%add_attribute('begin_time',begin_time)
call v%add_attribute('time_increment',time_increment)


_RETURN(ESMF_SUCCESS)
Expand Down

0 comments on commit bca7d54

Please sign in to comment.