diaobs.F90 60 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601
  1. MODULE diaobs
  2. !!======================================================================
  3. !! *** MODULE diaobs ***
  4. !! Observation diagnostics: Computation of the misfit between data and
  5. !! their model equivalent
  6. !!======================================================================
  7. !!----------------------------------------------------------------------
  8. !! 'key_diaobs' : Switch on the observation diagnostic computation
  9. !!----------------------------------------------------------------------
  10. !! dia_obs_init : Reading and prepare observations
  11. !! dia_obs : Compute model equivalent to observations
  12. !! dia_obs_wri : Write observational diagnostics
  13. !! ini_date : Compute the initial date YYYYMMDD.HHMMSS
  14. !! fin_date : Compute the final date YYYYMMDD.HHMMSS
  15. !!----------------------------------------------------------------------
  16. !! * Modules used
  17. USE wrk_nemo ! Memory Allocation
  18. USE par_kind ! Precision variables
  19. USE in_out_manager ! I/O manager
  20. USE par_oce
  21. USE dom_oce ! Ocean space and time domain variables
  22. USE obs_fbm, ONLY: ln_cl4 ! Class 4 diagnostic switch
  23. USE obs_read_prof ! Reading and allocation of observations (Coriolis)
  24. USE obs_read_sla ! Reading and allocation of SLA observations
  25. USE obs_read_sst ! Reading and allocation of SST observations
  26. USE obs_readmdt ! Reading and allocation of MDT for SLA.
  27. USE obs_read_seaice ! Reading and allocation of Sea Ice observations
  28. USE obs_read_vel ! Reading and allocation of velocity component observations
  29. USE obs_prep ! Preparation of obs. (grid search etc).
  30. USE obs_oper ! Observation operators
  31. USE obs_write ! Writing of observation related diagnostics
  32. USE obs_grid ! Grid searching
  33. USE obs_read_altbias ! Bias treatment for altimeter
  34. USE obs_profiles_def ! Profile data definitions
  35. USE obs_profiles ! Profile data storage
  36. USE obs_surf_def ! Surface data definitions
  37. USE obs_sla ! SLA data storage
  38. USE obs_sst ! SST data storage
  39. USE obs_seaice ! Sea Ice data storage
  40. USE obs_types ! Definitions for observation types
  41. USE mpp_map ! MPP mapping
  42. USE lib_mpp ! For ctl_warn/stop
  43. IMPLICIT NONE
  44. !! * Routine accessibility
  45. PRIVATE
  46. PUBLIC dia_obs_init, & ! Initialize and read observations
  47. & dia_obs, & ! Compute model equivalent to observations
  48. & dia_obs_wri, & ! Write model equivalent to observations
  49. & dia_obs_dealloc ! Deallocate dia_obs data
  50. !! * Shared Module variables
  51. LOGICAL, PUBLIC, PARAMETER :: &
  52. #if defined key_diaobs
  53. & lk_diaobs = .TRUE. !: Logical switch for observation diangostics
  54. #else
  55. & lk_diaobs = .FALSE. !: Logical switch for observation diangostics
  56. #endif
  57. !! * Module variables
  58. LOGICAL, PUBLIC :: ln_t3d !: Logical switch for temperature profiles
  59. LOGICAL, PUBLIC :: ln_s3d !: Logical switch for salinity profiles
  60. LOGICAL, PUBLIC :: ln_ena !: Logical switch for the ENACT data set
  61. LOGICAL, PUBLIC :: ln_cor !: Logical switch for the Coriolis data set
  62. LOGICAL, PUBLIC :: ln_profb !: Logical switch for profile feedback datafiles
  63. LOGICAL, PUBLIC :: ln_sla !: Logical switch for sea level anomalies
  64. LOGICAL, PUBLIC :: ln_sladt !: Logical switch for SLA from AVISO files
  65. LOGICAL, PUBLIC :: ln_slafb !: Logical switch for SLA from feedback files
  66. LOGICAL, PUBLIC :: ln_sst !: Logical switch for sea surface temperature
  67. LOGICAL, PUBLIC :: ln_reysst !: Logical switch for Reynolds sea surface temperature
  68. LOGICAL, PUBLIC :: ln_ghrsst !: Logical switch for GHRSST data
  69. LOGICAL, PUBLIC :: ln_sstfb !: Logical switch for SST from feedback files
  70. LOGICAL, PUBLIC :: ln_seaice !: Logical switch for sea ice concentration
  71. LOGICAL, PUBLIC :: ln_vel3d !: Logical switch for velocity component (u,v) observations
  72. LOGICAL, PUBLIC :: ln_velavcur !: Logical switch for raw daily averaged netCDF current meter vel. data
  73. LOGICAL, PUBLIC :: ln_velhrcur !: Logical switch for raw high freq netCDF current meter vel. data
  74. LOGICAL, PUBLIC :: ln_velavadcp !: Logical switch for raw daily averaged netCDF ADCP vel. data
  75. LOGICAL, PUBLIC :: ln_velhradcp !: Logical switch for raw high freq netCDF ADCP vel. data
  76. LOGICAL, PUBLIC :: ln_velfb !: Logical switch for velocities from feedback files
  77. LOGICAL, PUBLIC :: ln_ssh !: Logical switch for sea surface height
  78. LOGICAL, PUBLIC :: ln_sss !: Logical switch for sea surface salinity
  79. LOGICAL, PUBLIC :: ln_sstnight !: Logical switch for night mean SST observations
  80. LOGICAL, PUBLIC :: ln_nea !: Remove observations near land
  81. LOGICAL, PUBLIC :: ln_altbias !: Logical switch for altimeter bias
  82. LOGICAL, PUBLIC :: ln_ignmis !: Logical switch for ignoring missing files
  83. LOGICAL, PUBLIC :: ln_s_at_t !: Logical switch to compute model S at T observations
  84. REAL(KIND=dp), PUBLIC :: dobsini !: Observation window start date YYYYMMDD.HHMMSS
  85. REAL(KIND=dp), PUBLIC :: dobsend !: Observation window end date YYYYMMDD.HHMMSS
  86. INTEGER, PUBLIC :: n1dint !: Vertical interpolation method
  87. INTEGER, PUBLIC :: n2dint !: Horizontal interpolation method
  88. INTEGER, DIMENSION(imaxavtypes) :: &
  89. & endailyavtypes !: ENACT data types which are daily average
  90. INTEGER, PARAMETER :: MaxNumFiles = 1000
  91. LOGICAL, DIMENSION(MaxNumFiles) :: &
  92. & ln_profb_ena, & !: Is the feedback files from ENACT data ?
  93. ! !: If so use endailyavtypes
  94. & ln_profb_enatim !: Change tim for 820 enact data set.
  95. LOGICAL, DIMENSION(MaxNumFiles) :: &
  96. & ln_velfb_av !: Is the velocity feedback files daily average?
  97. LOGICAL, DIMENSION(:), ALLOCATABLE :: &
  98. & ld_enact !: Profile data is ENACT so use endailyavtypes
  99. LOGICAL, DIMENSION(:), ALLOCATABLE :: &
  100. & ld_velav !: Velocity data is daily averaged
  101. LOGICAL, DIMENSION(:), ALLOCATABLE :: &
  102. & ld_sstnight !: SST observation corresponds to night mean
  103. !!----------------------------------------------------------------------
  104. !! NEMO/OPA 3.3 , NEMO Consortium (2010)
  105. !! $Id: diaobs.F90 4990 2014-12-15 16:42:49Z timgraham $
  106. !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
  107. !!----------------------------------------------------------------------
  108. CONTAINS
  109. SUBROUTINE dia_obs_init
  110. !!----------------------------------------------------------------------
  111. !! *** ROUTINE dia_obs_init ***
  112. !!
  113. !! ** Purpose : Initialize and read observations
  114. !!
  115. !! ** Method : Read the namelist and call reading routines
  116. !!
  117. !! ** Action : Read the namelist and call reading routines
  118. !!
  119. !! History :
  120. !! ! 06-03 (K. Mogensen) Original code
  121. !! ! 06-05 (A. Weaver) Reformatted
  122. !! ! 06-10 (A. Weaver) Cleaning and add controls
  123. !! ! 07-03 (K. Mogensen) General handling of profiles
  124. !!----------------------------------------------------------------------
  125. IMPLICIT NONE
  126. !! * Local declarations
  127. CHARACTER(len=128) :: enactfiles(MaxNumFiles)
  128. CHARACTER(len=128) :: coriofiles(MaxNumFiles)
  129. CHARACTER(len=128) :: profbfiles(MaxNumFiles)
  130. CHARACTER(len=128) :: sstfiles(MaxNumFiles)
  131. CHARACTER(len=128) :: sstfbfiles(MaxNumFiles)
  132. CHARACTER(len=128) :: slafilesact(MaxNumFiles)
  133. CHARACTER(len=128) :: slafilespas(MaxNumFiles)
  134. CHARACTER(len=128) :: slafbfiles(MaxNumFiles)
  135. CHARACTER(len=128) :: seaicefiles(MaxNumFiles)
  136. CHARACTER(len=128) :: velcurfiles(MaxNumFiles)
  137. CHARACTER(len=128) :: veladcpfiles(MaxNumFiles)
  138. CHARACTER(len=128) :: velavcurfiles(MaxNumFiles)
  139. CHARACTER(len=128) :: velhrcurfiles(MaxNumFiles)
  140. CHARACTER(len=128) :: velavadcpfiles(MaxNumFiles)
  141. CHARACTER(len=128) :: velhradcpfiles(MaxNumFiles)
  142. CHARACTER(len=128) :: velfbfiles(MaxNumFiles)
  143. CHARACTER(LEN=128) :: reysstname
  144. CHARACTER(LEN=12) :: reysstfmt
  145. CHARACTER(LEN=128) :: bias_file
  146. CHARACTER(LEN=20) :: datestr=" ", timestr=" "
  147. NAMELIST/namobs/ln_ena, ln_cor, ln_profb, ln_t3d, ln_s3d, &
  148. & ln_sla, ln_sladt, ln_slafb, &
  149. & ln_ssh, ln_sst, ln_sstfb, ln_sss, ln_nea, &
  150. & enactfiles, coriofiles, profbfiles, &
  151. & slafilesact, slafilespas, slafbfiles, &
  152. & sstfiles, sstfbfiles, &
  153. & ln_seaice, seaicefiles, &
  154. & dobsini, dobsend, n1dint, n2dint, &
  155. & nmsshc, mdtcorr, mdtcutoff, &
  156. & ln_reysst, ln_ghrsst, reysstname, reysstfmt, &
  157. & ln_sstnight, &
  158. & ln_grid_search_lookup, &
  159. & grid_search_file, grid_search_res, &
  160. & ln_grid_global, bias_file, ln_altbias, &
  161. & endailyavtypes, ln_s_at_t, ln_profb_ena, &
  162. & ln_vel3d, ln_velavcur, velavcurfiles, &
  163. & ln_velhrcur, velhrcurfiles, &
  164. & ln_velavadcp, velavadcpfiles, &
  165. & ln_velhradcp, velhradcpfiles, &
  166. & ln_velfb, velfbfiles, ln_velfb_av, &
  167. & ln_profb_enatim, ln_ignmis, ln_cl4
  168. INTEGER :: jprofset
  169. INTEGER :: jveloset
  170. INTEGER :: jvar
  171. INTEGER :: jnumenact
  172. INTEGER :: jnumcorio
  173. INTEGER :: jnumprofb
  174. INTEGER :: jnumslaact
  175. INTEGER :: jnumslapas
  176. INTEGER :: jnumslafb
  177. INTEGER :: jnumsst
  178. INTEGER :: jnumsstfb
  179. INTEGER :: jnumseaice
  180. INTEGER :: jnumvelavcur
  181. INTEGER :: jnumvelhrcur
  182. INTEGER :: jnumvelavadcp
  183. INTEGER :: jnumvelhradcp
  184. INTEGER :: jnumvelfb
  185. INTEGER :: ji
  186. INTEGER :: jset
  187. INTEGER :: ios ! Local integer output status for namelist read
  188. LOGICAL :: lmask(MaxNumFiles), ll_u3d, ll_v3d
  189. !-----------------------------------------------------------------------
  190. ! Read namelist parameters
  191. !-----------------------------------------------------------------------
  192. enactfiles(:) = ''
  193. coriofiles(:) = ''
  194. profbfiles(:) = ''
  195. slafilesact(:) = ''
  196. slafilespas(:) = ''
  197. slafbfiles(:) = ''
  198. sstfiles(:) = ''
  199. sstfbfiles(:) = ''
  200. seaicefiles(:) = ''
  201. velcurfiles(:) = ''
  202. veladcpfiles(:) = ''
  203. velavcurfiles(:) = ''
  204. velhrcurfiles(:) = ''
  205. velavadcpfiles(:) = ''
  206. velhradcpfiles(:) = ''
  207. velfbfiles(:) = ''
  208. velcurfiles(:) = ''
  209. veladcpfiles(:) = ''
  210. endailyavtypes(:) = -1
  211. endailyavtypes(1) = 820
  212. ln_profb_ena(:) = .FALSE.
  213. ln_profb_enatim(:) = .TRUE.
  214. ln_velfb_av(:) = .FALSE.
  215. ln_ignmis = .FALSE.
  216. CALL ini_date( dobsini )
  217. CALL fin_date( dobsend )
  218. ! Read Namelist namobs : control observation diagnostics
  219. REWIND( numnam_ref ) ! Namelist namobs in reference namelist : Diagnostic: control observation
  220. READ ( numnam_ref, namobs, IOSTAT = ios, ERR = 901)
  221. 901 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namobs in reference namelist', lwp )
  222. REWIND( numnam_cfg ) ! Namelist namobs in configuration namelist : Diagnostic: control observation
  223. READ ( numnam_cfg, namobs, IOSTAT = ios, ERR = 902 )
  224. 902 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namobs in configuration namelist', lwp )
  225. IF(lwm) WRITE ( numond, namobs )
  226. ! Count number of files for each type
  227. IF (ln_ena) THEN
  228. lmask(:) = .FALSE.
  229. WHERE (enactfiles(:) /= '') lmask(:) = .TRUE.
  230. jnumenact = COUNT(lmask)
  231. ENDIF
  232. IF (ln_cor) THEN
  233. lmask(:) = .FALSE.
  234. WHERE (coriofiles(:) /= '') lmask(:) = .TRUE.
  235. jnumcorio = COUNT(lmask)
  236. ENDIF
  237. IF (ln_profb) THEN
  238. lmask(:) = .FALSE.
  239. WHERE (profbfiles(:) /= '') lmask(:) = .TRUE.
  240. jnumprofb = COUNT(lmask)
  241. ENDIF
  242. IF (ln_sladt) THEN
  243. lmask(:) = .FALSE.
  244. WHERE (slafilesact(:) /= '') lmask(:) = .TRUE.
  245. jnumslaact = COUNT(lmask)
  246. lmask(:) = .FALSE.
  247. WHERE (slafilespas(:) /= '') lmask(:) = .TRUE.
  248. jnumslapas = COUNT(lmask)
  249. ENDIF
  250. IF (ln_slafb) THEN
  251. lmask(:) = .FALSE.
  252. WHERE (slafbfiles(:) /= '') lmask(:) = .TRUE.
  253. jnumslafb = COUNT(lmask)
  254. lmask(:) = .FALSE.
  255. ENDIF
  256. IF (ln_ghrsst) THEN
  257. lmask(:) = .FALSE.
  258. WHERE (sstfiles(:) /= '') lmask(:) = .TRUE.
  259. jnumsst = COUNT(lmask)
  260. ENDIF
  261. IF (ln_sstfb) THEN
  262. lmask(:) = .FALSE.
  263. WHERE (sstfbfiles(:) /= '') lmask(:) = .TRUE.
  264. jnumsstfb = COUNT(lmask)
  265. lmask(:) = .FALSE.
  266. ENDIF
  267. IF (ln_seaice) THEN
  268. lmask(:) = .FALSE.
  269. WHERE (seaicefiles(:) /= '') lmask(:) = .TRUE.
  270. jnumseaice = COUNT(lmask)
  271. ENDIF
  272. IF (ln_velavcur) THEN
  273. lmask(:) = .FALSE.
  274. WHERE (velavcurfiles(:) /= '') lmask(:) = .TRUE.
  275. jnumvelavcur = COUNT(lmask)
  276. ENDIF
  277. IF (ln_velhrcur) THEN
  278. lmask(:) = .FALSE.
  279. WHERE (velhrcurfiles(:) /= '') lmask(:) = .TRUE.
  280. jnumvelhrcur = COUNT(lmask)
  281. ENDIF
  282. IF (ln_velavadcp) THEN
  283. lmask(:) = .FALSE.
  284. WHERE (velavadcpfiles(:) /= '') lmask(:) = .TRUE.
  285. jnumvelavadcp = COUNT(lmask)
  286. ENDIF
  287. IF (ln_velhradcp) THEN
  288. lmask(:) = .FALSE.
  289. WHERE (velhradcpfiles(:) /= '') lmask(:) = .TRUE.
  290. jnumvelhradcp = COUNT(lmask)
  291. ENDIF
  292. IF (ln_velfb) THEN
  293. lmask(:) = .FALSE.
  294. WHERE (velfbfiles(:) /= '') lmask(:) = .TRUE.
  295. jnumvelfb = COUNT(lmask)
  296. lmask(:) = .FALSE.
  297. ENDIF
  298. ! Control print
  299. IF(lwp) THEN
  300. WRITE(numout,*)
  301. WRITE(numout,*) 'dia_obs_init : Observation diagnostic initialization'
  302. WRITE(numout,*) '~~~~~~~~~~~~'
  303. WRITE(numout,*) ' Namelist namobs : set observation diagnostic parameters'
  304. WRITE(numout,*) ' Logical switch for T profile observations ln_t3d = ', ln_t3d
  305. WRITE(numout,*) ' Logical switch for S profile observations ln_s3d = ', ln_s3d
  306. WRITE(numout,*) ' Logical switch for ENACT insitu data set ln_ena = ', ln_ena
  307. WRITE(numout,*) ' Logical switch for Coriolis insitu data set ln_cor = ', ln_cor
  308. WRITE(numout,*) ' Logical switch for feedback insitu data set ln_profb = ', ln_profb
  309. WRITE(numout,*) ' Logical switch for SLA observations ln_sla = ', ln_sla
  310. WRITE(numout,*) ' Logical switch for AVISO SLA data ln_sladt = ', ln_sladt
  311. WRITE(numout,*) ' Logical switch for feedback SLA data ln_slafb = ', ln_slafb
  312. WRITE(numout,*) ' Logical switch for SSH observations ln_ssh = ', ln_ssh
  313. WRITE(numout,*) ' Logical switch for SST observations ln_sst = ', ln_sst
  314. WRITE(numout,*) ' Logical switch for Reynolds observations ln_reysst = ', ln_reysst
  315. WRITE(numout,*) ' Logical switch for GHRSST observations ln_ghrsst = ', ln_ghrsst
  316. WRITE(numout,*) ' Logical switch for feedback SST data ln_sstfb = ', ln_sstfb
  317. WRITE(numout,*) ' Logical switch for night-time SST obs ln_sstnight = ', ln_sstnight
  318. WRITE(numout,*) ' Logical switch for SSS observations ln_sss = ', ln_sss
  319. WRITE(numout,*) ' Logical switch for Sea Ice observations ln_seaice = ', ln_seaice
  320. WRITE(numout,*) ' Logical switch for velocity observations ln_vel3d = ', ln_vel3d
  321. WRITE(numout,*) ' Logical switch for velocity daily av. cur. ln_velavcur = ', ln_velavcur
  322. WRITE(numout,*) ' Logical switch for velocity high freq. cur. ln_velhrcur = ', ln_velhrcur
  323. WRITE(numout,*) ' Logical switch for velocity daily av. ADCP ln_velavadcp = ', ln_velavadcp
  324. WRITE(numout,*) ' Logical switch for velocity high freq. ADCP ln_velhradcp = ', ln_velhradcp
  325. WRITE(numout,*) ' Logical switch for feedback velocity data ln_velfb = ', ln_velfb
  326. WRITE(numout,*) ' Global distribtion of observations ln_grid_global = ',ln_grid_global
  327. WRITE(numout,*) &
  328. ' Logical switch for obs grid search w/lookup table ln_grid_search_lookup = ',ln_grid_search_lookup
  329. IF (ln_grid_search_lookup) &
  330. WRITE(numout,*) ' Grid search lookup file header grid_search_file = ', grid_search_file
  331. IF (ln_ena) THEN
  332. DO ji = 1, jnumenact
  333. WRITE(numout,'(1X,2A)') ' ENACT input observation file name enactfiles = ', &
  334. TRIM(enactfiles(ji))
  335. END DO
  336. ENDIF
  337. IF (ln_cor) THEN
  338. DO ji = 1, jnumcorio
  339. WRITE(numout,'(1X,2A)') ' Coriolis input observation file name coriofiles = ', &
  340. TRIM(coriofiles(ji))
  341. END DO
  342. ENDIF
  343. IF (ln_profb) THEN
  344. DO ji = 1, jnumprofb
  345. IF (ln_profb_ena(ji)) THEN
  346. WRITE(numout,'(1X,2A)') ' Enact feedback input observation file name profbfiles = ', &
  347. TRIM(profbfiles(ji))
  348. ELSE
  349. WRITE(numout,'(1X,2A)') ' Feedback input observation file name profbfiles = ', &
  350. TRIM(profbfiles(ji))
  351. ENDIF
  352. WRITE(numout,'(1X,2A)') ' Enact feedback input time setting switch ln_profb_enatim = ', ln_profb_enatim(ji)
  353. END DO
  354. ENDIF
  355. IF (ln_sladt) THEN
  356. DO ji = 1, jnumslaact
  357. WRITE(numout,'(1X,2A)') ' Active SLA input observation file name slafilesact = ', &
  358. TRIM(slafilesact(ji))
  359. END DO
  360. DO ji = 1, jnumslapas
  361. WRITE(numout,'(1X,2A)') ' Passive SLA input observation file name slafilespas = ', &
  362. TRIM(slafilespas(ji))
  363. END DO
  364. ENDIF
  365. IF (ln_slafb) THEN
  366. DO ji = 1, jnumslafb
  367. WRITE(numout,'(1X,2A)') ' Feedback SLA input observation file name slafbfiles = ', &
  368. TRIM(slafbfiles(ji))
  369. END DO
  370. ENDIF
  371. IF (ln_ghrsst) THEN
  372. DO ji = 1, jnumsst
  373. WRITE(numout,'(1X,2A)') ' GHRSST input observation file name sstfiles = ', &
  374. TRIM(sstfiles(ji))
  375. END DO
  376. ENDIF
  377. IF (ln_sstfb) THEN
  378. DO ji = 1, jnumsstfb
  379. WRITE(numout,'(1X,2A)') ' Feedback SST input observation file name sstfbfiles = ', &
  380. TRIM(sstfbfiles(ji))
  381. END DO
  382. ENDIF
  383. IF (ln_seaice) THEN
  384. DO ji = 1, jnumseaice
  385. WRITE(numout,'(1X,2A)') ' Sea Ice input observation file name seaicefiles = ', &
  386. TRIM(seaicefiles(ji))
  387. END DO
  388. ENDIF
  389. IF (ln_velavcur) THEN
  390. DO ji = 1, jnumvelavcur
  391. WRITE(numout,'(1X,2A)') ' Vel. cur. daily av. input file name velavcurfiles = ', &
  392. TRIM(velavcurfiles(ji))
  393. END DO
  394. ENDIF
  395. IF (ln_velhrcur) THEN
  396. DO ji = 1, jnumvelhrcur
  397. WRITE(numout,'(1X,2A)') ' Vel. cur. high freq. input file name velhvcurfiles = ', &
  398. TRIM(velhrcurfiles(ji))
  399. END DO
  400. ENDIF
  401. IF (ln_velavadcp) THEN
  402. DO ji = 1, jnumvelavadcp
  403. WRITE(numout,'(1X,2A)') ' Vel. ADCP daily av. input file name velavadcpfiles = ', &
  404. TRIM(velavadcpfiles(ji))
  405. END DO
  406. ENDIF
  407. IF (ln_velhradcp) THEN
  408. DO ji = 1, jnumvelhradcp
  409. WRITE(numout,'(1X,2A)') ' Vel. ADCP high freq. input file name velhvadcpfiles = ', &
  410. TRIM(velhradcpfiles(ji))
  411. END DO
  412. ENDIF
  413. IF (ln_velfb) THEN
  414. DO ji = 1, jnumvelfb
  415. IF (ln_velfb_av(ji)) THEN
  416. WRITE(numout,'(1X,2A)') ' Vel. feedback daily av. input file name velfbfiles = ', &
  417. TRIM(velfbfiles(ji))
  418. ELSE
  419. WRITE(numout,'(1X,2A)') ' Vel. feedback input observation file name velfbfiles = ', &
  420. TRIM(velfbfiles(ji))
  421. ENDIF
  422. END DO
  423. ENDIF
  424. WRITE(numout,*) ' Initial date in window YYYYMMDD.HHMMSS dobsini = ', dobsini
  425. WRITE(numout,*) ' Final date in window YYYYMMDD.HHMMSS dobsend = ', dobsend
  426. WRITE(numout,*) ' Type of vertical interpolation method n1dint = ', n1dint
  427. WRITE(numout,*) ' Type of horizontal interpolation method n2dint = ', n2dint
  428. WRITE(numout,*) ' Rejection of observations near land swithch ln_nea = ', ln_nea
  429. WRITE(numout,*) ' MSSH correction scheme nmsshc = ', nmsshc
  430. WRITE(numout,*) ' MDT correction mdtcorr = ', mdtcorr
  431. WRITE(numout,*) ' MDT cutoff for computed correction mdtcutoff = ', mdtcutoff
  432. WRITE(numout,*) ' Logical switch for alt bias ln_altbias = ', ln_altbias
  433. WRITE(numout,*) ' Logical switch for ignoring missing files ln_ignmis = ', ln_ignmis
  434. WRITE(numout,*) ' ENACT daily average types = ',endailyavtypes
  435. ENDIF
  436. IF ( ln_vel3d .AND. ( .NOT. ln_grid_global ) ) THEN
  437. CALL ctl_stop( 'Velocity data only works with ln_grid_global=.true.' )
  438. RETURN
  439. ENDIF
  440. CALL obs_typ_init
  441. CALL mppmap_init
  442. ! Parameter control
  443. #if defined key_diaobs
  444. IF ( ( .NOT. ln_t3d ).AND.( .NOT. ln_s3d ).AND.( .NOT. ln_sla ).AND. &
  445. & ( .NOT. ln_vel3d ).AND. &
  446. & ( .NOT. ln_ssh ).AND.( .NOT. ln_sst ).AND.( .NOT. ln_sss ).AND. &
  447. & ( .NOT. ln_seaice ).AND.( .NOT. ln_vel3d ) ) THEN
  448. IF(lwp) WRITE(numout,cform_war)
  449. IF(lwp) WRITE(numout,*) ' key_diaobs is activated but logical flags', &
  450. & ' ln_t3d, ln_s3d, ln_sla, ln_ssh, ln_sst, ln_sss, ln_seaice, ln_vel3d are all set to .FALSE.'
  451. nwarn = nwarn + 1
  452. ENDIF
  453. #endif
  454. CALL obs_grid_setup( )
  455. IF ( ( n1dint < 0 ).OR.( n1dint > 1 ) ) THEN
  456. CALL ctl_stop(' Choice of vertical (1D) interpolation method', &
  457. & ' is not available')
  458. ENDIF
  459. IF ( ( n2dint < 0 ).OR.( n2dint > 4 ) ) THEN
  460. CALL ctl_stop(' Choice of horizontal (2D) interpolation method', &
  461. & ' is not available')
  462. ENDIF
  463. !-----------------------------------------------------------------------
  464. ! Depending on switches read the various observation types
  465. !-----------------------------------------------------------------------
  466. ! - Temperature/salinity profiles
  467. IF ( ln_t3d .OR. ln_s3d ) THEN
  468. ! Set the number of variables for profiles to 2 (T and S)
  469. nprofvars = 2
  470. ! Set the number of extra variables for profiles to 1 (insitu temp).
  471. nprofextr = 1
  472. ! Count how may insitu data sets we have and allocate data.
  473. jprofset = 0
  474. IF ( ln_ena ) jprofset = jprofset + 1
  475. IF ( ln_cor ) jprofset = jprofset + 1
  476. IF ( ln_profb ) jprofset = jprofset + jnumprofb
  477. nprofsets = jprofset
  478. IF ( nprofsets > 0 ) THEN
  479. ALLOCATE(ld_enact(nprofsets))
  480. ALLOCATE(profdata(nprofsets))
  481. ALLOCATE(prodatqc(nprofsets))
  482. ENDIF
  483. jprofset = 0
  484. ! ENACT insitu data
  485. IF ( ln_ena ) THEN
  486. jprofset = jprofset + 1
  487. ld_enact(jprofset) = .TRUE.
  488. CALL obs_rea_pro_dri( 1, profdata(jprofset), &
  489. & jnumenact, enactfiles(1:jnumenact), &
  490. & nprofvars, nprofextr, &
  491. & nitend-nit000+2, &
  492. & dobsini, dobsend, ln_t3d, ln_s3d, &
  493. & ln_ignmis, ln_s_at_t, .TRUE., .FALSE., &
  494. & kdailyavtypes = endailyavtypes )
  495. DO jvar = 1, 2
  496. CALL obs_prof_staend( profdata(jprofset), jvar )
  497. END DO
  498. CALL obs_pre_pro( profdata(jprofset), prodatqc(jprofset), &
  499. & ln_t3d, ln_s3d, ln_nea, &
  500. & kdailyavtypes=endailyavtypes )
  501. ENDIF
  502. ! Coriolis insitu data
  503. IF ( ln_cor ) THEN
  504. jprofset = jprofset + 1
  505. ld_enact(jprofset) = .FALSE.
  506. CALL obs_rea_pro_dri( 2, profdata(jprofset), &
  507. & jnumcorio, coriofiles(1:jnumcorio), &
  508. & nprofvars, nprofextr, &
  509. & nitend-nit000+2, &
  510. & dobsini, dobsend, ln_t3d, ln_s3d, &
  511. & ln_ignmis, ln_s_at_t, .FALSE., .FALSE. )
  512. DO jvar = 1, 2
  513. CALL obs_prof_staend( profdata(jprofset), jvar )
  514. END DO
  515. CALL obs_pre_pro( profdata(jprofset), prodatqc(jprofset), &
  516. & ln_t3d, ln_s3d, ln_nea )
  517. ENDIF
  518. ! Feedback insitu data
  519. IF ( ln_profb ) THEN
  520. DO jset = 1, jnumprofb
  521. jprofset = jprofset + 1
  522. ld_enact (jprofset) = ln_profb_ena(jset)
  523. CALL obs_rea_pro_dri( 0, profdata(jprofset), &
  524. & 1, profbfiles(jset:jset), &
  525. & nprofvars, nprofextr, &
  526. & nitend-nit000+2, &
  527. & dobsini, dobsend, ln_t3d, ln_s3d, &
  528. & ln_ignmis, ln_s_at_t, &
  529. & ld_enact(jprofset).AND.&
  530. & ln_profb_enatim(jset), &
  531. & .FALSE., kdailyavtypes = endailyavtypes )
  532. DO jvar = 1, 2
  533. CALL obs_prof_staend( profdata(jprofset), jvar )
  534. END DO
  535. IF ( ld_enact(jprofset) ) THEN
  536. CALL obs_pre_pro( profdata(jprofset), prodatqc(jprofset), &
  537. & ln_t3d, ln_s3d, ln_nea, &
  538. & kdailyavtypes = endailyavtypes )
  539. ELSE
  540. CALL obs_pre_pro( profdata(jprofset), prodatqc(jprofset), &
  541. & ln_t3d, ln_s3d, ln_nea )
  542. ENDIF
  543. END DO
  544. ENDIF
  545. ENDIF
  546. ! - Sea level anomalies
  547. IF ( ln_sla ) THEN
  548. ! Set the number of variables for sla to 1
  549. nslavars = 1
  550. ! Set the number of extra variables for sla to 2
  551. nslaextr = 2
  552. ! Set the number of sla data sets to 2
  553. nslasets = 0
  554. IF ( ln_sladt ) THEN
  555. nslasets = nslasets + 2
  556. ENDIF
  557. IF ( ln_slafb ) THEN
  558. nslasets = nslasets + jnumslafb
  559. ENDIF
  560. ALLOCATE(sladata(nslasets))
  561. ALLOCATE(sladatqc(nslasets))
  562. sladata(:)%nsurf=0
  563. sladatqc(:)%nsurf=0
  564. nslasets = 0
  565. ! AVISO SLA data
  566. IF ( ln_sladt ) THEN
  567. ! Active SLA observations
  568. nslasets = nslasets + 1
  569. CALL obs_rea_sla( 1, sladata(nslasets), jnumslaact, &
  570. & slafilesact(1:jnumslaact), &
  571. & nslavars, nslaextr, nitend-nit000+2, &
  572. & dobsini, dobsend, ln_ignmis, .FALSE. )
  573. CALL obs_pre_sla( sladata(nslasets), sladatqc(nslasets), &
  574. & ln_sla, ln_nea )
  575. ! Passive SLA observations
  576. nslasets = nslasets + 1
  577. CALL obs_rea_sla( 1, sladata(nslasets), jnumslapas, &
  578. & slafilespas(1:jnumslapas), &
  579. & nslavars, nslaextr, nitend-nit000+2, &
  580. & dobsini, dobsend, ln_ignmis, .FALSE. )
  581. CALL obs_pre_sla( sladata(nslasets), sladatqc(nslasets), &
  582. & ln_sla, ln_nea )
  583. ENDIF
  584. ! Feedback SLA data
  585. IF ( ln_slafb ) THEN
  586. DO jset = 1, jnumslafb
  587. nslasets = nslasets + 1
  588. CALL obs_rea_sla( 0, sladata(nslasets), 1, &
  589. & slafbfiles(jset:jset), &
  590. & nslavars, nslaextr, nitend-nit000+2, &
  591. & dobsini, dobsend, ln_ignmis, .FALSE. )
  592. CALL obs_pre_sla( sladata(nslasets), sladatqc(nslasets), &
  593. & ln_sla, ln_nea )
  594. END DO
  595. ENDIF
  596. CALL obs_rea_mdt( nslasets, sladatqc, n2dint )
  597. ! read in altimeter bias
  598. IF ( ln_altbias ) THEN
  599. CALL obs_rea_altbias ( nslasets, sladatqc, n2dint, bias_file )
  600. ENDIF
  601. ENDIF
  602. ! - Sea surface height
  603. IF ( ln_ssh ) THEN
  604. IF(lwp) WRITE(numout,*) ' SSH currently not available'
  605. ENDIF
  606. ! - Sea surface temperature
  607. IF ( ln_sst ) THEN
  608. ! Set the number of variables for sst to 1
  609. nsstvars = 1
  610. ! Set the number of extra variables for sst to 0
  611. nsstextr = 0
  612. nsstsets = 0
  613. IF (ln_reysst) nsstsets = nsstsets + 1
  614. IF (ln_ghrsst) nsstsets = nsstsets + 1
  615. IF ( ln_sstfb ) THEN
  616. nsstsets = nsstsets + jnumsstfb
  617. ENDIF
  618. ALLOCATE(sstdata(nsstsets))
  619. ALLOCATE(sstdatqc(nsstsets))
  620. ALLOCATE(ld_sstnight(nsstsets))
  621. sstdata(:)%nsurf=0
  622. sstdatqc(:)%nsurf=0
  623. ld_sstnight(:)=.false.
  624. nsstsets = 0
  625. IF (ln_reysst) THEN
  626. nsstsets = nsstsets + 1
  627. ld_sstnight(nsstsets) = ln_sstnight
  628. CALL obs_rea_sst_rey( reysstname, reysstfmt, sstdata(nsstsets), &
  629. & nsstvars, nsstextr, &
  630. & nitend-nit000+2, dobsini, dobsend )
  631. CALL obs_pre_sst( sstdata(nsstsets), sstdatqc(nsstsets), ln_sst, &
  632. & ln_nea )
  633. ENDIF
  634. IF (ln_ghrsst) THEN
  635. nsstsets = nsstsets + 1
  636. ld_sstnight(nsstsets) = ln_sstnight
  637. CALL obs_rea_sst( 1, sstdata(nsstsets), jnumsst, &
  638. & sstfiles(1:jnumsst), &
  639. & nsstvars, nsstextr, nitend-nit000+2, &
  640. & dobsini, dobsend, ln_ignmis, .FALSE. )
  641. CALL obs_pre_sst( sstdata(nsstsets), sstdatqc(nsstsets), ln_sst, &
  642. & ln_nea )
  643. ENDIF
  644. ! Feedback SST data
  645. IF ( ln_sstfb ) THEN
  646. DO jset = 1, jnumsstfb
  647. nsstsets = nsstsets + 1
  648. ld_sstnight(nsstsets) = ln_sstnight
  649. CALL obs_rea_sst( 0, sstdata(nsstsets), 1, &
  650. & sstfbfiles(jset:jset), &
  651. & nsstvars, nsstextr, nitend-nit000+2, &
  652. & dobsini, dobsend, ln_ignmis, .FALSE. )
  653. CALL obs_pre_sst( sstdata(nsstsets), sstdatqc(nsstsets), &
  654. & ln_sst, ln_nea )
  655. END DO
  656. ENDIF
  657. ENDIF
  658. ! - Sea surface salinity
  659. IF ( ln_sss ) THEN
  660. IF(lwp) WRITE(numout,*) ' SSS currently not available'
  661. ENDIF
  662. ! - Sea Ice Concentration
  663. IF ( ln_seaice ) THEN
  664. ! Set the number of variables for seaice to 1
  665. nseaicevars = 1
  666. ! Set the number of extra variables for seaice to 0
  667. nseaiceextr = 0
  668. ! Set the number of data sets to 1
  669. nseaicesets = 1
  670. ALLOCATE(seaicedata(nseaicesets))
  671. ALLOCATE(seaicedatqc(nseaicesets))
  672. seaicedata(:)%nsurf=0
  673. seaicedatqc(:)%nsurf=0
  674. CALL obs_rea_seaice( 1, seaicedata(nseaicesets), jnumseaice, &
  675. & seaicefiles(1:jnumseaice), &
  676. & nseaicevars, nseaiceextr, nitend-nit000+2, &
  677. & dobsini, dobsend, ln_ignmis, .FALSE. )
  678. CALL obs_pre_seaice( seaicedata(nseaicesets), seaicedatqc(nseaicesets), &
  679. & ln_seaice, ln_nea )
  680. ENDIF
  681. IF (ln_vel3d) THEN
  682. ! Set the number of variables for profiles to 2 (U and V)
  683. nvelovars = 2
  684. ! Set the number of extra variables for profiles to 2 to store
  685. ! rotation parameters
  686. nveloextr = 2
  687. jveloset = 0
  688. IF ( ln_velavcur ) jveloset = jveloset + 1
  689. IF ( ln_velhrcur ) jveloset = jveloset + 1
  690. IF ( ln_velavadcp ) jveloset = jveloset + 1
  691. IF ( ln_velhradcp ) jveloset = jveloset + 1
  692. IF (ln_velfb) jveloset = jveloset + jnumvelfb
  693. nvelosets = jveloset
  694. IF ( nvelosets > 0 ) THEN
  695. ALLOCATE( velodata(nvelosets) )
  696. ALLOCATE( veldatqc(nvelosets) )
  697. ALLOCATE( ld_velav(nvelosets) )
  698. ENDIF
  699. jveloset = 0
  700. ! Daily averaged data
  701. IF ( ln_velavcur ) THEN
  702. jveloset = jveloset + 1
  703. ld_velav(jveloset) = .TRUE.
  704. CALL obs_rea_vel_dri( 1, velodata(jveloset), jnumvelavcur, &
  705. & velavcurfiles(1:jnumvelavcur), &
  706. & nvelovars, nveloextr, &
  707. & nitend-nit000+2, &
  708. & dobsini, dobsend, ln_ignmis, &
  709. & ld_velav(jveloset), &
  710. & .FALSE. )
  711. DO jvar = 1, 2
  712. CALL obs_prof_staend( velodata(jveloset), jvar )
  713. END DO
  714. CALL obs_pre_vel( velodata(jveloset), veldatqc(jveloset), &
  715. & ln_vel3d, ln_nea, ld_velav(jveloset) )
  716. ENDIF
  717. ! High frequency data
  718. IF ( ln_velhrcur ) THEN
  719. jveloset = jveloset + 1
  720. ld_velav(jveloset) = .FALSE.
  721. CALL obs_rea_vel_dri( 1, velodata(jveloset), jnumvelhrcur, &
  722. & velhrcurfiles(1:jnumvelhrcur), &
  723. & nvelovars, nveloextr, &
  724. & nitend-nit000+2, &
  725. & dobsini, dobsend, ln_ignmis, &
  726. & ld_velav(jveloset), &
  727. & .FALSE. )
  728. DO jvar = 1, 2
  729. CALL obs_prof_staend( velodata(jveloset), jvar )
  730. END DO
  731. CALL obs_pre_vel( velodata(jveloset), veldatqc(jveloset), &
  732. & ln_vel3d, ln_nea, ld_velav(jveloset) )
  733. ENDIF
  734. ! Daily averaged data
  735. IF ( ln_velavadcp ) THEN
  736. jveloset = jveloset + 1
  737. ld_velav(jveloset) = .TRUE.
  738. CALL obs_rea_vel_dri( 1, velodata(jveloset), jnumvelavadcp, &
  739. & velavadcpfiles(1:jnumvelavadcp), &
  740. & nvelovars, nveloextr, &
  741. & nitend-nit000+2, &
  742. & dobsini, dobsend, ln_ignmis, &
  743. & ld_velav(jveloset), &
  744. & .FALSE. )
  745. DO jvar = 1, 2
  746. CALL obs_prof_staend( velodata(jveloset), jvar )
  747. END DO
  748. CALL obs_pre_vel( velodata(jveloset), veldatqc(jveloset), &
  749. & ln_vel3d, ln_nea, ld_velav(jveloset) )
  750. ENDIF
  751. ! High frequency data
  752. IF ( ln_velhradcp ) THEN
  753. jveloset = jveloset + 1
  754. ld_velav(jveloset) = .FALSE.
  755. CALL obs_rea_vel_dri( 1, velodata(jveloset), jnumvelhradcp, &
  756. & velhradcpfiles(1:jnumvelhradcp), &
  757. & nvelovars, nveloextr, &
  758. & nitend-nit000+2, &
  759. & dobsini, dobsend, ln_ignmis, &
  760. & ld_velav(jveloset), &
  761. & .FALSE. )
  762. DO jvar = 1, 2
  763. CALL obs_prof_staend( velodata(jveloset), jvar )
  764. END DO
  765. CALL obs_pre_vel( velodata(jveloset), veldatqc(jveloset), &
  766. & ln_vel3d, ln_nea, ld_velav(jveloset) )
  767. ENDIF
  768. IF ( ln_velfb ) THEN
  769. DO jset = 1, jnumvelfb
  770. jveloset = jveloset + 1
  771. ld_velav(jveloset) = ln_velfb_av(jset)
  772. CALL obs_rea_vel_dri( 0, velodata(jveloset), 1, &
  773. & velfbfiles(jset:jset), &
  774. & nvelovars, nveloextr, &
  775. & nitend-nit000+2, &
  776. & dobsini, dobsend, ln_ignmis, &
  777. & ld_velav(jveloset), &
  778. & .FALSE. )
  779. DO jvar = 1, 2
  780. CALL obs_prof_staend( velodata(jveloset), jvar )
  781. END DO
  782. CALL obs_pre_vel( velodata(jveloset), veldatqc(jveloset), &
  783. & ln_vel3d, ln_nea, ld_velav(jveloset) )
  784. END DO
  785. ENDIF
  786. ENDIF
  787. END SUBROUTINE dia_obs_init
  788. SUBROUTINE dia_obs( kstp )
  789. !!----------------------------------------------------------------------
  790. !! *** ROUTINE dia_obs ***
  791. !!
  792. !! ** Purpose : Call the observation operators on each time step
  793. !!
  794. !! ** Method : Call the observation operators on each time step to
  795. !! compute the model equivalent of the following date:
  796. !! - T profiles
  797. !! - S profiles
  798. !! - Sea surface height (referenced to a mean)
  799. !! - Sea surface temperature
  800. !! - Sea surface salinity
  801. !! - Velocity component (U,V) profiles
  802. !!
  803. !! ** Action :
  804. !!
  805. !! History :
  806. !! ! 06-03 (K. Mogensen) Original code
  807. !! ! 06-05 (K. Mogensen) Reformatted
  808. !! ! 06-10 (A. Weaver) Cleaning
  809. !! ! 07-03 (K. Mogensen) General handling of profiles
  810. !! ! 07-04 (G. Smith) Generalized surface operators
  811. !! ! 08-10 (M. Valdivieso) obs operator for velocity profiles
  812. !!----------------------------------------------------------------------
  813. !! * Modules used
  814. USE dom_oce, ONLY : & ! Ocean space and time domain variables
  815. & rdt, &
  816. & gdept_1d, &
  817. & tmask, umask, vmask
  818. USE phycst, ONLY : & ! Physical constants
  819. & rday
  820. USE oce, ONLY : & ! Ocean dynamics and tracers variables
  821. & tsn, &
  822. & un, vn, &
  823. & sshn
  824. #if defined key_lim3
  825. USE ice, ONLY : & ! LIM Ice model variables
  826. & frld
  827. #endif
  828. #if defined key_lim2
  829. USE ice_2, ONLY : & ! LIM Ice model variables
  830. & frld
  831. #endif
  832. IMPLICIT NONE
  833. !! * Arguments
  834. INTEGER, INTENT(IN) :: kstp ! Current timestep
  835. !! * Local declarations
  836. INTEGER :: idaystp ! Number of timesteps per day
  837. INTEGER :: jprofset ! Profile data set loop variable
  838. INTEGER :: jslaset ! SLA data set loop variable
  839. INTEGER :: jsstset ! SST data set loop variable
  840. INTEGER :: jseaiceset ! sea ice data set loop variable
  841. INTEGER :: jveloset ! velocity profile data loop variable
  842. INTEGER :: jvar ! Variable number
  843. #if ! defined key_lim2 && ! defined key_lim3
  844. REAL(wp), POINTER, DIMENSION(:,:) :: frld
  845. #endif
  846. CHARACTER(LEN=20) :: datestr=" ",timestr=" "
  847. #if ! defined key_lim2 && ! defined key_lim3
  848. CALL wrk_alloc(jpi,jpj,frld)
  849. #endif
  850. IF(lwp) THEN
  851. WRITE(numout,*)
  852. WRITE(numout,*) 'dia_obs : Call the observation operators', kstp
  853. WRITE(numout,*) '~~~~~~~'
  854. ENDIF
  855. idaystp = NINT( rday / rdt )
  856. !-----------------------------------------------------------------------
  857. ! No LIM => frld == 0.0_wp
  858. !-----------------------------------------------------------------------
  859. #if ! defined key_lim2 && ! defined key_lim3
  860. frld(:,:) = 0.0_wp
  861. #endif
  862. !-----------------------------------------------------------------------
  863. ! Depending on switches call various observation operators
  864. !-----------------------------------------------------------------------
  865. ! - Temperature/salinity profiles
  866. IF ( ln_t3d .OR. ln_s3d ) THEN
  867. DO jprofset = 1, nprofsets
  868. IF ( ld_enact(jprofset) ) THEN
  869. CALL obs_pro_opt( prodatqc(jprofset), &
  870. & kstp, jpi, jpj, jpk, nit000, idaystp, &
  871. & tsn(:,:,:,jp_tem), tsn(:,:,:,jp_sal), &
  872. & gdept_1d, tmask, n1dint, n2dint, &
  873. & kdailyavtypes = endailyavtypes )
  874. ELSE
  875. CALL obs_pro_opt( prodatqc(jprofset), &
  876. & kstp, jpi, jpj, jpk, nit000, idaystp, &
  877. & tsn(:,:,:,jp_tem), tsn(:,:,:,jp_sal), &
  878. & gdept_1d, tmask, n1dint, n2dint )
  879. ENDIF
  880. END DO
  881. ENDIF
  882. ! - Sea surface anomaly
  883. IF ( ln_sla ) THEN
  884. DO jslaset = 1, nslasets
  885. CALL obs_sla_opt( sladatqc(jslaset), &
  886. & kstp, jpi, jpj, nit000, sshn, &
  887. & tmask(:,:,1), n2dint )
  888. END DO
  889. ENDIF
  890. ! - Sea surface temperature
  891. IF ( ln_sst ) THEN
  892. DO jsstset = 1, nsstsets
  893. CALL obs_sst_opt( sstdatqc(jsstset), &
  894. & kstp, jpi, jpj, nit000, idaystp, &
  895. & tsn(:,:,1,jp_tem), tmask(:,:,1), &
  896. & n2dint, ld_sstnight(jsstset) )
  897. END DO
  898. ENDIF
  899. ! - Sea surface salinity
  900. IF ( ln_sss ) THEN
  901. IF(lwp) WRITE(numout,*) ' SSS currently not available'
  902. ENDIF
  903. #if defined key_lim2 || defined key_lim3
  904. IF ( ln_seaice ) THEN
  905. DO jseaiceset = 1, nseaicesets
  906. CALL obs_seaice_opt( seaicedatqc(jseaiceset), &
  907. & kstp, jpi, jpj, nit000, 1.-frld, &
  908. & tmask(:,:,1), n2dint )
  909. END DO
  910. ENDIF
  911. #endif
  912. ! - Velocity profiles
  913. IF ( ln_vel3d ) THEN
  914. DO jveloset = 1, nvelosets
  915. ! zonal component of velocity
  916. CALL obs_vel_opt( veldatqc(jveloset), kstp, jpi, jpj, jpk, &
  917. & nit000, idaystp, un, vn, gdept_1d, umask, vmask, &
  918. n1dint, n2dint, ld_velav(jveloset) )
  919. END DO
  920. ENDIF
  921. #if ! defined key_lim2 && ! defined key_lim3
  922. CALL wrk_dealloc(jpi,jpj,frld)
  923. #endif
  924. END SUBROUTINE dia_obs
  925. SUBROUTINE dia_obs_wri
  926. !!----------------------------------------------------------------------
  927. !! *** ROUTINE dia_obs_wri ***
  928. !!
  929. !! ** Purpose : Call observation diagnostic output routines
  930. !!
  931. !! ** Method : Call observation diagnostic output routines
  932. !!
  933. !! ** Action :
  934. !!
  935. !! History :
  936. !! ! 06-03 (K. Mogensen) Original code
  937. !! ! 06-05 (K. Mogensen) Reformatted
  938. !! ! 06-10 (A. Weaver) Cleaning
  939. !! ! 07-03 (K. Mogensen) General handling of profiles
  940. !! ! 08-09 (M. Valdivieso) Velocity component (U,V) profiles
  941. !!----------------------------------------------------------------------
  942. IMPLICIT NONE
  943. !! * Local declarations
  944. INTEGER :: jprofset ! Profile data set loop variable
  945. INTEGER :: jveloset ! Velocity data set loop variable
  946. INTEGER :: jslaset ! SLA data set loop variable
  947. INTEGER :: jsstset ! SST data set loop variable
  948. INTEGER :: jseaiceset ! Sea Ice data set loop variable
  949. INTEGER :: jset
  950. INTEGER :: jfbini
  951. CHARACTER(LEN=20) :: datestr=" ",timestr=" "
  952. CHARACTER(LEN=10) :: cdtmp
  953. !-----------------------------------------------------------------------
  954. ! Depending on switches call various observation output routines
  955. !-----------------------------------------------------------------------
  956. ! - Temperature/salinity profiles
  957. IF( ln_t3d .OR. ln_s3d ) THEN
  958. ! Copy data from prodatqc to profdata structures
  959. DO jprofset = 1, nprofsets
  960. CALL obs_prof_decompress( prodatqc(jprofset), &
  961. & profdata(jprofset), .TRUE., numout )
  962. END DO
  963. ! Write the profiles.
  964. jprofset = 0
  965. ! ENACT insitu data
  966. IF ( ln_ena ) THEN
  967. jprofset = jprofset + 1
  968. CALL obs_wri_p3d( 'enact', profdata(jprofset) )
  969. ENDIF
  970. ! Coriolis insitu data
  971. IF ( ln_cor ) THEN
  972. jprofset = jprofset + 1
  973. CALL obs_wri_p3d( 'corio', profdata(jprofset) )
  974. ENDIF
  975. ! Feedback insitu data
  976. IF ( ln_profb ) THEN
  977. jfbini = jprofset + 1
  978. DO jprofset = jfbini, nprofsets
  979. jset = jprofset - jfbini + 1
  980. WRITE(cdtmp,'(A,I2.2)')'profb_',jset
  981. CALL obs_wri_p3d( cdtmp, profdata(jprofset) )
  982. END DO
  983. ENDIF
  984. ENDIF
  985. ! - Sea surface anomaly
  986. IF ( ln_sla ) THEN
  987. ! Copy data from sladatqc to sladata structures
  988. DO jslaset = 1, nslasets
  989. CALL obs_surf_decompress( sladatqc(jslaset), &
  990. & sladata(jslaset), .TRUE., numout )
  991. END DO
  992. jslaset = 0
  993. ! Write the AVISO SLA data
  994. IF ( ln_sladt ) THEN
  995. jslaset = 1
  996. CALL obs_wri_sla( 'aviso_act', sladata(jslaset) )
  997. jslaset = 2
  998. CALL obs_wri_sla( 'aviso_pas', sladata(jslaset) )
  999. ENDIF
  1000. IF ( ln_slafb ) THEN
  1001. jfbini = jslaset + 1
  1002. DO jslaset = jfbini, nslasets
  1003. jset = jslaset - jfbini + 1
  1004. WRITE(cdtmp,'(A,I2.2)')'slafb_',jset
  1005. CALL obs_wri_sla( cdtmp, sladata(jslaset) )
  1006. END DO
  1007. ENDIF
  1008. ENDIF
  1009. ! - Sea surface temperature
  1010. IF ( ln_sst ) THEN
  1011. ! Copy data from sstdatqc to sstdata structures
  1012. DO jsstset = 1, nsstsets
  1013. CALL obs_surf_decompress( sstdatqc(jsstset), &
  1014. & sstdata(jsstset), .TRUE., numout )
  1015. END DO
  1016. jsstset = 0
  1017. ! Write the AVISO SST data
  1018. IF ( ln_reysst ) THEN
  1019. jsstset = jsstset + 1
  1020. CALL obs_wri_sst( 'reynolds', sstdata(jsstset) )
  1021. ENDIF
  1022. IF ( ln_ghrsst ) THEN
  1023. jsstset = jsstset + 1
  1024. CALL obs_wri_sst( 'ghr', sstdata(jsstset) )
  1025. ENDIF
  1026. IF ( ln_sstfb ) THEN
  1027. jfbini = jsstset + 1
  1028. DO jsstset = jfbini, nsstsets
  1029. jset = jsstset - jfbini + 1
  1030. WRITE(cdtmp,'(A,I2.2)')'sstfb_',jset
  1031. CALL obs_wri_sst( cdtmp, sstdata(jsstset) )
  1032. END DO
  1033. ENDIF
  1034. ENDIF
  1035. ! - Sea surface salinity
  1036. IF ( ln_sss ) THEN
  1037. IF(lwp) WRITE(numout,*) ' SSS currently not available'
  1038. ENDIF
  1039. ! - Sea Ice Concentration
  1040. IF ( ln_seaice ) THEN
  1041. ! Copy data from seaicedatqc to seaicedata structures
  1042. DO jseaiceset = 1, nseaicesets
  1043. CALL obs_surf_decompress( seaicedatqc(jseaiceset), &
  1044. & seaicedata(jseaiceset), .TRUE., numout )
  1045. END DO
  1046. ! Write the Sea Ice data
  1047. DO jseaiceset = 1, nseaicesets
  1048. WRITE(cdtmp,'(A,I2.2)')'seaicefb_',jseaiceset
  1049. CALL obs_wri_seaice( cdtmp, seaicedata(jseaiceset) )
  1050. END DO
  1051. ENDIF
  1052. ! Velocity data
  1053. IF( ln_vel3d ) THEN
  1054. ! Copy data from veldatqc to velodata structures
  1055. DO jveloset = 1, nvelosets
  1056. CALL obs_prof_decompress( veldatqc(jveloset), &
  1057. & velodata(jveloset), .TRUE., numout )
  1058. END DO
  1059. ! Write the profiles.
  1060. jveloset = 0
  1061. ! Daily averaged data
  1062. IF ( ln_velavcur ) THEN
  1063. jveloset = jveloset + 1
  1064. CALL obs_wri_vel( 'velavcurr', velodata(jveloset), n2dint )
  1065. ENDIF
  1066. ! High frequency data
  1067. IF ( ln_velhrcur ) THEN
  1068. jveloset = jveloset + 1
  1069. CALL obs_wri_vel( 'velhrcurr', velodata(jveloset), n2dint )
  1070. ENDIF
  1071. ! Daily averaged data
  1072. IF ( ln_velavadcp ) THEN
  1073. jveloset = jveloset + 1
  1074. CALL obs_wri_vel( 'velavadcp', velodata(jveloset), n2dint )
  1075. ENDIF
  1076. ! High frequency data
  1077. IF ( ln_velhradcp ) THEN
  1078. jveloset = jveloset + 1
  1079. CALL obs_wri_vel( 'velhradcp', velodata(jveloset), n2dint )
  1080. ENDIF
  1081. ! Feedback velocity data
  1082. IF ( ln_velfb ) THEN
  1083. jfbini = jveloset + 1
  1084. DO jveloset = jfbini, nvelosets
  1085. jset = jveloset - jfbini + 1
  1086. WRITE(cdtmp,'(A,I2.2)')'velfb_',jset
  1087. CALL obs_wri_vel( cdtmp, velodata(jveloset), n2dint )
  1088. END DO
  1089. ENDIF
  1090. ENDIF
  1091. END SUBROUTINE dia_obs_wri
  1092. SUBROUTINE dia_obs_dealloc
  1093. IMPLICIT NONE
  1094. !!----------------------------------------------------------------------
  1095. !! *** ROUTINE dia_obs_dealloc ***
  1096. !!
  1097. !! ** Purpose : To deallocate data to enable the obs_oper online loop.
  1098. !! Specifically: dia_obs_init --> dia_obs --> dia_obs_wri
  1099. !!
  1100. !! ** Method : Clean up various arrays left behind by the obs_oper.
  1101. !!
  1102. !! ** Action :
  1103. !!
  1104. !!----------------------------------------------------------------------
  1105. !! obs_grid deallocation
  1106. CALL obs_grid_deallocate
  1107. !! diaobs deallocation
  1108. IF ( nprofsets > 0 ) THEN
  1109. DEALLOCATE(ld_enact, &
  1110. & profdata, &
  1111. & prodatqc)
  1112. END IF
  1113. IF ( ln_sla ) THEN
  1114. DEALLOCATE(sladata, &
  1115. & sladatqc)
  1116. END IF
  1117. IF ( ln_seaice ) THEN
  1118. DEALLOCATE(sladata, &
  1119. & sladatqc)
  1120. END IF
  1121. IF ( ln_sst ) THEN
  1122. DEALLOCATE(sstdata, &
  1123. & sstdatqc)
  1124. END IF
  1125. IF ( ln_vel3d ) THEN
  1126. DEALLOCATE(ld_velav, &
  1127. & velodata, &
  1128. & veldatqc)
  1129. END IF
  1130. END SUBROUTINE dia_obs_dealloc
  1131. SUBROUTINE ini_date( ddobsini )
  1132. !!----------------------------------------------------------------------
  1133. !! *** ROUTINE ini_date ***
  1134. !!
  1135. !! ** Purpose : Get initial data in double precision YYYYMMDD.HHMMSS format
  1136. !!
  1137. !! ** Method : Get initial data in double precision YYYYMMDD.HHMMSS format
  1138. !!
  1139. !! ** Action : Get initial data in double precision YYYYMMDD.HHMMSS format
  1140. !!
  1141. !! History :
  1142. !! ! 06-03 (K. Mogensen) Original code
  1143. !! ! 06-05 (K. Mogensen) Reformatted
  1144. !! ! 06-10 (A. Weaver) Cleaning
  1145. !! ! 06-10 (G. Smith) Calculates initial date the same as method for final date
  1146. !! ! 10-05 (D. Lea) Update to month length calculation for NEMO vn3.2
  1147. !!----------------------------------------------------------------------
  1148. USE phycst, ONLY : & ! Physical constants
  1149. & rday
  1150. ! USE daymod, ONLY : & ! Time variables
  1151. ! & nmonth_len
  1152. USE dom_oce, ONLY : & ! Ocean space and time domain variables
  1153. & rdt
  1154. IMPLICIT NONE
  1155. !! * Arguments
  1156. REAL(KIND=dp), INTENT(OUT) :: ddobsini ! Initial date in YYYYMMDD.HHMMSS
  1157. !! * Local declarations
  1158. INTEGER :: iyea ! date - (year, month, day, hour, minute)
  1159. INTEGER :: imon
  1160. INTEGER :: iday
  1161. INTEGER :: ihou
  1162. INTEGER :: imin
  1163. INTEGER :: imday ! Number of days in month.
  1164. REAL(KIND=wp) :: zdayfrc ! Fraction of day
  1165. INTEGER, DIMENSION(12) :: imonth_len !: length in days of the months of the current year
  1166. !!----------------------------------------------------------------------
  1167. !! Initial date initialization (year, month, day, hour, minute)
  1168. !! (This assumes that the initial date is for 00z))
  1169. !!----------------------------------------------------------------------
  1170. iyea = ndate0 / 10000
  1171. imon = ( ndate0 - iyea * 10000 ) / 100
  1172. iday = ndate0 - iyea * 10000 - imon * 100
  1173. ihou = 0
  1174. imin = 0
  1175. !!----------------------------------------------------------------------
  1176. !! Compute number of days + number of hours + min since initial time
  1177. !!----------------------------------------------------------------------
  1178. iday = iday + ( nit000 -1 ) * rdt / rday
  1179. zdayfrc = ( nit000 -1 ) * rdt / rday
  1180. zdayfrc = zdayfrc - aint(zdayfrc)
  1181. ihou = int( zdayfrc * 24 )
  1182. imin = int( (zdayfrc * 24 - ihou) * 60 )
  1183. !!-----------------------------------------------------------------------
  1184. !! Convert number of days (iday) into a real date
  1185. !!----------------------------------------------------------------------
  1186. CALL calc_month_len( iyea, imonth_len )
  1187. DO WHILE ( iday > imonth_len(imon) )
  1188. iday = iday - imonth_len(imon)
  1189. imon = imon + 1
  1190. IF ( imon > 12 ) THEN
  1191. imon = 1
  1192. iyea = iyea + 1
  1193. CALL calc_month_len( iyea, imonth_len ) ! update month lengths
  1194. ENDIF
  1195. END DO
  1196. !!----------------------------------------------------------------------
  1197. !! Convert it into YYYYMMDD.HHMMSS format.
  1198. !!----------------------------------------------------------------------
  1199. ddobsini = iyea * 10000_dp + imon * 100_dp + &
  1200. & iday + ihou * 0.01_dp + imin * 0.0001_dp
  1201. END SUBROUTINE ini_date
  1202. SUBROUTINE fin_date( ddobsfin )
  1203. !!----------------------------------------------------------------------
  1204. !! *** ROUTINE fin_date ***
  1205. !!
  1206. !! ** Purpose : Get final data in double precision YYYYMMDD.HHMMSS format
  1207. !!
  1208. !! ** Method : Get final data in double precision YYYYMMDD.HHMMSS format
  1209. !!
  1210. !! ** Action : Get final data in double precision YYYYMMDD.HHMMSS format
  1211. !!
  1212. !! History :
  1213. !! ! 06-03 (K. Mogensen) Original code
  1214. !! ! 06-05 (K. Mogensen) Reformatted
  1215. !! ! 06-10 (A. Weaver) Cleaning
  1216. !! ! 10-05 (D. Lea) Update to month length calculation for NEMO vn3.2
  1217. !!----------------------------------------------------------------------
  1218. USE phycst, ONLY : & ! Physical constants
  1219. & rday
  1220. ! USE daymod, ONLY : & ! Time variables
  1221. ! & nmonth_len
  1222. USE dom_oce, ONLY : & ! Ocean space and time domain variables
  1223. & rdt
  1224. IMPLICIT NONE
  1225. !! * Arguments
  1226. REAL(KIND=dp), INTENT(OUT) :: ddobsfin ! Final date in YYYYMMDD.HHMMSS
  1227. !! * Local declarations
  1228. INTEGER :: iyea ! date - (year, month, day, hour, minute)
  1229. INTEGER :: imon
  1230. INTEGER :: iday
  1231. INTEGER :: ihou
  1232. INTEGER :: imin
  1233. INTEGER :: imday ! Number of days in month.
  1234. REAL(KIND=wp) :: zdayfrc ! Fraction of day
  1235. INTEGER, DIMENSION(12) :: imonth_len !: length in days of the months of the current year
  1236. !-----------------------------------------------------------------------
  1237. ! Initial date initialization (year, month, day, hour, minute)
  1238. ! (This assumes that the initial date is for 00z)
  1239. !-----------------------------------------------------------------------
  1240. iyea = ndate0 / 10000
  1241. imon = ( ndate0 - iyea * 10000 ) / 100
  1242. iday = ndate0 - iyea * 10000 - imon * 100
  1243. ihou = 0
  1244. imin = 0
  1245. !-----------------------------------------------------------------------
  1246. ! Compute number of days + number of hours + min since initial time
  1247. !-----------------------------------------------------------------------
  1248. iday = iday + nitend * rdt / rday
  1249. zdayfrc = nitend * rdt / rday
  1250. zdayfrc = zdayfrc - AINT( zdayfrc )
  1251. ihou = INT( zdayfrc * 24 )
  1252. imin = INT( ( zdayfrc * 24 - ihou ) * 60 )
  1253. !-----------------------------------------------------------------------
  1254. ! Convert number of days (iday) into a real date
  1255. !----------------------------------------------------------------------
  1256. CALL calc_month_len( iyea, imonth_len )
  1257. DO WHILE ( iday > imonth_len(imon) )
  1258. iday = iday - imonth_len(imon)
  1259. imon = imon + 1
  1260. IF ( imon > 12 ) THEN
  1261. imon = 1
  1262. iyea = iyea + 1
  1263. CALL calc_month_len( iyea, imonth_len ) ! update month lengths
  1264. ENDIF
  1265. END DO
  1266. !-----------------------------------------------------------------------
  1267. ! Convert it into YYYYMMDD.HHMMSS format
  1268. !-----------------------------------------------------------------------
  1269. ddobsfin = iyea * 10000_dp + imon * 100_dp + iday &
  1270. & + ihou * 0.01_dp + imin * 0.0001_dp
  1271. END SUBROUTINE fin_date
  1272. END MODULE diaobs