diawri.F90 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. MODULE diawri
  2. !!======================================================================
  3. !! *** MODULE diawri ***
  4. !! Ocean diagnostics : write ocean output files
  5. !!=====================================================================
  6. !! History : OPA ! 1991-03 (M.-A. Foujols) Original code
  7. !! 4.0 ! 1991-11 (G. Madec)
  8. !! ! 1992-06 (M. Imbard) correction restart file
  9. !! ! 1992-07 (M. Imbard) split into diawri and rstwri
  10. !! ! 1993-03 (M. Imbard) suppress writibm
  11. !! ! 1998-01 (C. Levy) NETCDF format using ioipsl INTERFACE
  12. !! ! 1999-02 (E. Guilyardi) name of netCDF files + variables
  13. !! 8.2 ! 2000-06 (M. Imbard) Original code (diabort.F)
  14. !! NEMO 1.0 ! 2002-06 (A.Bozec, E. Durand) Original code (diainit.F)
  15. !! - ! 2002-09 (G. Madec) F90: Free form and module
  16. !! - ! 2002-12 (G. Madec) merge of diabort and diainit, F90
  17. !! ! 2005-11 (V. Garnier) Surface pressure gradient organization
  18. !! 3.2 ! 2008-11 (B. Lemaire) creation from old diawri
  19. !!----------------------------------------------------------------------
  20. !!----------------------------------------------------------------------
  21. !! dia_wri : create the standart output files
  22. !! dia_wri_state : create an output NetCDF file for a single instantaeous ocean state and forcing fields
  23. !!----------------------------------------------------------------------
  24. USE oce ! ocean dynamics and tracers
  25. USE dom_oce ! ocean space and time domain
  26. USE zdf_oce ! ocean vertical physics
  27. USE ldftra_oce ! ocean active tracers: lateral physics
  28. USE ldfdyn_oce ! ocean dynamics: lateral physics
  29. USE traldf_iso_grif, ONLY : psix_eiv, psiy_eiv
  30. USE sol_oce ! solver variables
  31. USE sbc_oce ! Surface boundary condition: ocean fields
  32. USE sbc_ice ! Surface boundary condition: ice fields
  33. USE sbcssr ! restoring term toward SST/SSS climatology
  34. USE phycst ! physical constants
  35. USE zdfmxl ! mixed layer
  36. USE dianam ! build name of file (routine)
  37. USE zdfddm ! vertical physics: double diffusion
  38. USE diahth ! thermocline diagnostics
  39. USE lbclnk ! ocean lateral boundary conditions (or mpp link)
  40. USE in_out_manager ! I/O manager
  41. USE diadimg ! dimg direct access file format output
  42. USE diaar5, ONLY : lk_diaar5
  43. USE iom
  44. USE ioipsl
  45. #if defined key_lim2
  46. USE limwri_2
  47. #endif
  48. USE lib_mpp ! MPP library
  49. USE timing ! preformance summary
  50. USE wrk_nemo ! working array
  51. IMPLICIT NONE
  52. PRIVATE
  53. PUBLIC dia_wri ! routines called by step.F90
  54. PUBLIC dia_wri_state
  55. PUBLIC dia_wri_alloc ! Called by nemogcm module
  56. INTEGER :: nid_T, nz_T, nh_T, ndim_T, ndim_hT ! grid_T file
  57. INTEGER :: nid_U, nz_U, nh_U, ndim_U, ndim_hU ! grid_U file
  58. INTEGER :: nid_V, nz_V, nh_V, ndim_V, ndim_hV ! grid_V file
  59. INTEGER :: ndex(1) ! ???
  60. INTEGER, SAVE, ALLOCATABLE, DIMENSION(:) :: ndex_hT, ndex_hU, ndex_hV
  61. !! * Substitutions
  62. # include "zdfddm_substitute.h90"
  63. # include "domzgr_substitute.h90"
  64. # include "vectopt_loop_substitute.h90"
  65. !!----------------------------------------------------------------------
  66. !! NEMO/OPA 3.3 , NEMO Consortium (2010)
  67. !! $Id: diawri.F90 2355 2015-05-20 07:11:50Z ufla $
  68. !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
  69. !!----------------------------------------------------------------------
  70. CONTAINS
  71. INTEGER FUNCTION dia_wri_alloc()
  72. !!----------------------------------------------------------------------
  73. INTEGER :: ierr
  74. !!----------------------------------------------------------------------
  75. !
  76. ALLOCATE( ndex_hT(jpi*jpj), ndex_hU(jpi*jpj), ndex_hV(jpi*jpj), STAT=dia_wri_alloc )
  77. IF( lk_mpp ) CALL mpp_sum( dia_wri_alloc )
  78. !
  79. END FUNCTION dia_wri_alloc
  80. #if defined key_dimgout
  81. !!----------------------------------------------------------------------
  82. !! 'key_dimgout' DIMG output file
  83. !!----------------------------------------------------------------------
  84. # include "diawri_dimg.h90"
  85. #else
  86. !!----------------------------------------------------------------------
  87. !! Default option NetCDF output file
  88. !!----------------------------------------------------------------------
  89. # if defined key_iomput
  90. !!----------------------------------------------------------------------
  91. !! 'key_iomput' use IOM library
  92. !!----------------------------------------------------------------------
  93. SUBROUTINE dia_wri( kt )
  94. !!---------------------------------------------------------------------
  95. !! *** ROUTINE dia_wri ***
  96. !!
  97. !! ** Purpose : Standard output of opa: dynamics and tracer fields
  98. !! NETCDF format is used by default
  99. !! Standalone surface scheme
  100. !!
  101. !! ** Method : use iom_put
  102. !!----------------------------------------------------------------------
  103. !!
  104. INTEGER, INTENT( in ) :: kt ! ocean time-step index
  105. !!----------------------------------------------------------------------
  106. !
  107. !! no relevant 2D arrays to write in iomput case
  108. !
  109. END SUBROUTINE dia_wri
  110. #else
  111. !!----------------------------------------------------------------------
  112. !! Default option use IOIPSL library
  113. !!----------------------------------------------------------------------
  114. SUBROUTINE dia_wri( kt )
  115. !!---------------------------------------------------------------------
  116. !! *** ROUTINE dia_wri ***
  117. !!
  118. !! ** Purpose : Standard output of opa: dynamics and tracer fields
  119. !! NETCDF format is used by default
  120. !!
  121. !! ** Method : At the beginning of the first time step (nit000),
  122. !! define all the NETCDF files and fields
  123. !! At each time step call histdef to compute the mean if ncessary
  124. !! Each nwrite time step, output the instantaneous or mean fields
  125. !!----------------------------------------------------------------------
  126. !!
  127. INTEGER, INTENT( in ) :: kt ! ocean time-step index
  128. !!
  129. LOGICAL :: ll_print = .FALSE. ! =T print and flush numout
  130. CHARACTER (len=40) :: clhstnam, clop, clmx ! local names
  131. INTEGER :: inum = 11 ! temporary logical unit
  132. INTEGER :: ji, jj, jk ! dummy loop indices
  133. INTEGER :: ierr ! error code return from allocation
  134. INTEGER :: iimi, iima, ipk, it, itmod, ijmi, ijma ! local integers
  135. REAL(wp) :: zsto, zout, zmax, zjulian, zdt ! local scalars
  136. !!----------------------------------------------------------------------
  137. !
  138. IF( nn_timing == 1 ) CALL timing_start('dia_wri')
  139. !
  140. ! Output the initial state and forcings
  141. IF( ninist == 1 ) THEN
  142. CALL dia_wri_state( 'output.init', kt )
  143. ninist = 0
  144. ENDIF
  145. !
  146. ! 0. Initialisation
  147. ! -----------------
  148. ! local variable for debugging
  149. ll_print = .FALSE.
  150. ll_print = ll_print .AND. lwp
  151. ! Define frequency of output and means
  152. zdt = rdt
  153. IF( nacc == 1 ) zdt = rdtmin
  154. IF( ln_mskland ) THEN ; clop = "only(x)" ! put 1.e+20 on land (very expensive!!)
  155. ELSE ; clop = "x" ! no use of the mask value (require less cpu time)
  156. ENDIF
  157. #if defined key_diainstant
  158. zsto = nwrite * zdt
  159. clop = "inst("//TRIM(clop)//")"
  160. #else
  161. zsto=zdt
  162. clop = "ave("//TRIM(clop)//")"
  163. #endif
  164. zout = nwrite * zdt
  165. zmax = ( nitend - nit000 + 1 ) * zdt
  166. ! Define indices of the horizontal output zoom and vertical limit storage
  167. iimi = 1 ; iima = jpi
  168. ijmi = 1 ; ijma = jpj
  169. ipk = jpk
  170. ! define time axis
  171. it = kt
  172. itmod = kt - nit000 + 1
  173. ! 1. Define NETCDF files and fields at beginning of first time step
  174. ! -----------------------------------------------------------------
  175. IF( kt == nit000 ) THEN
  176. ! Define the NETCDF files (one per grid)
  177. ! Compute julian date from starting date of the run
  178. CALL ymds2ju( nyear, nmonth, nday, rdt, zjulian )
  179. zjulian = zjulian - adatrj ! set calendar origin to the beginning of the experiment
  180. IF(lwp)WRITE(numout,*)
  181. IF(lwp)WRITE(numout,*) 'Date 0 used :', nit000, ' YEAR ', nyear, &
  182. & ' MONTH ', nmonth, ' DAY ', nday, 'Julian day : ', zjulian
  183. IF(lwp)WRITE(numout,*) ' indexes of zoom = ', iimi, iima, ijmi, ijma, &
  184. ' limit storage in depth = ', ipk
  185. ! WRITE root name in date.file for use by postpro
  186. IF(lwp) THEN
  187. CALL dia_nam( clhstnam, nwrite,' ' )
  188. CALL ctl_opn( inum, 'date.file', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea )
  189. WRITE(inum,*) clhstnam
  190. CLOSE(inum)
  191. ENDIF
  192. ! Define the T grid FILE ( nid_T )
  193. CALL dia_nam( clhstnam, nwrite, 'grid_T' )
  194. IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam ! filename
  195. CALL histbeg( clhstnam, jpi, glamt, jpj, gphit, & ! Horizontal grid: glamt and gphit
  196. & iimi, iima-iimi+1, ijmi, ijma-ijmi+1, &
  197. & nit000-1, zjulian, zdt, nh_T, nid_T, domain_id=nidom, snc4chunks=snc4set )
  198. CALL histvert( nid_T, "deptht", "Vertical T levels", & ! Vertical grid: gdept
  199. & "m", ipk, gdept_1d, nz_T, "down" )
  200. ! ! Index of ocean points
  201. CALL wheneq( jpi*jpj , tmask, 1, 1., ndex_hT, ndim_hT ) ! surface
  202. ! Define the U grid FILE ( nid_U )
  203. CALL dia_nam( clhstnam, nwrite, 'grid_U' )
  204. IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam ! filename
  205. CALL histbeg( clhstnam, jpi, glamu, jpj, gphiu, & ! Horizontal grid: glamu and gphiu
  206. & iimi, iima-iimi+1, ijmi, ijma-ijmi+1, &
  207. & nit000-1, zjulian, zdt, nh_U, nid_U, domain_id=nidom, snc4chunks=snc4set )
  208. CALL histvert( nid_U, "depthu", "Vertical U levels", & ! Vertical grid: gdept
  209. & "m", ipk, gdept_1d, nz_U, "down" )
  210. ! ! Index of ocean points
  211. CALL wheneq( jpi*jpj , umask, 1, 1., ndex_hU, ndim_hU ) ! surface
  212. ! Define the V grid FILE ( nid_V )
  213. CALL dia_nam( clhstnam, nwrite, 'grid_V' ) ! filename
  214. IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam
  215. CALL histbeg( clhstnam, jpi, glamv, jpj, gphiv, & ! Horizontal grid: glamv and gphiv
  216. & iimi, iima-iimi+1, ijmi, ijma-ijmi+1, &
  217. & nit000-1, zjulian, zdt, nh_V, nid_V, domain_id=nidom, snc4chunks=snc4set )
  218. CALL histvert( nid_V, "depthv", "Vertical V levels", & ! Vertical grid : gdept
  219. & "m", ipk, gdept_1d, nz_V, "down" )
  220. ! ! Index of ocean points
  221. CALL wheneq( jpi*jpj , vmask, 1, 1., ndex_hV, ndim_hV ) ! surface
  222. ! No W grid FILE
  223. ! Declare all the output fields as NETCDF variables
  224. ! !!! nid_T : 3D
  225. CALL histdef( nid_T, "sst_m", "Sea Surface temperature" , "C" , & ! sst
  226. & jpi, jpj, nh_T, 1 , 1, 1 , -99 , 32, clop, zsto, zout )
  227. CALL histdef( nid_T, "sss_m", "Sea Surface Salinity" , "PSU" , & ! sss
  228. & jpi, jpj, nh_T, 1 , 1, 1 , -99 , 32, clop, zsto, zout )
  229. CALL histdef( nid_T, "sowaflup", "Net Upward Water Flux" , "Kg/m2/s", & ! (emp-rnf)
  230. & jpi, jpj, nh_T, 1 , 1, 1 , -99 , 32, clop, zsto, zout )
  231. CALL histdef( nid_T, "sosfldow", "downward salt flux" , "PSU/m2/s", & ! (sfx)
  232. & jpi, jpj, nh_T, 1 , 1, 1 , -99 , 32, clop, zsto, zout )
  233. CALL histdef( nid_T, "sohefldo", "Net Downward Heat Flux" , "W/m2" , & ! qns + qsr
  234. & jpi, jpj, nh_T, 1 , 1, 1 , -99 , 32, clop, zsto, zout )
  235. CALL histdef( nid_T, "soshfldo", "Shortwave Radiation" , "W/m2" , & ! qsr
  236. & jpi, jpj, nh_T, 1 , 1, 1 , -99 , 32, clop, zsto, zout )
  237. CALL histdef( nid_T, "soicecov", "Ice fraction" , "[0,1]" , & ! fr_i
  238. & jpi, jpj, nh_T, 1 , 1, 1 , -99 , 32, clop, zsto, zout )
  239. CALL histdef( nid_T, "sowindsp", "wind speed at 10m" , "m/s" , & ! wndm
  240. & jpi, jpj, nh_T, 1 , 1, 1 , -99 , 32, clop, zsto, zout )
  241. CALL histend( nid_T, snc4chunks=snc4set )
  242. ! !!! nid_U : 3D
  243. CALL histdef( nid_U, "ssu_m", "Velocity component in x-direction", "m/s" , & ! ssu
  244. & jpi, jpj, nh_U, 1 , 1, 1 , - 99, 32, clop, zsto, zout )
  245. CALL histdef( nid_U, "sozotaux", "Wind Stress along i-axis" , "N/m2" , & ! utau
  246. & jpi, jpj, nh_U, 1 , 1, 1 , - 99, 32, clop, zsto, zout )
  247. CALL histend( nid_U, snc4chunks=snc4set )
  248. ! !!! nid_V : 3D
  249. CALL histdef( nid_V, "ssv_m", "Velocity component in y-direction", "m/s", & ! ssv_m
  250. & jpi, jpj, nh_V, 1 , 1, 1 , - 99, 32, clop, zsto, zout )
  251. CALL histdef( nid_V, "sometauy", "Wind Stress along j-axis" , "N/m2" , & ! vtau
  252. & jpi, jpj, nh_V, 1 , 1, 1 , - 99, 32, clop, zsto, zout )
  253. CALL histend( nid_V, snc4chunks=snc4set )
  254. IF(lwp) WRITE(numout,*)
  255. IF(lwp) WRITE(numout,*) 'End of NetCDF Initialization'
  256. IF(ll_print) CALL FLUSH(numout )
  257. ENDIF
  258. ! 2. Start writing data
  259. ! ---------------------
  260. ! ndex(1) est utilise ssi l'avant dernier argument est diffferent de
  261. ! la taille du tableau en sortie. Dans ce cas , l'avant dernier argument
  262. ! donne le nombre d'elements, et ndex la liste des indices a sortir
  263. IF( lwp .AND. MOD( itmod, nwrite ) == 0 ) THEN
  264. WRITE(numout,*) 'dia_wri : write model outputs in NetCDF files at ', kt, 'time-step'
  265. WRITE(numout,*) '~~~~~~ '
  266. ENDIF
  267. ! Write fields on T grid
  268. CALL histwrite( nid_T, "sst_m", it, sst_m, ndim_hT, ndex_hT ) ! sea surface temperature
  269. CALL histwrite( nid_T, "sss_m", it, sss_m, ndim_hT, ndex_hT ) ! sea surface salinity
  270. CALL histwrite( nid_T, "sowaflup", it, (emp - rnf ) , ndim_hT, ndex_hT ) ! upward water flux
  271. CALL histwrite( nid_T, "sosfldow", it, sfx , ndim_hT, ndex_hT ) ! downward salt flux
  272. ! (includes virtual salt flux beneath ice
  273. ! in linear free surface case)
  274. CALL histwrite( nid_T, "sohefldo", it, qns + qsr , ndim_hT, ndex_hT ) ! total heat flux
  275. CALL histwrite( nid_T, "soshfldo", it, qsr , ndim_hT, ndex_hT ) ! solar heat flux
  276. CALL histwrite( nid_T, "soicecov", it, fr_i , ndim_hT, ndex_hT ) ! ice fraction
  277. CALL histwrite( nid_T, "sowindsp", it, wndm , ndim_hT, ndex_hT ) ! wind speed
  278. ! Write fields on U grid
  279. CALL histwrite( nid_U, "ssu_m" , it, ssu_m , ndim_hU, ndex_hU ) ! i-current speed
  280. CALL histwrite( nid_U, "sozotaux", it, utau , ndim_hU, ndex_hU ) ! i-wind stress
  281. ! Write fields on V grid
  282. CALL histwrite( nid_V, "ssv_m" , it, ssv_m , ndim_hV, ndex_hV ) ! j-current speed
  283. CALL histwrite( nid_V, "sometauy", it, vtau , ndim_hV, ndex_hV ) ! j-wind stress
  284. ! 3. Close all files
  285. ! ---------------------------------------
  286. IF( kt == nitend ) THEN
  287. CALL histclo( nid_T )
  288. CALL histclo( nid_U )
  289. CALL histclo( nid_V )
  290. ENDIF
  291. !
  292. IF( nn_timing == 1 ) CALL timing_stop('dia_wri')
  293. !
  294. END SUBROUTINE dia_wri
  295. # endif
  296. #endif
  297. SUBROUTINE dia_wri_state( cdfile_name, kt )
  298. !!---------------------------------------------------------------------
  299. !! *** ROUTINE dia_wri_state ***
  300. !!
  301. !! ** Purpose : create a NetCDF file named cdfile_name which contains
  302. !! the instantaneous ocean state and forcing fields.
  303. !! Used to find errors in the initial state or save the last
  304. !! ocean state in case of abnormal end of a simulation
  305. !!
  306. !! ** Method : NetCDF files using ioipsl
  307. !! File 'output.init.nc' is created if ninist = 1 (namelist)
  308. !! File 'output.abort.nc' is created in case of abnormal job end
  309. !!----------------------------------------------------------------------
  310. CHARACTER (len=* ), INTENT( in ) :: cdfile_name ! name of the file created
  311. INTEGER , INTENT( in ) :: kt ! ocean time-step index
  312. !!
  313. CHARACTER (len=32) :: clname
  314. CHARACTER (len=40) :: clop
  315. INTEGER :: id_i , nz_i, nh_i
  316. INTEGER, DIMENSION(1) :: idex ! local workspace
  317. REAL(wp) :: zsto, zout, zmax, zjulian, zdt
  318. !!----------------------------------------------------------------------
  319. !
  320. IF( nn_timing == 1 ) CALL timing_start('dia_wri_state')
  321. ! 0. Initialisation
  322. ! -----------------
  323. ! Define name, frequency of output and means
  324. clname = cdfile_name
  325. IF( .NOT. Agrif_Root() ) clname = TRIM(Agrif_CFixed())//'_'//TRIM(clname)
  326. zdt = rdt
  327. zsto = rdt
  328. clop = "inst(x)" ! no use of the mask value (require less cpu time)
  329. zout = rdt
  330. zmax = ( nitend - nit000 + 1 ) * zdt
  331. IF(lwp) WRITE(numout,*)
  332. IF(lwp) WRITE(numout,*) 'dia_wri_state : single instantaneous ocean state'
  333. IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~ and forcing fields file created '
  334. IF(lwp) WRITE(numout,*) ' and named :', clname, '.nc'
  335. ! 1. Define NETCDF files and fields at beginning of first time step
  336. ! -----------------------------------------------------------------
  337. ! Compute julian date from starting date of the run
  338. CALL ymds2ju( nyear, nmonth, nday, rdt, zjulian ) ! time axis
  339. zjulian = zjulian - adatrj ! set calendar origin to the beginning of the experiment
  340. CALL histbeg( clname, jpi, glamt, jpj, gphit, &
  341. 1, jpi, 1, jpj, nit000-1, zjulian, zdt, nh_i, id_i, domain_id=nidom, snc4chunks=snc4set ) ! Horizontal grid : glamt and gphit
  342. CALL histvert( id_i, "deptht", "Vertical T levels", & ! Vertical grid : gdept
  343. "m", jpk, gdept_1d, nz_i, "down")
  344. ! Declare all the output fields as NetCDF variables
  345. CALL histdef( id_i, "sowaflup", "Net Upward Water Flux" , "Kg/m2/S", & ! net freshwater
  346. & jpi, jpj, nh_i, 1 , 1, 1 , -99 , 32, clop, zsto, zout )
  347. CALL histdef( id_i, "sohefldo", "Net Downward Heat Flux", "W/m2" , & ! net heat flux
  348. & jpi, jpj, nh_i, 1 , 1, 1 , -99 , 32, clop, zsto, zout )
  349. CALL histdef( id_i, "soshfldo", "Shortwave Radiation" , "W/m2" , & ! solar flux
  350. & jpi, jpj, nh_i, 1 , 1, 1 , -99 , 32, clop, zsto, zout )
  351. CALL histdef( id_i, "soicecov", "Ice fraction" , "[0,1]" , & ! fr_i
  352. & jpi, jpj, nh_i, 1 , 1, 1 , -99 , 32, clop, zsto, zout )
  353. CALL histdef( id_i, "sozotaux", "Zonal Wind Stress" , "N/m2" , & ! i-wind stress
  354. & jpi, jpj, nh_i, 1 , 1, 1 , -99 , 32, clop, zsto, zout )
  355. CALL histdef( id_i, "sometauy", "Meridional Wind Stress", "N/m2" , & ! j-wind stress
  356. & jpi, jpj, nh_i, 1 , 1, 1 , -99 , 32, clop, zsto, zout )
  357. #if defined key_lim2
  358. CALL lim_wri_state_2( kt, id_i, nh_i )
  359. #else
  360. CALL histend( id_i, snc4chunks=snc4set )
  361. #endif
  362. ! 2. Start writing data
  363. ! ---------------------
  364. ! idex(1) est utilise ssi l'avant dernier argument est diffferent de
  365. ! la taille du tableau en sortie. Dans ce cas , l'avant dernier argument
  366. ! donne le nombre d'elements, et idex la liste des indices a sortir
  367. idex(1) = 1 ! init to avoid compil warning
  368. ! Write all fields on T grid
  369. CALL histwrite( id_i, "sowaflup", kt, emp , jpi*jpj , idex ) ! freshwater budget
  370. CALL histwrite( id_i, "sohefldo", kt, qsr + qns , jpi*jpj , idex ) ! total heat flux
  371. CALL histwrite( id_i, "soshfldo", kt, qsr , jpi*jpj , idex ) ! solar heat flux
  372. CALL histwrite( id_i, "soicecov", kt, fr_i , jpi*jpj , idex ) ! ice fraction
  373. CALL histwrite( id_i, "sozotaux", kt, utau , jpi*jpj , idex ) ! i-wind stress
  374. CALL histwrite( id_i, "sometauy", kt, vtau , jpi*jpj , idex ) ! j-wind stress
  375. ! 3. Close the file
  376. ! -----------------
  377. CALL histclo( id_i )
  378. #if ! defined key_iomput && ! defined key_dimgout
  379. IF( ninist /= 1 ) THEN
  380. CALL histclo( nid_T )
  381. CALL histclo( nid_U )
  382. CALL histclo( nid_V )
  383. ENDIF
  384. #endif
  385. IF( nn_timing == 1 ) CALL timing_stop('dia_wri_state')
  386. !
  387. END SUBROUTINE dia_wri_state
  388. !!======================================================================
  389. END MODULE diawri