Skip to content
Snippets Groups Projects
Commit 67b1f786 authored by Luis Kornblueh's avatar Luis Kornblueh
Browse files

Next step of iconatm finished.

parent a6940dc7
No related branches found
No related tags found
No related merge requests found
......@@ -26,3 +26,4 @@ test/iconatm
test/iconoce
test/output_control
test/recurrence
test/repetitor
program iconatm
use mtime
implicit none
character(len=max_calendar_str_len) :: calendar_in_use
character(len=max_datetime_str_len) :: dstring
character(len=max_timedelta_str_len) :: tdstring
type(datetime), pointer :: experiment_start_date => null()
type(datetime), pointer :: experiment_stop_date => null()
type(datetime), pointer :: experiment_end_date => null()
type(datetime), pointer :: start_date => null()
type(datetime), pointer :: stop_date => null()
......@@ -30,65 +27,130 @@ program iconatm
type(timedelta), pointer :: model_time_step => null()
type(datetime), pointer :: current_date => null()
! setup of calendar
call setCalendar(year_of_365_days) ! proleptic_gregorian/year_of_365_days/year_of_360_days.
character(len=max_calendar_str_len) :: calendar_in_use
character(len=max_datetime_str_len) :: dstring
character(len=max_timedelta_str_len) :: tdstring
! namelist variables
character(len=max_calendar_str_len) :: calendar
character(len=max_datetime_str_len) :: experimentStartDate
character(len=max_datetime_str_len) :: experimentEndDate
character(len=max_timedelta_str_len) :: modelTimeStep
character(len=max_repetition_str_len) :: advectionTimeInterval
character(len=max_repetition_str_len) :: radiationTimeInterval
character(len=max_repetition_str_len) :: convectionTimeInterval
character(len=max_repetition_str_len) :: cloudTimeInterval
character(len=max_repetition_str_len) :: ssoTimeInterval
character(len=max_repetition_str_len) :: gwdragTimeInterval
character(len=max_repetition_str_len) :: checkpointTimeInterval
character(len=max_repetition_str_len) :: restartTimeInterval
character(len=max_repetition_str_len) :: couplingTimeInterval
character(len=132) :: error_message
namelist /timeControl/ &
& calendar, &
& experimentStartDate, &
& experimentEndDate, &
& modelTimeStep, &
& advectionTimeInterval, &
& radiationTimeInterval, &
& convectionTimeInterval, &
& cloudTimeInterval, &
& ssoTimeInterval, &
& gwdragTimeInterval, &
& checkpointTimeInterval, &
& restartTimeInterval, &
& couplingTimeInterval
integer :: iunit, icalendar, ierror
open (file='test/iconatm.nml', newunit=iunit, iostat=ierror)
if (ierror /= 0) then
print *, 'ERROR: could not open namelist file.'
stop
else
read (unit=iunit, nml=timeControl, iostat=ierror, iomsg=error_message)
if (ierror /= 0) then
print *, 'ERROR: could not read namelist file.'
print *, ' ', trim(error_message)
stop
endif
close (unit=iunit)
endif
select case (toLower(calendar))
case ('proleptic gregorian')
icalendar = proleptic_gregorian
case ('365 day year')
icalendar = year_of_365_days
case ('360 day year')
icalendar = year_of_360_days
case default
icalendar = calendar_not_set
print *, 'ERROR: calendar ', trim(calendar), ' not available.'
stop
end select
call setCalendar(icalendar)
call calendarToString(calendar_in_use)
print *, 'Calendar: ', TRIM(calendar_in_use)
! set defaults for dates
start_date => newDatetime('1978-01-01')
call datetimeToString(start_date, dstring)
print *, 'Start date: ', trim(dstring)
print *, 'Calendar: ', trim(calendar_in_use)
experiment_start_date => newDatetime(experimentStartDate)
call datetimeToString(experiment_start_date, dstring)
print *, 'Experiment start date: ', dstring
experiment_end_date => newDatetime(experimentEndDate)
call datetimeToString(experiment_end_date, dstring)
print *, 'Experiment end date : ', dstring
model_time_step => newTimedelta(modelTimeStep)
call timedeltaToString(model_time_step, tdstring)
print *, 'Dynamics time step: ', trim(tdstring)
stop_date => newDatetime('2008-01-01')
call datetimeToString(stop_date, dstring)
print *, 'Stop date : ', trim(dstring)
physics_time_intervals: block
experiment_start_date = start_date
call datetimeToString(experiment_start_date, dstring)
print *, 'Experiment start date: ', trim(dstring)
character(len=max_repetition_str_len) :: r, s, e, d
logical :: lr, ls, le, ld
experiment_stop_date = stop_date
call datetimeToString(experiment_stop_date, dstring)
print *, 'Experiment stop date : ', trim(dstring)
call splitRepetitionString(advectionTimeInterval, &
& r, s, e, d, lr, ls, le, ld)
dynamic_time_step => newTimedelta('PT120S')
call timedeltaToString(dynamic_time_step, tdstring)
print *, 'Dynamics tim step: ', trim(tdstring)
if (lr) then
if (getRepetitions(r) /= -1) then
print *, 'WARNING: event setup should not have explicit repeat count.'
endif
endif
advection_time_step => newTimedelta('PT600S')
if (ls) then
print *, 'WARNING: event setup should not have explicit start date.'
endif
radiation_time_step => newTimedelta('PT1800S')
convection_time_step => newTimedelta('PT600S')
cloud_cover_time_step => newTimedelta('PT600S')
sso_time_step => newTimedelta('PT1200S')
gwdrag_time_step => newTimedelta('PT1200S')
if (le) then
print *, 'WARNING: event setup should not have explicit end date.'
endif
checkpoint_time_step => newTimedelta('PT86400S')
restart_time_step => newTimedelta('P1M')
if (ld) then
advection_time_step => newTimeDelta(d)
call timedeltaToString(advection_time_step, tdstring)
print *, 'Advection time interval: ', trim(tdstring)
endif
coupling_time_step => newTimedelta('PT21600S')
model_time_step => newTimedelta('PT600S')
end block physics_time_intervals
! time_step => newTimedelta('PT12H')
! call timedeltaToString(time_step, time_step_string)
! print *, 'Model time step : ', trim(time_step_string)
current_date => newDatetime(experiment_start_date)
! current_date => newDatetime('2012-09-01T02:10:00.000')
! ! copy operator - overload newDatetime using construct and copy!
! ! current_date = start_date
! call datetimeToString(current_date, current_date_string)
! print *, 'Model time : ', trim(current_date_string)
! time_integration: do
! current_date = current_date + time_step
! call datetimeToString(current_date, current_date_string)
! print *, 'Model time loop : ', trim(current_date_string)
! if (current_date >= stop_date) exit time_integration
! enddo time_integration
time_integration: do
current_date = current_date + model_time_step
call datetimeToString(current_date, dstring)
print *, 'Model time loop : ', trim(dstring)
if (current_date >= experiment_end_date) exit time_integration
enddo time_integration
! call datetimeToString(current_date, current_date_string)
! print *, 'Model stop time : ', trim(current_date_string)
......@@ -181,4 +243,24 @@ program iconatm
! end subroutine event_tests
contains
pure function toLower (str) result (string)
character(*), intent(in) :: str
character(len(str)) :: string
integer :: ic, i
character(len=26), parameter :: capitel = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
character(len=26), parameter :: lower = 'abcdefghijklmnopqrstuvwxyz'
string = str
do i = 1, LEN_TRIM(str)
ic = INDEX(capitel, str(i:i))
if (ic > 0) string(i:i) = lower(ic:ic)
end do
end function toLower
end program iconatm
&timeControl
calendar = 'proleptic Gregorian'
experimentStartDate = '2000-01-01T00:00:00'
experimentEndDate = '2000-01-02T00:00:00'
modelTimeStep = 'PT2M'
advectionTimeInterval = 'R/PT12M'
radiationTimeInterval = 'R/PT1H'
convectionTimeInterval = 'R/PT12M'
cloudTimeInterval = 'R/PT12M'
ssoTimeInterval = 'R/PT12M'
gwdragTimeInterval = 'R/PT12M'
checkpointTimeInterval = 'R/P5D'
restartTimeInterval = 'R/P1M'
couplingTimeInterval = 'R/PT2H'
/
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment