! This function is to read the cmz list file into tinfil ! By Jin Gao on 02/15/2011 subroutine cmzlist_read include 'airpact/spatialGIS.inc' include 'wpath.inc' ! implicit none integer, parameter :: max_csv_lines = 117 ! max number of lines in CSV integer stat, line_nr, nr, i, computed_number character(80) :: line ! integer :: idx(max_csv_lines) ! integer :: code(max_csv_lines) character*125 ::name(max_csv_lines) character*10 idx_head, code_head, name_head ! open file open (1, file=rootp(1:len_trim(rootp))//'data/wa_cmzfile.csv', & & status='old', iostat=stat) if (stat .ne. 0) then write(*,*) 'File cannot be opened !' go to 99 end if write(*,*) 'Reading CSV-file...' ! process file line_nr = 0 do while (line_nr < 119) if (line_nr .eq. 0) then read(1,'(A)') line read(line,*) idx_head,code_head,name_head write(*,*)idx_head,code_head,name_head else ! if line_nr > 1 then parse data line read(1,'(A)') line ! write(*,*) 'Line:',line read (line,*)cmzListIDX(line_nr),cmzListCode(line_nr), & & cmzListName(line_nr) ! write(*,*)'name:',cmzListName(line_nr) end if line_nr = line_nr + 1 if (line_nr .eq. 118) then ! write(*,*) 'Last line:',line go to 99 end if end do ! close file 99 continue close(1) write(*,*) 'Done.' nr = line_nr write(*,*) 'Number of all lines found in CSV = ', line_nr write(*,*) 'Number of data lines found in CSV = ', nr ! write the data write(*, '(A)') '****************************************' write(*,'(3A10)') idx_head,code_head,name_head write(*, '(A)') '****************************************' return end