date_to_datestr_new Subroutine

private subroutine date_to_datestr_new(date_array, in_format_str, out_a_str)

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


Called by

proc~~date_to_datestr_new~~CalledByGraph proc~date_to_datestr_new date_to_datestr_new proc~date_to_datestr_bracket date_to_datestr_bracket proc~date_to_datestr_bracket->proc~date_to_datestr_new proc~date_to_datestr_squarebracket date_to_datestr_squarebracket proc~date_to_datestr_squarebracket->proc~date_to_datestr_new proc~uemep_read_config uEMEP_read_config proc~uemep_read_config->proc~date_to_datestr_bracket proc~uemep_read_config->proc~date_to_datestr_squarebracket 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_new(date_array, in_format_str, out_a_str)
        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
        integer :: pos
        
        ! Extract elements of the date string
        pos = index(in_format_str, 'yyyy')
        if (pos .gt. 0) then
            write(out_a_str(pos:pos+3),'(i4)') date_array(1)
        end if

        pos = index(in_format_str, 'mm')
        if (pos .gt. 0) then
            if (date_array(2) .gt. 9) then
                write(out_a_str(pos:pos+1),'(i2)') date_array(2)
            else
                write(out_a_str(pos:pos+1),'(a1,i1)') '0', date_array(2)
            end if
        end if

        pos = index(in_format_str, 'dd')
        if (pos.gt.0) then
            if (date_array(3) .gt. 9) then
                write(out_a_str(pos:pos+1),'(i2)') date_array(3)
            else
                write(out_a_str(pos:pos+1),'(a1,i1)') '0', date_array(3)
            end if
        end if

        pos = index(in_format_str, 'HH')
        if (pos .gt. 0) then
            if (date_array(4) .gt. 9) then
                write(out_a_str(pos:pos+1),'(i2)') date_array(4)
            else
                write(out_a_str(pos:pos+1),'(a1,i1)') '0', date_array(4)
            end if
        end if

        pos = index(in_format_str,'MM')
        if (pos .gt. 0) then
            if (date_array(5) .gt. 9) then
                write(out_a_str(pos:pos+1),'(i2)') date_array(5)
            else
                write(out_a_str(pos:pos+1),'(a1,i1)') '0', date_array(5)
            end if
        end if

        pos = index(in_format_str,'SS')
        if (pos .gt. 0) then
            if (date_array(6) .gt. 9) then
                write(out_a_str(pos:pos+1),'(i2)') date_array(6)
            else
                write(out_a_str(pos:pos+1),'(a1,i1)') '0', date_array(6)
            end if
        end if
    end subroutine date_to_datestr_new