Converts a date array to a date string with brackets in format string
format string brackets are '<' and '>'.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | date_array(6) | |||
character(len=*), | intent(in) | :: | in_format_str | |||
character(len=*), | intent(out) | :: | out_a_str |
subroutine date_to_datestr_squarebracket(date_array, in_format_str, out_a_str) !! Converts a date array to a date string with brackets in format string !! !! format string brackets are '<' and '>'. integer, intent(in) :: date_array(6) character(*), intent(in) :: in_format_str character(*), intent(out) :: out_a_str ! Local variables character(256) :: format_str, a_str integer :: pos1, pos2 ! Only changes dates when they are inside '[.....]' ! Removes these once changed pos1 = index(in_format_str, '[') pos2 = index(in_format_str, ']') if (pos1 .le. 0 .or. pos2 .le. 0 .or. pos1+1 .gt. pos2-1) then out_a_str = in_format_str return end if ! Reassign format_str to be just the text between <..> format_str = in_format_str(pos1+1:pos2-1) a_str = format_str ! Get date string call date_to_datestr_new(date_array, format_str, a_str) ! Insert the a_str into out_a_str, removing the '[]' text if (len_trim(in_format_str) .gt. pos2) then out_a_str = in_format_str(1:pos1-1)//trim(a_str)//in_format_str(pos2+1:) else out_a_str = in_format_str(1:pos1-1)//trim(a_str) end if end subroutine date_to_datestr_squarebracket