m_read_CLS_data.F90 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. module m_read_CLS_data
  2. ! Reads SLA and SST data from CLS, Toulouse, France
  3. ! Files are given as .asc (lat,lon,data)
  4. ! The data points are surface data and therefore the data(k)%depths=0
  5. ! This subroutine also prepares the gridd which the data
  6. ! Is provided on.
  7. contains
  8. subroutine read_CLS_data(fname,obstype,dformat,gr,form,data,factor,var)
  9. use mod_measurement
  10. use mod_grid
  11. use m_spherdist
  12. implicit none
  13. type (measurement), intent(inout) :: data(:)
  14. type (grid), intent(in) :: gr ! CLS measurement grid
  15. real, intent(in) :: factor, var
  16. character(len=80), intent(in) :: fname,dformat
  17. character(len=3), intent(in)::form
  18. character(len=*), intent(in)::obstype
  19. integer :: k, telli, tellj, nrdat, dum
  20. logical :: ex, found, fleeting
  21. real :: lon, lat
  22. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  23. ! Read observation file
  24. if (trim(form) == '0') stop 'read_CLS_data: illegal format '
  25. inquire (file=fname, exist=ex)
  26. if (.not. ex) then
  27. print *, 'read_CLS_data: file ', fname, ' not found.'
  28. stop
  29. end if
  30. !std = 0.0; lat = 0.0; lon = 0.0
  31. !!! Find out if data column is type integer or not
  32. found = .false.
  33. found = ((scan(dformat,'i') > 0) .or. (scan(dformat,'I') > 0))
  34. fleeting = .not. found
  35. open (10, file=fname, form='formatted', status='old')
  36. telli=1
  37. tellj=1
  38. do k = 1, gridpoints(gr)
  39. data(k)%id = obstype
  40. if (fleeting) then ! Data column floating point
  41. read (10,dformat,end=999,err=999) lat, lon, data(k)%d
  42. else ! Data column integer valued
  43. read (10,dformat,end=999,err=999) lat, lon, dum
  44. data(k)%d = real(dum)
  45. end if
  46. ! print*,'lat',lat,'lon', lon,'data',data(k)%d
  47. !NBNBN Avoid sla data in region 3S to 3N (due to strange Ifremer mean ssh in this region):
  48. ! if (trim(data(k)%id) == 'ssh' .or. trim(data(k)%id) == 'SSH') then
  49. ! if ((lat.ge.-3.0).and.(lat.le.3.0)) then
  50. ! data(k)%d = 999.9
  51. ! endif
  52. ! endif
  53. if (.not. undefined(data(k)%d,gr)) then
  54. data(k)%d = data(k)%d*factor ! Convert to proper units
  55. end if
  56. data(k)%jpiv = telli
  57. data(k)%ipiv = tellj
  58. ! iloop(k) = telli
  59. ! jloop(k) = tellj
  60. telli = telli + 1
  61. if (telli > gr%ny) then
  62. tellj=tellj+1
  63. telli = 1
  64. endif
  65. data(k)%lon=lon
  66. data(k)%lat=lat
  67. !LB: Data support is assumed = a square grid cell
  68. !support diameter stored in %a1 (tricky, isn't it ?)
  69. data(k)%a1 = spherdist(lon-.5*gr%dx,lat-.5*gr%dy,lon+.5*gr%dx,lat+.5*gr%dy)
  70. data(k)%ns = 1
  71. data(k)%status = .not. undefined(data(k)%d,gr) ! active data
  72. if (trim(obstype) == 'SST') then
  73. data(k) % status = data(k) % status .and.&
  74. abs(data(k) % d + 1.8d0) > 1.0d-6
  75. end if
  76. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  77. ! In the case of SSH data the var parameter is given for each data point !!!!
  78. !
  79. if (trim(data(k)%id) == 'ssh' .or. trim(data(k)%id) == 'SSH') then
  80. data(k)%var = var !!!NBNBNB + std**2
  81. else
  82. data(k)%var = var
  83. endif
  84. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  85. data(k)%depth = 0.0
  86. enddo ! k = 1, gridpoints(gr)
  87. 999 continue
  88. nrdat =k-1
  89. print*, 'Number of data read:', nrdat
  90. close(10)
  91. end subroutine read_CLS_data
  92. end module m_read_CLS_data