The GetUnit function is used for getting a free logic unit. The users of \LIBVTKIO does not know which is the logical unit: \LIBVTKIO handels this information without boring the users. The logical unit used is safe-free: if the program calling \LIBVTKIO has others logical units used \LIBVTKIO will never use these units, but will choice one that is free.
GetUnit function is private and cannot be called outside \LIBVTKIO. If you are interested to use it change its scope to public.
function GetUnit() result(Free_Unit)
!---------------------------------------------------------------------------------------------------------------------------------
!!The GetUnit function is used for getting a free logic unit. The users of \LIBVTKIO does not know which is
!!the logical unit: \LIBVTKIO handels this information without boring the users. The logical unit used is safe-free: if the
!!program calling \LIBVTKIO has others logical units used \LIBVTKIO will never use these units, but will choice one that is free.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
integer(I4P):: Free_Unit ! free logic unit
integer(I4P):: n1 ! counter
integer(I4P):: ios ! inquiring flag
logical(4):: lopen ! inquiring flag
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
!!The following is the code snippet of GetUnit function: the units 0, 5, 6, 9 and all non-free units are discarded.
!!
!(\doc)codesnippet
Free_Unit = -1_I4P ! initializing free logic unit
n1=1_I4P ! initializing counter
do
if ((n1/=5_I4P).AND.(n1/=6_I4P).AND.(n1/=9_I4P)) then
inquire (unit=n1,opened=lopen,iostat=ios) ! verify logic units
if (ios==0_I4P) then
if (.NOT.lopen) then
Free_Unit = n1 ! assignment of free logic
return
endif
endif
endif
n1=n1+1_I4P ! updating counter
enddo
return
!(doc/)codesnippet
!!GetUnit function is private and cannot be called outside \LIBVTKIO. If you are interested to use it change its scope to public.
!---------------------------------------------------------------------------------------------------------------------------------
endfunction GetUnit