787 type(param_file_type),
intent(in) :: cs
788 character(len=*),
intent(in) :: varname
789 type(time_type),
intent(inout) :: value
790 real,
optional,
intent(in) :: timeunit
791 logical,
optional,
intent(in) :: fail_if_missing
792 logical,
optional,
intent(out) :: date_format
799 character(len=INPUT_STR_LENGTH) :: value_string(1)
800 character(len=240) :: err_msg
801 logical :: found, defined
802 real :: real_time, time_unit
803 integer :: days, secs, vals(7)
805 if (
present(date_format)) date_format = .false.
807 call get_variable_line(cs, varname, found, defined, value_string)
808 if (found .and. defined .and. (len_trim(value_string(1)) > 0))
then 811 if ((index(value_string(1),
'-') > 0) .and. &
812 (index(value_string(1),
'-',back=.true.) > index(value_string(1),
'-')))
then 814 value = set_date(value_string(1), err_msg=err_msg)
815 if (len_trim(err_msg) > 0)
call mom_error(fatal,
'read_param_time: '//&
816 trim(err_msg)//
' in integer list read error for time-type variable '//&
817 trim(varname)//
' parsing "'//trim(value_string(1))//
'"')
818 if (
present(date_format)) date_format = .true.
819 elseif (index(value_string(1),
',') > 0)
then 821 vals(:) = (/ -999, -999, -999, 0, 0, 0, 0 /)
822 read(value_string(1),*,end=995,err=1005) vals
824 if ((vals(1) < 0) .or. (vals(2) < 0) .or. (vals(3) < 0)) &
825 call mom_error(fatal,
'read_param_time: integer list read error for time-type variable '//&
826 trim(varname)//
' parsing "'//trim(value_string(1))//
'"')
827 value = set_date(vals(1), vals(2), vals(3), vals(4), vals(5), vals(6), &
828 vals(7), err_msg=err_msg)
829 if (len_trim(err_msg) > 0)
call mom_error(fatal,
'read_param_time: '//&
830 trim(err_msg)//
' in integer list read error for time-type variable '//&
831 trim(varname)//
' parsing "'//trim(value_string(1))//
'"')
832 if (
present(date_format)) date_format = .true.
834 time_unit = 1.0 ;
if (
present(timeunit)) time_unit = timeunit
835 read( value_string(1), *) real_time
836 days = int(real_time*(time_unit/86400.0))
837 secs = int(floor((real_time*(time_unit/86400.0)-days)*86400.0 + 0.5))
838 value = set_time(secs, days)
841 if (
present(fail_if_missing))
then ;
if (fail_if_missing)
then 843 call mom_error(fatal,
'Unable to find variable '//trim(varname)// &
844 ' in any input files.')
846 call mom_error(fatal,
'Variable '//trim(varname)// &
847 ' found but not set in input files.')
852 1005
call mom_error(fatal,
'read_param_time: read error for time-type variable '//&
853 trim(varname)//
' parsing "'//trim(value_string(1))//
'"')