Commit e18f8877 authored by Zolnierczuk, Piotr's avatar Zolnierczuk, Piotr
Browse files

introduced HDF5 and nxs2echo

parent 45a3d42f
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -2,8 +2,8 @@
export PROJECT=drspine

export VERSION_MAJOR=2
export VERSION_MINOR=0
export VERSION_RELEASE=a4
export VERSION_MINOR=1
export VERSION_RELEASE=a1

export PROJLIB=lib$(PROJECT).a
export PROJARCH=$(PROJECT)-$(VERSION_MAJOR).$(VERSION_MINOR)
+11 −11
Original line number Diff line number Diff line
@@ -42,18 +42,17 @@ PROGSRC=\
	drspine.f90 \
	extract_figures.f90 \
	plain_figures.f90 \
	mxx.f90
	mxx.f90 \
#	makeconf.f90

ifneq ($(HDF5DIR),)
PROGSRC +=nxs2echo.f90
endif

FSOURCES1=\
	drspine_version.F90 \
	os_utils.F90

ifndef OLDCOM
FSOURCES1 += new_com.F90
else
FSOURCES1 += old_com.F90
endif
	os_utils.F90\
	new_com.F90

FSOURCES2=\
	drspine_parameters.f90 \
@@ -79,7 +78,6 @@ FSOURCES2=\
	echo_shapes.f90   \
	file_utils.f90    \
	read_utils.f90    \
	read_nexus.f90    \
    texology.f90      \
    dump_data.f90     \
	write_utils.f90   \
@@ -93,12 +91,14 @@ FSOURCES2=\
	drspine_utils.f90

ifneq ($(GRDIR),)
FSOURCES2+=gr_interface.f90 \
		   plot_utils.f90
FSOURCES2+=gr_interface.f90 plot_utils.f90
else
FSOURCES2+=plot_nogr.f90
endif

ifneq ($(HDF5DIR),)
FSOURCES2+=read_nexus.f90
endif

CSOURCES=linenoise.c linenoise_f90.c regex2.c

+0 −5
Original line number Diff line number Diff line
@@ -31,8 +31,6 @@ program drspine
  use gen_makro
  use plot_utils
  use drspine_utils
  !
  use read_nexus

  !
  implicit none
@@ -193,9 +191,6 @@ program drspine
  !! LOG INITIALIZATION
  call loginit(prefix='drspine_', sigerr_proc=errsig)

  !!
  call nexus_init(ier)

  call data_manager_init(data_allocation, stat=istat)
  if (istat/=DATA_MANAGER_OK) &
    call msg_fatal('drspine', msg='data manager error', extra=msg_fmt('("allocating ",i0," slots failed")', data_allocation))

sources/nxs2echo.f90

0 → 100644
+28 −0
Original line number Diff line number Diff line
program nxs2echo

  use drspine_parameters
  use logger
  use read_nexus 

  implicit none

  integer :: i
  character(len=MAX_LINE_LENGTH) :: arg

  call loginit(console_level=LOG_INFO, prefix='nxs2echo_')
  call nexus_init()

  do i=1, command_argument_count()
    call get_command_argument(i,arg)
    call msg_info('nxs2echo', msg='processing file'//trim(arg))
    !write(*,'(a)') '----> '//trim(arg)
    call nexus_open(arg)
    call nexus_open_group("/entry/bank1_events")
    call nexus_close()
  end do
  
  call nexus_end()



end program nxs2echo
+49 −7
Original line number Diff line number Diff line
@@ -6,22 +6,64 @@ module read_nexus
  implicit none
  private

  public nexus_init
  public nexus_init, nexus_end
  public nexus_open, nexus_close
  public nexus_open_group

  integer        :: ier
  integer(HID_T) :: hid

  character(len=*), parameter :: cmodname="HDF5/NeXus module"

contains

  subroutine nexus_init(ier)
    integer, intent(out) :: ier

  !> init HDF5 module
  subroutine nexus_init
    ier=0
    hid=-1
    call h5open_f(ier)
    ier = -1
    if (ier.lt.0) &
        call msg_fatal('nexus_init', msg='Error initializing HDF5 routines')
    call msg_info('nexus_init', msg='HDF5/NeXus module initialized')
        call msg_fatal('nexus_init', msg='Error initializing '//cmodname)
    call msg_debug('nexus_init', msg=cmodname//' initialized')
  end subroutine nexus_init

  !> end using HDF5 module
  subroutine nexus_end
    call nexus_close()
    call h5close_f(ier)
    call msg_debug('nexus_end', msg=cmodname//' closed')
  end subroutine nexus_end

  !> open nexus file
  subroutine nexus_open(cfilename)
    character(len=*), intent(in) :: cfilename
    call h5fopen_f(cfilename, H5F_ACC_RDONLY_F, hid, ier)
    if (ier.lt.0) &
        call msg_fatal('nexus_open', msg='Error opening file '//trim(cfilename))
    call msg_debug('nexus_open', msg='File '//trim(cfilename)//' opened')
    return
  end subroutine nexus_open

  !> close nexus file
  subroutine nexus_close
    if (hid<0) return
    call h5fclose_f(hid,ier)
    if (ier.lt.0) &
       call msg_error('nexus_close', msg='Error closing HDF5/NeXus file')
    call msg_debug('nexus_close', msg='HDF5/NeXus file closed')
    hid=-1
  end subroutine nexus_close

  !> open group
  subroutine nexus_open_group(gname)
    character(len=*), intent(in)  :: gname
    integer (hid_t) :: gid
    call h5gopen_f(hid, gname, gid, ier)
    if (ier.lt.0) &
        call msg_fatal('nexus_group', msg='Error opening group '//trim(gname))
    call msg_debug('nexus_group', msg='HDF5/NeXus group '//trim(gname)//' opened')
    return
  end subroutine nexus_open_group

end module read_nexus