obs_read_vel.F90 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653
  1. MODULE obs_read_vel
  2. !!======================================================================
  3. !! *** MODULE obs_read_vel ***
  4. !! Observation diagnostics: Read the velocity profile observations
  5. !!======================================================================
  6. !!----------------------------------------------------------------------
  7. !! obs_rea_vel_dri : Driver for reading profile obs
  8. !!----------------------------------------------------------------------
  9. !! * Modules used
  10. USE par_kind ! Precision variables
  11. USE par_oce ! Ocean parameters
  12. USE in_out_manager ! I/O manager
  13. USE dom_oce ! Ocean space and time domain variables
  14. USE obs_mpp ! MPP support routines for observation diagnostics
  15. USE julian ! Julian date routines
  16. USE obs_utils ! Observation operator utility functions
  17. USE obs_prep ! Prepare observation arrays
  18. USE obs_grid ! Grid search
  19. USE obs_sort ! Sorting observation arrays
  20. USE obs_profiles_def ! Profile definitions
  21. USE obs_conv ! Various conversion routines
  22. USE obs_types ! Observation type definitions
  23. USE netcdf ! NetCDF library
  24. USE obs_oper ! Observation operators
  25. USE obs_vel_io ! Velocity profile files I/O (non-FB files)
  26. USE lib_mpp ! For ctl_warn/stop
  27. IMPLICIT NONE
  28. !! * Routine accessibility
  29. PRIVATE
  30. PUBLIC obs_rea_vel_dri ! Read the profile observations
  31. !!----------------------------------------------------------------------
  32. !! NEMO/OPA 3.3 , NEMO Consortium (2010)
  33. !! $Id: obs_read_vel.F90 4990 2014-12-15 16:42:49Z timgraham $
  34. !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
  35. !!----------------------------------------------------------------------
  36. CONTAINS
  37. SUBROUTINE obs_rea_vel_dri( kformat, &
  38. & profdata, knumfiles, cfilenames, &
  39. & kvars, kextr, kstp, ddobsini, ddobsend, &
  40. & ldignmis, ldavtimset, ldmod )
  41. !!---------------------------------------------------------------------
  42. !!
  43. !! *** ROUTINE obs_rea_pro_dri ***
  44. !!
  45. !! ** Purpose : Read from file the profile observations
  46. !!
  47. !! ** Method : Depending on kformat either ENACT, CORIOLIS or
  48. !! feedback data files are read
  49. !!
  50. !! ** Action :
  51. !!
  52. !! References :
  53. !!
  54. !! History :
  55. !! ! : 2009-01 (K. Mogensen) : New merged version of old routines
  56. !!----------------------------------------------------------------------
  57. !! * Modules used
  58. !! * Arguments
  59. INTEGER :: kformat ! Format of input data
  60. ! ! 1: ENACT
  61. ! ! 2: Coriolis
  62. TYPE(obs_prof), INTENT(OUT) :: profdata ! Profile data to be read
  63. INTEGER, INTENT(IN) :: knumfiles ! Number of files to read in
  64. CHARACTER(LEN=128), INTENT(IN) :: cfilenames(knumfiles) ! File names to read in
  65. INTEGER, INTENT(IN) :: kvars ! Number of variables in profdata
  66. INTEGER, INTENT(IN) :: kextr ! Number of extra fields for each var in profdata
  67. INTEGER, INTENT(IN) :: kstp ! Ocean time-step index
  68. LOGICAL, INTENT(IN) :: ldignmis ! Ignore missing files
  69. LOGICAL, INTENT(IN) :: ldavtimset ! Set time to be equal to the end of the day
  70. LOGICAL, INTENT(IN) :: ldmod ! Initialize model from input data
  71. REAL(KIND=dp), INTENT(IN) :: ddobsini ! Obs. ini time in YYYYMMDD.HHMMSS
  72. REAL(KIND=dp), INTENT(IN) :: ddobsend ! Obs. end time in YYYYMMDD.HHMMSS
  73. !! * Local declarations
  74. CHARACTER(LEN=15), PARAMETER :: cpname='obs_rea_vel_dri'
  75. INTEGER :: jvar
  76. INTEGER :: ji
  77. INTEGER :: jj
  78. INTEGER :: jk
  79. INTEGER :: ij
  80. INTEGER :: iflag
  81. INTEGER :: inobf
  82. INTEGER :: i_file_id
  83. INTEGER :: inowin
  84. INTEGER :: iyea
  85. INTEGER :: imon
  86. INTEGER :: iday
  87. INTEGER :: ihou
  88. INTEGER :: imin
  89. INTEGER :: isec
  90. INTEGER, DIMENSION(knumfiles) :: &
  91. & irefdate
  92. INTEGER, DIMENSION(ntyp1770+1) :: &
  93. & itypuv, &
  94. & itypuvmpp
  95. INTEGER :: iuv3dtmpp
  96. INTEGER, DIMENSION(:), ALLOCATABLE :: &
  97. & iobsiu, &
  98. & iobsju, &
  99. & iprocu, &
  100. & iobsiv, &
  101. & iobsjv, &
  102. & iprocv, &
  103. & iindx, &
  104. & ifileidx, &
  105. & iprofidx
  106. INTEGER :: itype
  107. REAL(wp), DIMENSION(:), ALLOCATABLE :: &
  108. & zphi, &
  109. & zlam
  110. real(wp), DIMENSION(:), ALLOCATABLE :: &
  111. & zdat
  112. LOGICAL :: &
  113. & llvalprof
  114. TYPE(obfbdata), POINTER, DIMENSION(:) :: &
  115. & inpfiles
  116. real(wp), DIMENSION(knumfiles) :: &
  117. & djulini, &
  118. & djulend
  119. INTEGER :: iprof
  120. INTEGER :: iproftot
  121. INTEGER :: iuv3dt
  122. INTEGER :: ios
  123. INTEGER :: ioserrcount
  124. INTEGER, DIMENSION(kvars) :: iv3dt
  125. CHARACTER(len=8) :: cl_refdate
  126. ! Local initialization
  127. iprof = 0
  128. iuv3dt = 0
  129. !-----------------------------------------------------------------------
  130. ! Check data the model part is just with feedback data files
  131. !-----------------------------------------------------------------------
  132. IF ( ldmod .AND. ( kformat /= 0 ) ) THEN
  133. CALL ctl_stop( 'Model can only be read from feedback data' )
  134. RETURN
  135. ENDIF
  136. !-----------------------------------------------------------------------
  137. ! Count the number of files needed and allocate the obfbdata type
  138. !-----------------------------------------------------------------------
  139. inobf = knumfiles
  140. ALLOCATE( inpfiles(inobf) )
  141. prof_files : DO jj = 1, inobf
  142. !---------------------------------------------------------------------
  143. ! Prints
  144. !---------------------------------------------------------------------
  145. IF(lwp) THEN
  146. WRITE(numout,*)
  147. WRITE(numout,*) ' obs_rea_vel_dri : Reading from file = ', &
  148. & TRIM( TRIM( cfilenames(jj) ) )
  149. WRITE(numout,*) ' ~~~~~~~~~~~~~~~'
  150. WRITE(numout,*)
  151. ENDIF
  152. !---------------------------------------------------------------------
  153. ! Initialization: Open file and get dimensions only
  154. !---------------------------------------------------------------------
  155. iflag = nf90_open( TRIM( TRIM( cfilenames(jj) ) ), nf90_nowrite, &
  156. & i_file_id )
  157. IF ( iflag /= nf90_noerr ) THEN
  158. IF ( ldignmis ) THEN
  159. inpfiles(jj)%nobs = 0
  160. CALL ctl_warn( 'File ' // TRIM( TRIM( cfilenames(jj) ) ) // &
  161. & ' not found' )
  162. ELSE
  163. CALL ctl_stop( 'File ' // TRIM( TRIM( cfilenames(jj) ) ) // &
  164. & ' not found' )
  165. ENDIF
  166. ELSE
  167. !------------------------------------------------------------------
  168. ! Close the file since it is opened in read_proffile
  169. !------------------------------------------------------------------
  170. iflag = nf90_close( i_file_id )
  171. !------------------------------------------------------------------
  172. ! Read the profile file into inpfiles
  173. !------------------------------------------------------------------
  174. IF ( kformat == 0 ) THEN
  175. CALL init_obfbdata( inpfiles(jj) )
  176. IF(lwp) THEN
  177. WRITE(numout,*)
  178. WRITE(numout,*)'Reading from feedback file :', &
  179. & TRIM( cfilenames(jj) )
  180. ENDIF
  181. CALL read_obfbdata( TRIM( cfilenames(jj) ), inpfiles(jj), &
  182. & ldgrid = .TRUE. )
  183. IF ( ldmod .AND. ( inpfiles(jj)%nadd == 0 ) ) THEN
  184. CALL ctl_stop( 'Model not in input data' )
  185. RETURN
  186. ENDIF
  187. ELSEIF ( kformat == 1 ) THEN
  188. CALL read_taondbc( TRIM( cfilenames(jj) ), inpfiles(jj), &
  189. & numout, lwp, .TRUE. )
  190. ELSE
  191. CALL ctl_stop( 'File format unknown' )
  192. ENDIF
  193. !------------------------------------------------------------------
  194. ! Change longitude (-180,180)
  195. !------------------------------------------------------------------
  196. DO ji = 1, inpfiles(jj)%nobs
  197. IF ( inpfiles(jj)%plam(ji) < -180. ) &
  198. & inpfiles(jj)%plam(ji) = inpfiles(jj)%plam(ji) + 360.
  199. IF ( inpfiles(jj)%plam(ji) > 180. ) &
  200. & inpfiles(jj)%plam(ji) = inpfiles(jj)%plam(ji) - 360.
  201. END DO
  202. !------------------------------------------------------------------
  203. ! Calculate the date (change eventually)
  204. !------------------------------------------------------------------
  205. cl_refdate=inpfiles(jj)%cdjuldref(1:8)
  206. READ(cl_refdate,'(I8)') irefdate(jj)
  207. CALL ddatetoymdhms( ddobsini, iyea, imon, iday, ihou, imin, isec )
  208. CALL greg2jul( isec, imin, ihou, iday, imon, iyea, djulini(jj), &
  209. & krefdate = irefdate(jj) )
  210. CALL ddatetoymdhms( ddobsend, iyea, imon, iday, ihou, imin, isec )
  211. CALL greg2jul( isec, imin, ihou, iday, imon, iyea, djulend(jj), &
  212. & krefdate = irefdate(jj) )
  213. IF ( ldavtimset ) THEN
  214. DO ji = 1, inpfiles(jj)%nobs
  215. !
  216. ! for daily averaged data force the time
  217. ! to be the end of the day
  218. !
  219. inpfiles(jj)%ptim(ji) = &
  220. & INT(inpfiles(jj)%ptim(ji)) + 1
  221. END DO
  222. ENDIF
  223. IF ( inpfiles(jj)%nobs > 0 ) THEN
  224. inpfiles(jj)%iproc = -1
  225. inpfiles(jj)%iobsi = -1
  226. inpfiles(jj)%iobsj = -1
  227. ENDIF
  228. inowin = 0
  229. DO ji = 1, inpfiles(jj)%nobs
  230. IF ( ( inpfiles(jj)%ptim(ji) > djulini(jj) ) .AND. &
  231. & ( inpfiles(jj)%ptim(ji) <= djulend(jj) ) ) THEN
  232. inowin = inowin + 1
  233. ENDIF
  234. END DO
  235. ALLOCATE( zlam(inowin) )
  236. ALLOCATE( zphi(inowin) )
  237. ALLOCATE( iobsiu(inowin) )
  238. ALLOCATE( iobsju(inowin) )
  239. ALLOCATE( iprocu(inowin) )
  240. ALLOCATE( iobsiv(inowin) )
  241. ALLOCATE( iobsjv(inowin) )
  242. ALLOCATE( iprocv(inowin) )
  243. inowin = 0
  244. DO ji = 1, inpfiles(jj)%nobs
  245. IF ( ( inpfiles(jj)%ptim(ji) > djulini(jj) ) .AND. &
  246. & ( inpfiles(jj)%ptim(ji) <= djulend(jj) ) ) THEN
  247. inowin = inowin + 1
  248. zlam(inowin) = inpfiles(jj)%plam(ji)
  249. zphi(inowin) = inpfiles(jj)%pphi(ji)
  250. ENDIF
  251. END DO
  252. CALL obs_grid_search( inowin, zlam, zphi, iobsiu, iobsju, iprocu, &
  253. & 'U' )
  254. CALL obs_grid_search( inowin, zlam, zphi, iobsiv, iobsjv, iprocv, &
  255. & 'V' )
  256. inowin = 0
  257. DO ji = 1, inpfiles(jj)%nobs
  258. IF ( ( inpfiles(jj)%ptim(ji) > djulini(jj) ) .AND. &
  259. & ( inpfiles(jj)%ptim(ji) <= djulend(jj) ) ) THEN
  260. inowin = inowin + 1
  261. inpfiles(jj)%iproc(ji,1) = iprocu(inowin)
  262. inpfiles(jj)%iobsi(ji,1) = iobsiu(inowin)
  263. inpfiles(jj)%iobsj(ji,1) = iobsju(inowin)
  264. inpfiles(jj)%iproc(ji,2) = iprocv(inowin)
  265. inpfiles(jj)%iobsi(ji,2) = iobsiv(inowin)
  266. inpfiles(jj)%iobsj(ji,2) = iobsjv(inowin)
  267. IF ( inpfiles(jj)%iproc(ji,1) /= &
  268. & inpfiles(jj)%iproc(ji,2) ) THEN
  269. CALL ctl_stop( 'Error in obs_read_vel:', &
  270. & 'U and V observation on different processors')
  271. ENDIF
  272. ENDIF
  273. END DO
  274. DEALLOCATE( zlam, zphi, iobsiu, iobsju, iprocu, &
  275. & iobsiv, iobsjv, iprocv )
  276. DO ji = 1, inpfiles(jj)%nobs
  277. IF ( ( inpfiles(jj)%ptim(ji) > djulini(jj) ) .AND. &
  278. & ( inpfiles(jj)%ptim(ji) <= djulend(jj) ) ) THEN
  279. IF ( nproc == 0 ) THEN
  280. IF ( inpfiles(jj)%iproc(ji,1) > nproc ) CYCLE
  281. ELSE
  282. IF ( inpfiles(jj)%iproc(ji,1) /= nproc ) CYCLE
  283. ENDIF
  284. llvalprof = .FALSE.
  285. IF ( ( ( nproc == 0 ) .AND. &
  286. & ( inpfiles(jj)%iproc(ji,1) <= nproc ) ) .OR. &
  287. & ( inpfiles(jj)%iproc(ji,1) == nproc ) ) THEN
  288. loop_uv_count : DO ij = 1,inpfiles(jj)%nlev
  289. IF ( inpfiles(jj)%pdep(ij,ji) >= 6000. ) &
  290. & CYCLE
  291. IF ( ( inpfiles(jj)%ivlqc(ij,ji,1) <= 2 ) .AND. &
  292. & ( inpfiles(jj)%ivlqc(ij,ji,2) <= 2 ) .AND. &
  293. & ( inpfiles(jj)%idqc(ij,ji) <= 2 ) ) THEN
  294. iuv3dt = iuv3dt + 1
  295. llvalprof = .TRUE.
  296. ENDIF
  297. END DO loop_uv_count
  298. ENDIF
  299. IF ( llvalprof ) iprof = iprof + 1
  300. ENDIF
  301. END DO
  302. ENDIF
  303. END DO prof_files
  304. !-----------------------------------------------------------------------
  305. ! Get the time ordered indices of the input data
  306. !-----------------------------------------------------------------------
  307. !---------------------------------------------------------------------
  308. ! Loop over input data files to count total number of profiles
  309. !---------------------------------------------------------------------
  310. iproftot = 0
  311. DO jj = 1, inobf
  312. DO ji = 1, inpfiles(jj)%nobs
  313. IF ( ( inpfiles(jj)%ptim(ji) > djulini(jj) ) .AND. &
  314. & ( inpfiles(jj)%ptim(ji) <= djulend(jj) ) ) THEN
  315. iproftot = iproftot + 1
  316. ENDIF
  317. END DO
  318. END DO
  319. ALLOCATE( iindx(iproftot), ifileidx(iproftot), &
  320. & iprofidx(iproftot), zdat(iproftot) )
  321. jk = 0
  322. DO jj = 1, inobf
  323. DO ji = 1, inpfiles(jj)%nobs
  324. IF ( ( inpfiles(jj)%ptim(ji) > djulini(jj) ) .AND. &
  325. & ( inpfiles(jj)%ptim(ji) <= djulend(jj) ) ) THEN
  326. jk = jk + 1
  327. ifileidx(jk) = jj
  328. iprofidx(jk) = ji
  329. zdat(jk) = inpfiles(jj)%ptim(ji)
  330. ENDIF
  331. END DO
  332. END DO
  333. CALL sort_dp_indx( iproftot, &
  334. & zdat, &
  335. & iindx )
  336. iv3dt(:) = -1
  337. iv3dt(1:2) = iuv3dt
  338. CALL obs_prof_alloc( profdata, kvars, kextr, iprof, iv3dt, &
  339. & kstp, jpi, jpj, jpk )
  340. ! * Read obs/positions, QC, all variable and assign to profdata
  341. profdata%nprof = 0
  342. profdata%nvprot(:) = 0
  343. iprof = 0
  344. iuv3dt = 0
  345. itypuv (:) = 0
  346. itypuvmpp(:) = 0
  347. DO jk = 1, iproftot
  348. jj = ifileidx(iindx(jk))
  349. ji = iprofidx(iindx(jk))
  350. IF ( ( inpfiles(jj)%ptim(ji) > djulini(jj) ) .AND. &
  351. & ( inpfiles(jj)%ptim(ji) <= djulend(jj) ) ) THEN
  352. IF ( nproc == 0 ) THEN
  353. IF ( inpfiles(jj)%iproc(ji,1) > nproc ) CYCLE
  354. ELSE
  355. IF ( inpfiles(jj)%iproc(ji,1) /= nproc ) CYCLE
  356. ENDIF
  357. llvalprof = .FALSE.
  358. loop_prof : DO ij = 1, inpfiles(jj)%nlev
  359. IF ( inpfiles(jj)%pdep(ij,ji) >= 6000. ) &
  360. & CYCLE
  361. IF ( ( inpfiles(jj)%ivlqc(ij,ji,1) <= 2 ) .AND. &
  362. & ( inpfiles(jj)%ivlqc(ij,ji,2) <= 2 ) .AND. &
  363. & ( inpfiles(jj)%idqc(ij,ji) <= 2 ) ) THEN
  364. llvalprof = .TRUE.
  365. EXIT loop_prof
  366. ENDIF
  367. END DO loop_prof
  368. ! Set profile information
  369. IF ( llvalprof ) THEN
  370. iprof = iprof + 1
  371. CALL jul2greg( isec, &
  372. & imin, &
  373. & ihou, &
  374. & iday, &
  375. & imon, &
  376. & iyea, &
  377. & inpfiles(jj)%ptim(ji), &
  378. & irefdate(jj) )
  379. ! Profile time coordinates
  380. profdata%nyea(iprof) = iyea
  381. profdata%nmon(iprof) = imon
  382. profdata%nday(iprof) = iday
  383. profdata%nhou(iprof) = ihou
  384. profdata%nmin(iprof) = imin
  385. ! Profile space coordinates
  386. profdata%rlam(iprof) = inpfiles(jj)%plam(ji)
  387. profdata%rphi(iprof) = inpfiles(jj)%pphi(ji)
  388. ! Coordinate search parameters
  389. profdata%mi (iprof,1) = inpfiles(jj)%iobsi(ji,1)
  390. profdata%mj (iprof,1) = inpfiles(jj)%iobsj(ji,1)
  391. profdata%mi (iprof,2) = inpfiles(jj)%iobsi(ji,2)
  392. profdata%mj (iprof,2) = inpfiles(jj)%iobsj(ji,2)
  393. ! Profile WMO number
  394. profdata%cwmo(iprof) = inpfiles(jj)%cdwmo(ji)
  395. ! Instrument type
  396. READ( inpfiles(jj)%cdtyp(ji), '(I4)', IOSTAT = ios, ERR = 901 ) itype
  397. 901 IF ( ios /= 0 ) THEN
  398. IF (ioserrcount == 0) CALL ctl_warn ( 'Problem converting an instrument type to integer. Setting type to zero' )
  399. ioserrcount = ioserrcount + 1
  400. itype = 0
  401. ENDIF
  402. profdata%ntyp(iprof) = itype
  403. ! QC stuff
  404. profdata%nqc(iprof) = inpfiles(jj)%ioqc(ji)
  405. profdata%nqcf(:,iprof) = inpfiles(jj)%ioqcf(:,ji)
  406. profdata%ipqc(iprof) = inpfiles(jj)%ipqc(ji)
  407. profdata%ipqcf(:,iprof) = inpfiles(jj)%ipqcf(:,ji)
  408. profdata%itqc(iprof) = inpfiles(jj)%itqc(ji)
  409. profdata%itqcf(:,iprof) = inpfiles(jj)%itqcf(:,ji)
  410. profdata%ivqc(iprof,:) = inpfiles(jj)%ivqc(ji,:)
  411. profdata%ivqcf(:,iprof,:) = inpfiles(jj)%ivqcf(:,ji,:)
  412. ! Bookkeeping data to match profiles
  413. profdata%npidx(iprof) = iprof
  414. profdata%npfil(iprof) = iindx(jk)
  415. ! Observation QC flag (whole profile)
  416. profdata%nqc(iprof) = 0 !TODO
  417. loop_uv : DO ij = 1, inpfiles(jj)%nlev
  418. IF ( inpfiles(jj)%pdep(ij,ji) >= 6000. ) &
  419. & CYCLE
  420. IF ( ( inpfiles(jj)%ivlqc(ij,ji,1) <= 2 ) .AND. &
  421. & ( inpfiles(jj)%ivlqc(ij,ji,2) <= 2 ) .AND. &
  422. & ( inpfiles(jj)%idqc(ij,ji) <= 2 ) ) THEN
  423. iuv3dt = iuv3dt + 1
  424. ELSE
  425. CYCLE
  426. ENDIF
  427. ! Depth of U observation
  428. profdata%var(1)%vdep(iuv3dt) = &
  429. & inpfiles(jj)%pdep(ij,ji)
  430. ! Depth of U observation QC
  431. profdata%var(1)%idqc(iuv3dt) = &
  432. & inpfiles(jj)%idqc(ij,ji)
  433. ! Depth of U observation QC flags
  434. profdata%var(1)%idqcf(:,iuv3dt) = &
  435. & inpfiles(jj)%idqcf(:,ij,ji)
  436. ! Profile index
  437. profdata%var(1)%nvpidx(iuv3dt) = iprof
  438. ! Vertical index in original profile
  439. profdata%var(1)%nvlidx(iuv3dt) = ij
  440. ! Profile U value
  441. profdata%var(1)%vobs(iuv3dt) = &
  442. & inpfiles(jj)%pob(ij,ji,1)
  443. IF ( ldmod ) THEN
  444. profdata%var(1)%vmod(iuv3dt) = &
  445. & inpfiles(jj)%padd(ij,ji,1,1)
  446. ENDIF
  447. ! Profile U qc
  448. profdata%var(1)%nvqc(iuv3dt) = &
  449. & inpfiles(jj)%ivlqc(ij,ji,1)
  450. ! Profile U qc flags
  451. profdata%var(1)%nvqcf(:,iuv3dt) = &
  452. & inpfiles(jj)%ivlqcf(:,ij,ji,1)
  453. ! Depth of V observation
  454. profdata%var(2)%vdep(iuv3dt) = &
  455. & inpfiles(jj)%pdep(ij,ji)
  456. ! Depth of V observation QC
  457. profdata%var(2)%idqc(iuv3dt) = &
  458. & inpfiles(jj)%idqc(ij,ji)
  459. ! Depth of V observation QC flags
  460. profdata%var(2)%idqcf(:,iuv3dt) = &
  461. & inpfiles(jj)%idqcf(:,ij,ji)
  462. ! Profile index
  463. profdata%var(2)%nvpidx(iuv3dt) = iprof
  464. ! Vertical index in original profile
  465. profdata%var(2)%nvlidx(iuv3dt) = ij
  466. ! Profile V value
  467. profdata%var(2)%vobs(iuv3dt) = &
  468. & inpfiles(jj)%pob(ij,ji,2)
  469. IF ( ldmod ) THEN
  470. profdata%var(2)%vmod(iuv3dt) = &
  471. & inpfiles(jj)%padd(ij,ji,1,2)
  472. ENDIF
  473. ! Profile V qc
  474. profdata%var(2)%nvqc(iuv3dt) = &
  475. & inpfiles(jj)%ivlqc(ij,ji,2)
  476. ! Profile V qc flags
  477. profdata%var(2)%nvqcf(:,iuv3dt) = &
  478. & inpfiles(jj)%ivlqcf(:,ij,ji,2)
  479. ! Observation type
  480. itypuv( profdata%ntyp(iprof) + 1 ) = &
  481. & itypuv( profdata%ntyp(iprof) + 1 ) + 1
  482. END DO loop_uv
  483. ENDIF
  484. ENDIF
  485. END DO
  486. !-----------------------------------------------------------------------
  487. ! Sum up over processors
  488. !-----------------------------------------------------------------------
  489. CALL obs_mpp_sum_integer ( iuv3dt, iuv3dtmpp )
  490. CALL obs_mpp_sum_integers( itypuv, itypuvmpp, ntyp1770 + 1 )
  491. !-----------------------------------------------------------------------
  492. ! Output number of observations.
  493. !-----------------------------------------------------------------------
  494. IF(lwp) THEN
  495. WRITE(numout,*)
  496. WRITE(numout,'(1X,A)') 'Profile U,V velocity data'
  497. WRITE(numout,'(1X,A)') '-------------------------'
  498. WRITE(numout,*)
  499. DO ji = 0, ntyp1770
  500. IF ( itypuvmpp(ji+1) > 0 ) THEN
  501. WRITE(numout,'(1X,A3,A3,I8)') ctypshort(ji), ' = ', &
  502. & itypuvmpp(ji+1)
  503. ENDIF
  504. END DO
  505. WRITE(numout,'(1X,A)') '--------------'
  506. WRITE(numout,'(1X,A6,I8)') &
  507. & 'Total profile UV data = ',&
  508. & iuv3dtmpp
  509. WRITE(numout,'(1X,A)') '--------------'
  510. ENDIF
  511. profdata%nvprot(1) = iuv3dt
  512. profdata%nvprot(2) = iuv3dt
  513. profdata%nvprotmpp(1) = iuv3dtmpp
  514. profdata%nvprotmpp(2) = iuv3dtmpp
  515. profdata%nprof = iprof
  516. !-----------------------------------------------------------------------
  517. ! Model level search
  518. !-----------------------------------------------------------------------
  519. CALL obs_level_search( jpk, gdept_1d, &
  520. & profdata%nvprot(1), profdata%var(1)%vdep, &
  521. & profdata%var(1)%mvk )
  522. CALL obs_level_search( jpk, gdept_1d, &
  523. & profdata%nvprot(2), profdata%var(2)%vdep, &
  524. & profdata%var(2)%mvk )
  525. !-----------------------------------------------------------------------
  526. ! Set model equivalent to 99999
  527. !-----------------------------------------------------------------------
  528. IF ( .NOT. ldmod ) THEN
  529. DO jvar = 1, kvars
  530. profdata%var(jvar)%vmod(:) = fbrmdi
  531. END DO
  532. ENDIF
  533. !-----------------------------------------------------------------------
  534. ! Deallocate temporary data
  535. !-----------------------------------------------------------------------
  536. DEALLOCATE( ifileidx, iprofidx, zdat )
  537. !-----------------------------------------------------------------------
  538. ! Deallocate input data
  539. !-----------------------------------------------------------------------
  540. DO jj = 1, inobf
  541. CALL dealloc_obfbdata( inpfiles(jj) )
  542. END DO
  543. DEALLOCATE( inpfiles )
  544. END SUBROUTINE obs_rea_vel_dri
  545. END MODULE obs_read_vel