1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
subroutine extraire_type(type,sous_tab)
implicit none
! variables d'entrée/sortie
! -----------------------
character*1, intent(in) :: type ! type d'atome à extraire
real*8, intent(out) :: tableau(100,3) ! tableau qui contiendra les résultats
! variables locales
! ----------------
integer :: i,ios
character*1 :: tmp_type
real*8 :: tmp_coord(3)
open(unit=10,file='fichier_contenant_la_tableau_total',status='old')
1 format(A,3(E15.8))
ios = 0
i = 1
sous_tab = 0.0D00
do while (ios .eq. 0)
read(11,1,iostat=ios) tmp_type , tmp_coord(:)
if (tmp_type .eq. type) then
sous_tab(i,:) = tmp_coord(:)
i = i + 1
endif
enddo
! ici :
! la variable i contient le nombre d'atomes de type recherché
! la variable sous_tab contient les coordonnées de ces atomes
return
end subroutine extraire_type |
Partager