m_read_CLS_header.F90 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. module m_read_CLS_header
  2. ! Reads the CLS header stored as sla.hdr or sst.hdr
  3. contains
  4. subroutine read_CLS_header(fnamehdr,gr,dataformat,form,factor,var)
  5. use mod_grid
  6. implicit none
  7. type (grid), intent(out) :: gr
  8. character(len=80),intent(in) :: fnamehdr
  9. character(len=80),intent(out) :: dataformat
  10. character(len=80) :: title
  11. character(len=3), intent (out)::form
  12. integer :: lastchar
  13. real, intent(out) :: factor, var
  14. logical :: ex
  15. gr = default_grid
  16. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  17. ! Read .hdr file information
  18. inquire (file=fnamehdr,exist=ex)
  19. if (ex) then
  20. open (10,file=fnamehdr)
  21. read (10,'(a)') title
  22. read (10,'(a3)') form
  23. read (10,'(a80)') dataformat
  24. read (10,*) gr%undef, factor, var
  25. lastchar = scan(dataformat,')')
  26. dataformat(lastchar+1:80) = ' '
  27. print '(2a)','title : ', trim(title)
  28. print '(2a)','Form : ', form
  29. print '(2a)','data format: ', trim(dataformat)
  30. print '(a,3e14.3)','undef factor var: ', gr%undef,factor,var
  31. !Reads the observation gridd
  32. if (form == 'reg') then
  33. read (10,*) gr%nx,gr%ny,gr%x0,gr%y0,gr%dx,gr%dy
  34. gr%reg = .true.
  35. gr%order = 2
  36. gr%ux = 'deg'
  37. gr%uy = 'deg'
  38. elseif (form == 'irr') then
  39. read (10,*) gr%nx
  40. gr%reg = .false.
  41. gr%order = 1
  42. else
  43. stop 'readhdr: Header error, format should be reg or irr'
  44. end if
  45. gr%set = .true.
  46. close (10)
  47. else
  48. form = '0' ! File not found.
  49. gr%set = .false.
  50. print*, title
  51. stop 'read_CLS_header: no data header'
  52. end if
  53. print *,' No of gridpoints: ', gridpoints(gr)
  54. ! print '(a,a3,a,f8.4)','Error variance of dataset ',obstype, ' is', var
  55. end subroutine read_CLS_header
  56. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  57. end module m_read_CLS_header