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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
| subroutine READ_FILE ( file_name, ANALYS, OMEGAS, DISPIR, DISPOR, BEARAN, BEAREF, IR_setting, OR_setting, FILTER, ERROR)
implicit none
character(len = 64), intent(in) :: file_name
real(8) :: DISPIR, DISPOR
integer :: ERROR
integer, dimension(1,5) :: ANALYS
logical, dimension(1,8) :: FILTER
real(8), dimension ( : , : ), allocatable :: IR_setting, OR_setting
real(8), dimension(1,2) :: OMEGAS
real(8), dimension(1,5) :: BEARAN, BEAREF
character(len = 6) :: STR
integer :: i, num_line
integer, dimension(1,8) :: LABEL
OPEN(1, FILE = file_name, ERR = 301, STATUS = 'OLD', ACTION = 'READ')
i = 0
FILTER = .false.
LABEL = 0
do WHILE (.NOT. EOF(1))
i = i + 1
read( 1, FMT = '(a6)', ERR = 302) STR
if ( STR == 'ANALYS' ) then
if (FILTER(1,1) == .true.) goto 302
LABEL(1,1) = i
FILTER(1,1) = .true.
end if
if ( STR == 'OMEGAS' ) then
if (FILTER(1,2) == .true.) goto 302
LABEL(1,2) = i
FILTER(1,2) = .true.
end if
if ( STR == 'DISPIR' ) then
if (FILTER(1,3) == .true.) goto 302
LABEL(1,3) = i
FILTER(1,3) = .true.
end if
if ( STR == 'DISPOR' ) then
if (FILTER(1,4) == .true.) goto 302
LABEL(1,4) = i
FILTER(1,4) = .true.
end if
if ( STR == 'BEARAN' ) then
if (FILTER(1,5) == .true.) goto 302
LABEL(1,5) = i
FILTER(1,5) = .true.
end if
if ( STR == 'BEAREF' ) then
if (FILTER(1,6) == .true.) goto 302
LABEL(1,6) = i
FILTER(1,6) = .true.
end if
if ( STR == 'IR_SET' ) then
if (FILTER(1,7) == .true.) goto 302
LABEL(1,7) = i
FILTER(1,7) = .true.
end if
if ( STR == 'OR_SET' ) then
if (FILTER(1,8) == .true.) goto 302
LABEL(1,8) = i
FILTER(1,8) = .true.
end if
enddo
if (LABEL(1,1) == 0 .AND. LABEL(1,2) == 0) goto 302
rewind(1)
do i = 1, LABEL(1,1)-1 ; read(1,*) ; end do
read( 1, *, ERR = 302) STR, ANALYS(1,1:5)
rewind(1)
do i = 1, LABEL(1,2)-1 ; read(1,*) ; end do
read( 1, *, ERR = 302) STR, OMEGAS(1,1:2)
rewind(1)
if (LABEL(1,3) /= 0) then ;
do i = 1, LABEL(1,3)-1 ; read(1,*) ; end do
read( 1, *, ERR = 302) STR, DISPIR
rewind(1)
else ; DISPIR = 0.d0
end if
if (LABEL(1,4) /= 0) then ;
do i = 1, LABEL(1,4)-1 ; read(1,*) ; end do
read( 1, *, ERR = 302) STR, DISPOR
rewind(1)
else ; DISPOR = 0.d0
end if
if (LABEL(1,5) /= 0)then ;
do i = 1, LABEL(1,5)-1 ; read(1,*) ; end do
read( 1, *, ERR = 302) STR, BEARAN(1,1:5)
rewind(1)
else ; BEARAN = 0.d0
end if
if (LABEL(1,6) /= 0)then ;
do i = 1, LABEL(1,6)-1 ; read(1,*) ; end do
read( 1, *, ERR = 302) STR, BEAREF(1,1:5)
rewind(1)
else ; BEAREF = 0.d0
end if
num_line = ANALYS(1,2)
allocate(IR_setting(num_line,17))
if (LABEL(1,7) /= 0) then ;
do i = 1, LABEL(1,7) ; read(1,*) ; end do
do i = 1, num_line ; read( 1, *, ERR = 302) IR_setting(i,1:17) ; end do
rewind(1)
else ; IR_setting = 0.d0
end if
num_line = ANALYS(1,3)
allocate(OR_setting(num_line,17))
if (LABEL(1,8) /= 0) then ;
do i = 1, LABEL(1,8) ; read(1,*) ; end do
do i = 1, num_line ; read( 1, *, ERR = 302) OR_setting(i,1:17) ; end do
rewind(1)
else ; OR_setting = 0.d0
end if
CLOSE (1) ; return
301 ERROR = 1 ; return ! File not founded
302 ERROR = 2 ; close(1) ; return ! File have bad structure
end subroutine READ_FILE
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
Partager