! note from paster: the pointer arrays me_opt/ffopt and me_dia/ffdia are build here

! fhand is a file handle

! info is a context struct that contains all me's

! quit() is a function that aborts the programm execution

do iopt = 1 , nopt

! pointer array

ierr = 1

jopt = iopt

idx_me = idx_list ( label_opt ( iopt ) ,info )

if ( idx_me. le .0 ) exit

ierr = 2

me_opt ( iopt ) % me = > info % me_arr ( idx_me ) % me

ffopt ( iopt ) % fhand = > info % me_arr ( idx_me ) % me % fhand

if ( . not . associated ( ffopt ( iopt ) % fhand ) ) exit

ierr = 3

jopt = iopt

idx_me = idx_list ( label_dia ( iopt ) ,info )

if ( idxmel. le .0 ) exit

me_dia ( iopt ) % me = > info % me_arr ( idx_me ) % me

ierr = 4

ffdia ( iopt ) % fhand = > op_info % mel_arr ( idxmel ) % mel % fhand

if ( . not . associated ( ffdia ( iopt ) % fhand ) ) exit

ierr = 0

end do

! special arrays

if ( ierr. eq .0 ) then

do idx = 1 , nspecial

jopt = idx

idx_me = idx_list ( label_special ( idx ) ,info )

ierr = 5

if ( idxmel. le .0 ) exit

me_special ( idx ) % mel = > op_info % me_arr ( idx_me ) % me

ffspecial ( idx ) % fhand = > op_info % me_arr ( idx_me ) % me % fhand

ierr = 6

if ( . not . associated ( ffspecial ( idx ) % fhand ) ) exit

ierr = 0

end do

end if

! error handling

if ( ierr. gt .0 ) then

if ( ierr. eq .1. or . ierr . eq .2 ) label = label_opt ( jopt )

if ( ierr. eq .3. or . ierr . eq .4 ) label = label_dia ( jopt )

if ( ierr. eq .5. or . ierr . eq .6 ) label = label_special ( jopt )

if ( mod ( ierr, 2 ) . eq .1 )

& call quit ( 1 , 'solve_evp' ,

& 'did not find list ' // trim ( label ) )

if ( mod ( ierr, 2 ) . eq .0 )

& call quit ( 1 , 'solve_evp' ,

& 'no file associated with list ' // trim ( label ) )