FIXME : Add documentation
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real, | intent(inout) | :: | delt0 | |||
real, | intent(inout) | :: | delt1 | |||
real, | intent(inout) | :: | delt2 | |||
real, | intent(inout) | :: | delt_max | |||
integer, | intent(out) | :: | istatus | |||
real, | intent(in), | optional | :: | not_set_value |
subroutine init_dt (delt0, delt1, delt2, delt_max, istatus, not_set_value)
# ifdef NETCDF
use mp, only: proc0, broadcast
use file_utils, only: error_unit
use optionals, only: get_option_with_default
# endif
implicit none
real, intent (in out) :: delt0, delt1, delt2, delt_max
integer, intent (out) :: istatus
real, intent(in), optional :: not_set_value
# ifdef NETCDF
character (run_name_size) :: file_proc
real :: not_set_value_to_use
logical :: is_one_file_per_processor
is_one_file_per_processor = read_many .or. (.not. has_netcdf_parallel)
if (proc0) then
file_proc = get_file_proc(is_one_file_per_processor)
istatus = nf90_open (file_proc, NF90_NOWRITE, ncid)
if (istatus /= NF90_NOERR) call netcdf_error (istatus,file=file_proc)
not_set_value_to_use = get_option_with_default(not_set_value, -1.0)
! Note unlike the explicit source terms all three time steps should always
! be available in the restart file so we don't silence the error messages here.
! The only situation we are likely to come across where the delt1 and delt2
! values aren't available is where we are trying to read an old restart file.
! This will then lead to the error/warning being displayed but the code should
! carry on as intended and the missing steps will be set to a special value to
! indicate they have not been set yet.
istatus = nf90_inq_varid (ncid, "delt0", delt0id)
if (istatus /= NF90_NOERR) call netcdf_error (istatus, var='delt0')
istatus = nf90_get_var (ncid, delt0id, delt0)
if (istatus /= NF90_NOERR) then
call netcdf_error (istatus, ncid, delt0id, message=' in init_dt')
delt0 = not_set_value_to_use
endif
istatus = nf90_inq_varid (ncid, "delt1", delt1id)
if (istatus /= NF90_NOERR) call netcdf_error (istatus, var='delt1')
istatus = nf90_get_var (ncid, delt1id, delt1)
if (istatus /= NF90_NOERR) then
call netcdf_error (istatus, ncid, delt1id, message=' in init_dt')
delt1 = not_set_value_to_use
endif
istatus = nf90_inq_varid (ncid, "delt2", delt2id)
if (istatus /= NF90_NOERR) call netcdf_error (istatus, var='delt2')
istatus = nf90_get_var (ncid, delt2id, delt2)
if (istatus /= NF90_NOERR) then
call netcdf_error (istatus, ncid, delt2id, message=' in init_dt')
delt2 = not_set_value_to_use
endif
istatus = nf90_inq_varid (ncid, "delt_max", delt_max_id)
if (istatus /= NF90_NOERR) call netcdf_error (istatus, var='delt_max')
istatus = nf90_get_var (ncid, delt_max_id, delt_max)
if (istatus /= NF90_NOERR) then
call netcdf_error (istatus, ncid, delt_max_id, message=' in init_dt')
delt_max = not_set_value_to_use
endif
istatus = nf90_close (ncid)
endif
call broadcast (istatus)
call broadcast (delt0)
call broadcast (delt1)
call broadcast (delt2)
call broadcast (delt_max)
# endif
end subroutine init_dt