I would like to know if this is the most efficient way to use the new get_multiple_filenames@ facility. The only idea I had was to declare a number of arrays in a subroutine and then open one by one using Select Case. This seems for me rather primitive and does not allow to open more files than the number of arrays that is fixed in the subroutine, but I found no better idea. Any suggestions?
Agustin
subroutine get_several_files
C_EXTERNAL GET_MULTIPLE_FILENAMES@ 'get_multiple_file_names'(VAL,INSTRING,OUTSTRING,VAL,INSTRING,INSTRING,VAL):LOGICAL
logical L,next
character*256 filename,filter,defpath
integer :: status,ndata
character a,b
character*128,dimension(10) :: file_names_set
real x1,y1
type array
real*8 x
real*8 y
end type array
type(array),dimension(:), allocatable :: array_1,array_2,array_3,array_4,array_5,array_6
integer *4 :: number_of_files=0
filter = 'Data files (*.dat)'//char(0)//'*.dat'//char(0)//'All files (*.*)'//char(0)//'*.*'//char(0)//char(0)
defpath = char(0)
L = .TRUE.
next = .FALSE.
number_of_files=1
! first select files
do while(L)
ndata=0
L=GET_MULTIPLE_FILENAMES@(0,'Dialog Title',filename,256,filter,defpath,next)
next = .TRUE.
if(L) then
file_names_set(number_of_files)=filename
number_of_files=number_of_files+1
endif
end do
!then open files one by one
do i=1,number_of_files
open(32,file=file_names_set(i),status='old',action='read',iostat=status)
read(32,100) a,b
100 format(2A16)
do
read(32,*,iostat=status) x1,y1
if(status/= 0) exit
ndata=ndata+1
end do
close(32)
open(32,file=file_names_set(i),status='old',action='read',iostat=status)
select case(i)
case(1)
read(32,*) a,b
allocate(array_1(ndata))
do j=1,ndata
read(32,*) array_1(j)%x,array_1(j)%y
end do
close(32)
case(2)
read(32,*) a,b
allocate(array_2(ndata))
do j=1,ndata
read(32,*) array_2(j)%x,array_2(j)%y
end do
close(32)
!...........up to n cases
end select
ndata=0 !reset ndata for the next file
end do
call plot_files !subroutine for plotting data
end subroutine get_several_files