uEMEP_reset_constants Subroutine

public subroutine uEMEP_reset_constants()

Uses

  • proc~~uemep_reset_constants~~UsesGraph proc~uemep_reset_constants uEMEP_reset_constants module~uemep_definitions uEMEP_definitions proc~uemep_reset_constants->module~uemep_definitions

Arguments

None

Called by

proc~~uemep_reset_constants~~CalledByGraph proc~uemep_reset_constants uEMEP_reset_constants program~uemep uEMEP program~uemep->proc~uemep_reset_constants

Source Code

    subroutine uEMEP_reset_constants
        !Reset some constants based on the configuration file input
        use uEMEP_definitions
        implicit none

        integer index_start
        character(256) prefix_str,postfix_str
        integer i,j
        character(8) sector_str_lf,sector_str_emis
        integer sector_index
        character(256) temp_str
        integer i_comp,i_source,p_loop
        character(256) local_fraction_naming_template_str_temp,local_fraction_grid_size_str

        if (index(alternative_meteorology_type,'nortrip').gt.0) then
            var_name_meteo_nc(lon_nc_index)='lon'
            var_name_meteo_nc(lat_nc_index)='lat'
        endif

        !Reset meteorological names
        if (index(alternative_meteorology_type,'nbv').gt.0) then
            dim_name_meteo_nc(z_dim_nc_index)='height4'
            var_name_meteo_nc(lon_nc_index)='lon'
            var_name_meteo_nc(lat_nc_index)='lat'
            var_name_meteo_nc(hmix_nc_index)='boundary_layer_height'
            var_name_meteo_nc(logz0_nc_index)='surface_roughness_momentum' !Needs to be converted to log(Z0)
            var_name_meteo_nc(Hflux_nc_index)='surface_upward_sensible_heat_flux'     !Note this is upward not downward so must have a negative when read
            var_name_meteo_nc(precip_nc_index)='precipitation_amount'
        endif

        if (use_EMEP_surface_ozone_flag) then
            comp_name_nc(o3_nc_index)='SURF_ug_O3'
        endif


        !If GNFR19 emissions are true then so are the GNFR13 emissions
        if (use_GNFR19_emissions_from_EMEP_flag) use_GNFR_emissions_from_EMEP_flag=.true.

        !Set the emission sector index to be read to standard GNFR.
        !Not actually used now but could be used in the loop below
        if (use_GNFR_emissions_from_EMEP_flag) then
            uEMEP_to_EMEP_sector(allsource_index)=0
            uEMEP_to_EMEP_sector(traffic_index)=6
            uEMEP_to_EMEP_sector(shipping_index)=7
            uEMEP_to_EMEP_sector(agriculture_index)=12
            uEMEP_to_EMEP_sector(heating_index)=3
            uEMEP_to_EMEP_sector(industry_index)=2
            uEMEP_to_EMEP_sector(publicpower_nc_index)=1
            uEMEP_to_EMEP_sector(fugitive_nc_index)=4
            uEMEP_to_EMEP_sector(solvents_nc_index)=5
            uEMEP_to_EMEP_sector(aviation_nc_index)=8
            uEMEP_to_EMEP_sector(offroad_nc_index)=9
            uEMEP_to_EMEP_sector(waste_nc_index)=10
            uEMEP_to_EMEP_sector(livestock_nc_index)=11
            uEMEP_to_EMEP_sector(other_nc_index)=13
            uEMEP_to_EMEP_sector(publicpower_point_nc_index)=14
            uEMEP_to_EMEP_sector(publicpower_area_nc_index)=15
            uEMEP_to_EMEP_sector(traffic_gasoline_nc_index)=16
            uEMEP_to_EMEP_sector(traffic_diesel_nc_index)=17
            uEMEP_to_EMEP_sector(traffic_gas_nc_index)=18
            uEMEP_to_EMEP_sector(traffic_nonexhaust_nc_index)=19
        endif

        !Create the sector strings, different for emissions to the local fraction strings, no leading 0's
        do i_source=1,n_source_nc_index
            write(temp_str,'(i2)') uEMEP_to_EMEP_sector(i_source)
            if (uEMEP_to_EMEP_sector(i_source).lt.10) then
                uEMEP_to_EMEP_sector_str(i_source)='0'//trim(adjustl(temp_str))
            else
                uEMEP_to_EMEP_sector_str(i_source)=trim(temp_str)
            endif

            write(uEMEP_to_EMEP_emis_sector_str(i_source),'(i2)') uEMEP_to_EMEP_sector(i_source)
            uEMEP_to_EMEP_emis_sector_str(i_source)=adjustl(uEMEP_to_EMEP_emis_sector_str(i_source))
            if (i_source.eq.allsource_nc_index) then
                uEMEP_to_EMEP_emis_sector_str(i_source)=''
                uEMEP_to_EMEP_sector_str(i_source)=''
            endif

            !write(*,*) i_source,uEMEP_to_EMEP_sector_str(i_source),' ',uEMEP_to_EMEP_emis_sector_str(i_source)

        enddo

        if (use_alphabetic_GNFR_emissions_from_EMEP_flag) then
            uEMEP_to_EMEP_emis_sector_str(allsource_index)=''
            uEMEP_to_EMEP_emis_sector_str(traffic_index)='F'
            uEMEP_to_EMEP_emis_sector_str(shipping_index)='G'
            uEMEP_to_EMEP_emis_sector_str(agriculture_index)='L'
            uEMEP_to_EMEP_emis_sector_str(heating_index)='C'
            uEMEP_to_EMEP_emis_sector_str(industry_index)='B'
            uEMEP_to_EMEP_emis_sector_str(publicpower_nc_index)='A'
            uEMEP_to_EMEP_emis_sector_str(fugitive_nc_index)='D'
            uEMEP_to_EMEP_emis_sector_str(solvents_nc_index)='E'
            uEMEP_to_EMEP_emis_sector_str(aviation_nc_index)='H'
            uEMEP_to_EMEP_emis_sector_str(offroad_nc_index)='I'
            uEMEP_to_EMEP_emis_sector_str(waste_nc_index)='J'
            uEMEP_to_EMEP_emis_sector_str(livestock_nc_index)='K'
            uEMEP_to_EMEP_emis_sector_str(other_nc_index)='M'
            uEMEP_to_EMEP_emis_sector_str(traffic_gasoline_nc_index)='F1'
            uEMEP_to_EMEP_emis_sector_str(traffic_diesel_nc_index)='F2'
            uEMEP_to_EMEP_emis_sector_str(traffic_gas_nc_index)='F3'
            uEMEP_to_EMEP_emis_sector_str(traffic_nonexhaust_nc_index)='F4'
            uEMEP_to_EMEP_emis_sector_str(publicpower_point_nc_index)='A1'
            uEMEP_to_EMEP_emis_sector_str(publicpower_area_nc_index)='A2'
            uEMEP_to_EMEP_emis_sector_str(traffic_exhaust_nc_index)='F1-3' !Not read
        endif

        save_EMEP_source=calculate_EMEP_source

        !Automatically set these extra files to be read
        !Of these only the traffic exhaust and nonexhaust will be saved
        if (use_GNFR19_emissions_from_EMEP_flag) then
            calculate_EMEP_source(traffic_gasoline_nc_index)=.true.
            calculate_EMEP_source(traffic_diesel_nc_index)=.true.
            calculate_EMEP_source(traffic_gas_nc_index)=.true.
            calculate_EMEP_source(publicpower_point_nc_index)=.true.
            calculate_EMEP_source(publicpower_area_nc_index)=.true.
            calculate_EMEP_source(traffic_exhaust_nc_index)=.true.
            calculate_EMEP_source(traffic_nonexhaust_nc_index)=.true.
            !We do not want to add these since they are already in traffic but we do want to save them
            calculate_EMEP_source(traffic_exhaust_nc_index)=.false.
            calculate_EMEP_source(traffic_nonexhaust_nc_index)=.false.
            save_EMEP_source(traffic_exhaust_nc_index)=.true.
            save_EMEP_source(traffic_nonexhaust_nc_index)=.true.
        endif

        !integer GNFR_index(n_source_nc_index)
        !A 1 �PublicPower� (1)
        !B 2 �Industry� (3)
        !C 3 �OtherStationaryComb� (2)
        !D 4 �Fugitive� (4)
        !E 5 �Solvents� (6)
        !F 6 �RoadTransport� (7)
        !G 7 �Shipping� (8)
        !H 8 �Aviation� (8)
        !I 9 �Offroad� (8)
        !J 10 �Waste� (9)
        !K 11 �AgriLivestock� (10)
        !L 12 �AgriOther� (10)
        !M 13 �Other� (5)

        !These are for the previous EMEP version before 4.3.3
        if (use_GNFR_emissions_from_EMEP_flag) then

            !Local fractions
            var_name_nc(frac_nc_index,nox_nc_index,traffic_nc_index)='nox_sec06_local_fraction'
            var_name_nc(frac_nc_index,pmco_nc_index,traffic_nc_index)='pmco_sec06_local_fraction'
            var_name_nc(frac_nc_index,pm25_nc_index,traffic_nc_index)='pm25_sec06_local_fraction'

            var_name_nc(frac_nc_index,nox_nc_index,shipping_nc_index)='nox_sec07_local_fraction'
            var_name_nc(frac_nc_index,pm25_nc_index,shipping_nc_index)='pm25_sec07_local_fraction'
            var_name_nc(frac_nc_index,pmco_nc_index,shipping_nc_index)='pmco_sec07_local_fraction'

            !var_name_nc(frac_nc_index,nh3_nc_index,agriculture_nc_index)='nh3_sec11_local_fraction'
            !var_name_nc(frac_nc_index,nh3_nc_index,agriculture_nc_index)='nh3_sec12_local_fraction'
            !Read as total for the time being as these have become two sectors now
            var_name_nc(frac_nc_index,nh3_nc_index,agriculture_nc_index)='nh3_local_fraction'

            var_name_nc(frac_nc_index,nox_nc_index,heating_nc_index)='nox_sec03_local_fraction'
            var_name_nc(frac_nc_index,pm25_nc_index,heating_nc_index)='pm25_sec03_local_fraction'
            var_name_nc(frac_nc_index,pmco_nc_index,heating_nc_index)='pmco_sec03_local_fraction'

            var_name_nc(frac_nc_index,nox_nc_index,industry_nc_index)='nox_sec02_local_fraction'
            var_name_nc(frac_nc_index,pm25_nc_index,industry_nc_index)='pm25_sec02_local_fraction'
            var_name_nc(frac_nc_index,pmco_nc_index,industry_nc_index)='pmco_sec02_local_fraction'

            !Total emissions remain the same
            var_name_nc(emis_nc_index,nh3_nc_index,allsource_nc_index)='Emis_mgm2_nh3'
            var_name_nc(emis_nc_index,nox_nc_index,allsource_nc_index)='Emis_mgm2_nox'
            var_name_nc(emis_nc_index,pmco_nc_index,allsource_nc_index)='Emis_mgm2_pmco'
            var_name_nc(emis_nc_index,pm25_nc_index,allsource_nc_index)='Emis_mgm2_pm25'

            !Sector emissions read as total
            var_name_nc(emis_nc_index,nh3_nc_index,agriculture_nc_index)='Emis_mgm2_nh3'

            var_name_nc(emis_nc_index,nox_nc_index,traffic_nc_index)='Emis_mgm2_sec6nox'
            var_name_nc(emis_nc_index,pm25_nc_index,traffic_nc_index)='Emis_mgm2_sec6pm25'
            var_name_nc(emis_nc_index,pmco_nc_index,traffic_nc_index)='Emis_mgm2_sec6pmco'

            var_name_nc(emis_nc_index,nox_nc_index,shipping_nc_index)='Emis_mgm2_sec7nox'
            var_name_nc(emis_nc_index,pm25_nc_index,shipping_nc_index)='Emis_mgm2_sec7pm25'
            var_name_nc(emis_nc_index,pmco_nc_index,shipping_nc_index)='Emis_mgm2_sec7pmco'

            var_name_nc(emis_nc_index,nox_nc_index,heating_nc_index)='Emis_mgm2_sec3nox'
            var_name_nc(emis_nc_index,pm25_nc_index,heating_nc_index)='Emis_mgm2_sec3pm25'
            var_name_nc(emis_nc_index,pmco_nc_index,heating_nc_index)='Emis_mgm2_sec3pmco'

            var_name_nc(emis_nc_index,nox_nc_index,industry_nc_index)='Emis_mgm2_sec2nox'
            var_name_nc(emis_nc_index,pm25_nc_index,industry_nc_index)='Emis_mgm2_sec2pm25'
            var_name_nc(emis_nc_index,pmco_nc_index,industry_nc_index)='Emis_mgm2_sec2pmco'

        endif

        !General setting of names. Overrides all other presets
        do i_comp=1,n_pollutant_nc_index
            do i_source=1,n_source_nc_index

                var_name_nc(frac_nc_index,i_comp,i_source)=trim(var_name_nc(conc_nc_index,i_comp,allsource_nc_index))//'_sec'//trim(uEMEP_to_EMEP_sector_str(i_source))//'_local_fraction'
                var_name_nc(emis_nc_index,i_comp,i_source)='Emis_mgm2_sec'//trim(uEMEP_to_EMEP_emis_sector_str(i_source))//var_name_nc(conc_nc_index,i_comp,allsource_nc_index)
                if (i_source.eq.allsource_nc_index) then
                    var_name_nc(frac_nc_index,i_comp,i_source)=trim(var_name_nc(conc_nc_index,i_comp,allsource_nc_index))//'_local_fraction'
                    var_name_nc(emis_nc_index,i_comp,i_source)='Emis_mgm2_'//var_name_nc(conc_nc_index,i_comp,allsource_nc_index)
                endif
                if (extract_benzene_from_voc_emissions.and.i_comp.eq.c6h6_nc_index) then
                    var_name_nc(emis_nc_index,i_comp,i_source)='Emis_mgm2_sec'//trim(uEMEP_to_EMEP_emis_sector_str(i_source))//'voc'
                endif

                !write(*,*) i_comp,i_source,trim(var_name_nc(frac_nc_index,i_comp,i_source)),trim(var_name_nc(emis_nc_index,i_comp,i_source))
            enddo
        enddo


        if (use_emission_naming_template_flag) then
            !Set the prefix and postfix part of the emission name string based on the template
            !Assumes compound is added at the end

            index_start=INDEX(emission_naming_template_str,'<n>')
            if (index_start.eq.0) then
                prefix_str=''
            else
                prefix_str=emission_naming_template_str(1:index_start-1)
            endif
            if (index_start+3.gt.len_trim(emission_naming_template_str)) then
                postfix_str=''
            else
                postfix_str=emission_naming_template_str(index_start+3:)
            endif

            !write(*,*) index_start,index_start+3,len_trim(emission_naming_template_str)
            if (use_GNFR_emissions_from_EMEP_flag.or.use_alphabetic_GNFR_emissions_from_EMEP_flag) then
                write(unit_logfile,'(a)') 'Using emission name template for GNFR sectors: '//trim(emission_naming_template_str)
                do i=1,n_pollutant_nc_index
                    do i_source=1,n_source_nc_index
                        var_name_nc(emis_nc_index,i,i_source)=trim(prefix_str)//trim(uEMEP_to_EMEP_emis_sector_str(i_source))//trim(postfix_str)//trim(var_name_nc(conc_nc_index,i,allsource_nc_index))
                        if (extract_benzene_from_voc_emissions.and.i.eq.c6h6_nc_index) then
                            var_name_nc(emis_nc_index,i,i_source)=trim(prefix_str)//trim(uEMEP_to_EMEP_emis_sector_str(i_source))//trim(postfix_str)//'voc'
                        endif

                        if (i_source.eq.allsource_nc_index) then
                            var_name_nc(emis_nc_index,i,allsource_nc_index)=trim(prefix_str)//''//trim(postfix_str)//trim(var_name_nc(conc_nc_index,i,allsource_nc_index))
                            if (extract_benzene_from_voc_emissions.and.i.eq.c6h6_nc_index) then
                                var_name_nc(emis_nc_index,i,allsource_nc_index)=trim(prefix_str)//''//trim(postfix_str)//'voc'
                            endif
                            if (use_alphabetic_GNFR_emissions_from_EMEP_flag) then
                                !Remove any leading '_' in the postfix_str
                                index_start=INDEX(postfix_str,'_')
                                if (index_start.eq.1) then
                                    var_name_nc(emis_nc_index,i,allsource_nc_index)=trim(postfix_str(2:))//trim(var_name_nc(conc_nc_index,i,allsource_nc_index))
                                    if (extract_benzene_from_voc_emissions.and.i.eq.c6h6_nc_index) then
                                        var_name_nc(emis_nc_index,i,allsource_nc_index)=trim(postfix_str(2:))//'voc'
                                    endif
                                else
                                    var_name_nc(emis_nc_index,i,allsource_nc_index)=trim(postfix_str)//trim(var_name_nc(conc_nc_index,i,allsource_nc_index))
                                    if (extract_benzene_from_voc_emissions.and.i.eq.c6h6_nc_index) then
                                        var_name_nc(emis_nc_index,i,allsource_nc_index)=trim(postfix_str)//'voc'
                                    endif
                                endif
                            endif
                        endif
                        !write(*,*) i,i_source,trim(var_name_nc(emis_nc_index,i,i_source))

                    enddo
                enddo

            else
                write(unit_logfile,'(a)') 'Using emission name template for SNAP sectors: '//trim(emission_naming_template_str)

                do i=1,n_pollutant_nc_index
                    do i_source=1,n_source_nc_index
                        var_name_nc(emis_nc_index,i,i_source)=trim(prefix_str)//trim(uEMEP_to_EMEP_emis_sector_str(i_source))//trim(postfix_str)//trim(var_name_nc(conc_nc_index,i,allsource_nc_index))
                        if (i_source.eq.allsource_nc_index) then
                            var_name_nc(emis_nc_index,i,allsource_nc_index)=trim(prefix_str)//''//trim(postfix_str)//trim(var_name_nc(conc_nc_index,i,allsource_nc_index))
                            if (extract_benzene_from_voc_emissions.and.i.eq.c6h6_nc_index) then
                                var_name_nc(emis_nc_index,i,allsource_nc_index)=trim(prefix_str)//''//trim(postfix_str)//'voc'
                            endif
                        endif
                    enddo
                enddo
            endif


        endif

        !Set the indexes for the local fraction data and increase the number of variables appropriately
        !Include a conversion array between the local and fraction arrays
        if (use_local_fraction_naming_template_flag) then

            i=0
            do j=1,n_local_fraction_grids
                i=i+1;lc_frac_nc_loop_index(j)=i
            enddo
            do j=1,n_local_fraction_grids
                i=i+1;lc_local_nc_loop_index(j)=i
                !convert_local_to_fraction_loop_index(lc_local_nc_loop_index(j))=lc_frac_nc_loop_index(j)
            enddo
            !do j=1,n_local_fraction_grids
            !    convert_fraction_to_local_loop_index(lc_fraction_nc_loop_index(j))=lc_local_nc_loop_index(j)
            !enddo
            num_lc_var_nc=i
            write(unit_logfile,'(a,i)') 'New number of num_lc_var_nc variables with additional LF EMEP: ',num_lc_var_nc
            min_lc_frac_nc_loop_index=minval(lc_frac_nc_loop_index)
            max_lc_frac_nc_loop_index=maxval(lc_frac_nc_loop_index)

            i=num_var_nc_start
            do j=1,n_local_fraction_grids
                i=i+1;frac_nc_loop_index(j)=i
                convert_frac_to_lc_frac_loop_index(frac_nc_loop_index(j))=lc_frac_nc_loop_index(j)
                !write(*,*) i,j,frac_nc_loop_index(j),convert_frac_to_lc_frac_loop_index(frac_nc_loop_index(j))
            enddo
            do j=1,n_local_fraction_grids
                i=i+1;local_nc_loop_index(j)=i
            enddo
            num_var_nc=i
            write(unit_logfile,'(a,i)') 'New number of num_var_nc variables with additional LF EMEP: ',num_var_nc
            min_frac_nc_loop_index=minval(frac_nc_loop_index)
            max_frac_nc_loop_index=maxval(frac_nc_loop_index)


        endif


        if (use_local_fraction_naming_template_flag) then
            !Set the prefix and postfix part of the emission name string based on the template
            !Assumes compound is added at the end
            do j=1,n_local_fraction_grids
                local_fraction_naming_template_str_temp=local_fraction_naming_template_str
                index_start=INDEX(local_fraction_naming_template_str_temp,'<n>')
                if (index_start.eq.0) then
                    prefix_str=''
                else
                    prefix_str=local_fraction_naming_template_str_temp(1:index_start-1)
                endif
                if (index_start+3.gt.len_trim(local_fraction_naming_template_str_temp)) then
                    postfix_str=''
                else
                    postfix_str=local_fraction_naming_template_str_temp(index_start+3:)
                endif

                !Create the local fraction grid size for appending to the variable name
                write(temp_str,'(i2)') local_fraction_grid_size(j)
                local_fraction_grid_size_str='_'//trim(adjustl(temp_str))//'x'//trim(adjustl(temp_str))
                if (.not.use_local_fraction_grid_size_in_template_flag) then
                    local_fraction_grid_size_str=''
                endif

                !write(*,*) index_start,index_start+3,len_trim(emission_naming_template_str)
                write(unit_logfile,'(a,i)') 'Using local fraction name template: '//trim(local_fraction_naming_template_str_temp)//' for lf grid = ',j
                !do i=1,n_pollutant_nc_index
                do p_loop=1,n_emep_pollutant_loop+1
                    if (p_loop.le.n_emep_pollutant_loop) then
                        i=pollutant_loop_index(p_loop)
                    else
                        i=pmco_nc_index !Necessary to include this
                    endif

                    do i_source=1,n_source_nc_index
                        if (calculate_source(i_source).or.calculate_EMEP_source(i_source).or.save_EMEP_source(i_source).or.i_source.eq.allsource_nc_index) then
                            var_name_nc(frac_nc_loop_index(j),i,i_source)=trim(var_name_nc(conc_nc_index,i,allsource_nc_index))//'_'//trim(prefix_str)//trim(uEMEP_to_EMEP_sector_str(i_source))//trim(postfix_str)//trim(local_fraction_grid_size_str)
                            if (i_source.eq.allsource_nc_index) then
                                var_name_nc(frac_nc_loop_index(j),i,allsource_nc_index)=trim(var_name_nc(conc_nc_index,i,allsource_nc_index))//trim(postfix_str)//trim(local_fraction_grid_size_str)
                            endif
                            write(unit_logfile,'(2i6,2a)') i,i_source,'  ',trim(var_name_nc(frac_nc_loop_index(j),i,i_source))
                        endif
                    enddo
                enddo
            enddo

        endif

        !Only works on the old sectors and lf names
        if (use_user_specified_sectors_flag) then

            write(unit_logfile,'(a)') 'Replacing sector index in EMEP (sector,pollutant,lf_name,emis_name)'

            do sector_index=0,n_source_nc_index
                if (calculate_source(sector_index).and.uEMEP_to_EMEP_replace_sector(sector_index).ge.0) then
                    !sector_index=traffic_nc_index
                    write(sector_str_lf,'(i0.2)') uEMEP_to_EMEP_replace_sector(sector_index)
                    write(sector_str_emis,'(i0.1)') uEMEP_to_EMEP_replace_sector(sector_index)
                    if (uEMEP_to_EMEP_replace_sector(sector_index).ne.0) then
                        sector_str_lf='_sec'//trim(sector_str_lf)
                        sector_str_emis=trim(sector_str_emis)
                    else
                        sector_str_lf=''
                        sector_str_emis=''
                    endif
                    do i=1,n_pollutant_nc_index
                        !Can fix the above problem here
                        if (use_local_fraction_naming_template_flag) then
                            var_name_nc(frac_nc_index,i,sector_index)=trim(prefix_str)//trim(sector_str_lf)//trim(postfix_str)
                        else
                            var_name_nc(frac_nc_index,i,sector_index)=trim(var_name_nc(conc_nc_index,i,allsource_nc_index))//trim(sector_str_lf)//'_local_fraction'
                        endif

                        !var_name_nc(frac_nc_index,pmco_nc_index,sector_index)='pmco'//trim(sector_str)//'_local_fraction'
                        !var_name_nc(frac_nc_index,pm25_nc_index,sector_index)='pm25'//trim(sector_str)//'_local_fraction'

                        if (use_emission_naming_template_flag) then
                            var_name_nc(emis_nc_index,i,sector_index)=trim(prefix_str)//trim(sector_str_emis)//trim(postfix_str)//trim(var_name_nc(conc_nc_index,i,allsource_nc_index))
                        else
                            var_name_nc(emis_nc_index,i,sector_index)='Emis_mgm2_sec'//trim(sector_str_emis)//trim(var_name_nc(conc_nc_index,i,allsource_nc_index))
                        endif

                        write(unit_logfile,'(2i8,a6,i2,a4,i2,a3,2a48)') sector_index,i,' from ',uEMEP_to_EMEP_sector(sector_index),' to ',uEMEP_to_EMEP_replace_sector(sector_index),' : ',trim(var_name_nc(frac_nc_index,i,sector_index)),trim(var_name_nc(emis_nc_index,i,sector_index))

                    enddo

                endif
            enddo
        endif
        !stop
        !write(unit_tile,'(a,i0.5)') 'tile_tag= '//trim(save_tile_tag)//'_',count

        if (use_EMEP_surface_compounds_flag) then
            write(unit_logfile,'(a)') 'Using EMEP surface compounds instead of gridded'
            comp_name_nc(o3_nc_index)='SURF_ug_O3'
            comp_name_nc(no2_nc_index)='SURF_ug_NO2'
            comp_name_nc(nox_nc_index)='SURF_ugN_NOX' !Not used
            comp_name_nc(nh3_nc_index)='SURF_ug_NH3'
            !comp_name_nc(nh3_nc_index)='nh3'
            comp_name_nc(nh4_nc_index)='SURF_ug_NH4_F'
            !comp_name_nc(pm25_nc_index)='pm25'
            !comp_name_nc(pmco_nc_index)='SURF_ug_PMCO'
            comp_name_nc(pm10_nc_index)='SURF_ug_PM10'
            comp_name_nc(pm25_nc_index)='SURF_ug_PM25'
            comp_name_nc(co_nc_index)='SURF_ug_CO'
            comp_name_nc(bap_nc_index)='SURF_ug_BAP'
            comp_name_nc(c6h6_nc_index)='SURF_ug_BENZENE'
            comp_name_nc(so2_nc_index)='SURF_ug_SO2'
        endif

        if (use_water_in_EMEP_surface_pm_flag) then
            write(unit_logfile,'(a)') 'Using EMEP surface PM including water (RH50)'
            comp_name_nc(pm10_nc_index)='SURF_ug_PM10_rh50'
            comp_name_nc(pm25_nc_index)='SURF_ug_PM25_rh50'
        endif

        !Reset emission names so they will not be read if they are not used
        if (make_EMEP_grid_emission_data(allsource_index).or.local_subgrid_method_flag.ne.2.or.save_emissions_for_EMEP(allsource_index).or.save_emissions) then
        else
            var_name_nc(emis_nc_index,:,:)=''
            write(unit_logfile,'(a,i)') 'Will not read or write any EMEP emission data'
        endif

        !If utm zones set the projection parameters to these values
        if (projection_type.eq.UTM_projection_index) then
            projection_attributes(1)=utm_zone
            projection_attributes(2)=utm_lon0
        endif
        if (projection_type.eq.LTM_projection_index) then
            projection_attributes(1)=utm_zone
            projection_attributes(2)=ltm_lon0
        endif

        !Reset the EMEP grid region based on the size of the selected local fraction
        local_fraction_grid_size_scaling=real(local_fraction_grid_size(local_fraction_grid_for_EMEP_grid_interpolation))
        EMEP_grid_interpolation_size_original=EMEP_grid_interpolation_size
        !EMEP_grid_interpolation_size=EMEP_grid_interpolation_size_original*local_fraction_grid_size_scaling
        local_fraction_additional_grid_size_scaling=real(local_fraction_grid_size(local_fraction_grid_for_EMEP_additional_grid_interpolation))
        EMEP_additional_grid_interpolation_size_original=EMEP_additional_grid_interpolation_size
        !EMEP_additional_grid_interpolation_size=EMEP_additional_grid_interpolation_size_original*local_fraction_additional_grid_size_scaling

        !Definitions of the emission saving grid. These are the pre February 2020 values
        !save_emission_subgrid_min(x_dim_index)=-6.498834E+05
        !save_emission_subgrid_delta(x_dim_index)=2500.
        !save_emission_subgrid_dim(x_dim_index)=531
        !save_emission_subgrid_min(y_dim_index)=-6.567275E+05
        !save_emission_subgrid_delta(y_dim_index)=2500.
        !save_emission_subgrid_dim(y_dim_index)=671

    end subroutine uEMEP_reset_constants