date_to_datestr_bracket Subroutine

public subroutine date_to_datestr_bracket(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 '>'.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: date_array(6)

Datetime [y,m,d,h,m,s]

character(len=*), intent(in) :: in_format_str

Format string

character(len=*), intent(out) :: out_a_str

Date string


Calls

proc~~date_to_datestr_bracket~~CallsGraph proc~date_to_datestr_bracket date_to_datestr_bracket proc~date_to_datestr_new date_to_datestr_new proc~date_to_datestr_bracket->proc~date_to_datestr_new

Called by

proc~~date_to_datestr_bracket~~CalledByGraph proc~date_to_datestr_bracket date_to_datestr_bracket proc~uemep_read_config uEMEP_read_config proc~uemep_read_config->proc~date_to_datestr_bracket proc~uemep_read_meteo_nc uEMEP_read_meteo_nc proc~uemep_read_meteo_nc->proc~date_to_datestr_bracket proc~uemep_calculate_emissions_for_emep uEMEP_calculate_emissions_for_EMEP proc~uemep_calculate_emissions_for_emep->proc~uemep_read_meteo_nc program~uemep uEMEP program~uemep->proc~uemep_read_config program~uemep->proc~uemep_read_meteo_nc program~uemep->proc~uemep_calculate_emissions_for_emep

Source Code

    subroutine date_to_datestr_bracket(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) !! Datetime [y,m,d,h,m,s]
        character(*), intent(in) :: in_format_str !! Format string
        character(*), intent(out) ::  out_a_str !! Date string

        ! 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 the 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_bracket