Commit 90cba55c authored by Zolnierczuk, Piotr's avatar Zolnierczuk, Piotr
Browse files

added testreduce

parent a6a56c3d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ TESTSRC1=\
       testmatch.f90 \
       testmath.f90 \
       testosutils.f90 \
       testreduce.f90 \
       teststat.f90 \
       teststrings.f90

+4 −2
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@ program testdata
  call test_data_sizes
  call test_phase_scan_struct
  call test_collection

contains


@@ -122,12 +123,13 @@ contains
    end do

    do iq=1, sqt_collection%q_bin%nbins
       call print_collection_item(output_unit, sqt_collection%tq_bin(1,iq), "fqt", print_header=.true.)
       do it=1, sqt_collection%t_bin%nbins
          call print_collection_item(output_unit, sqt_collection%tq_bin(it,iq), "default")
          call print_collection_item(output_unit, sqt_collection%tq_bin(it,iq), "fqt")
       end do

    end do

  end subroutine test_collection


end program testdata
+0 −2
Original line number Diff line number Diff line
@@ -2,9 +2,7 @@
program testmatch
  use, intrinsic :: iso_fortran_env, only : output_unit
  use matching
  use dump_data

  use print_helper
  use data_helper

  implicit none

tests/testreduce.f90

0 → 100644
+71 −0
Original line number Diff line number Diff line
program testreduce
    use, intrinsic :: iso_fortran_env, only : output_unit
    use data_types
    use instrument_config
    use matching
    use fit_data
    use reduce_data

    use data_helper

    implicit none

    type(collection) :: sqt_collection

    type(scan_struct), allocatable, dimension(:) :: scan_data

    type(bin_struct)        :: tbins
    type(double_bin_struct) :: tau_bins, q_bins

    integer :: nscan = 4
    integer :: iunit
    integer :: i, iq, it

    call loginit(LOG_DEBUG, file_level=LOG_OFF)

    call configure_instrument_defaults(INST_SNSNSE, tbins, tau_bins, q_bins)
    call init_collection_from_bins(sqt_collection, tau_bins, q_bins)
    !
    allocate(scan_data(nscan))
    call create_scan_data(scan_data, nscan)
    call match_scan_global(scan_data, nscan, ROLE_REFERENCE)
    call match_show(scan_data, nscan)

    do i=1, nscan
        if( has_role(scan_data(i)%role, ROLE_REFERENCE) ) then
            call fit_echo_data(scan_data(i), PHASE_FIT_DEFAULT )
        else
            call fit_echo_data(scan_data(i), PHASE_USE )
        end if

    end do
    !
    call test_consolidate_collection
    deallocate(scan_data)

contains

    subroutine test_consolidate_collection
        write(*,*) '=========== TEST CONSOLIDATE COLLECTION ========='

        open(newunit=iunit, file='sqt_bin.dat')

        do i=1, nscan
            if (is_valid_scan(scan_data(i), role=ROLE_SAMPLE)) then
            call calculate_sqt_raw(scan_data(i), 0, 1D0, 1D0)
            call collect_sqt_raw(sqt_collection, scan_data(i), iunit, use_mean=.false.)
            end if
        end do
        close(iunit)

        do iq=1, sqt_collection%q_bin%nbins
            call print_collection_item(output_unit, sqt_collection%tq_bin(1,iq), "fqt", print_header=.true.)
            do it=1, sqt_collection%t_bin%nbins
                call print_collection_item(output_unit, sqt_collection%tq_bin(it,iq), "fqt")
            end do
        end do

    end subroutine test_consolidate_collection


end program testreduce