New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
diawri.F90 in trunk/NEMO/OPA_SRC/DIA – NEMO

source: trunk/NEMO/OPA_SRC/DIA/diawri.F90 @ 719

Last change on this file since 719 was 719, checked in by ctlod, 17 years ago

get back to the nemo_v2_3 version for trunk

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 35.9 KB
Line 
1MODULE diawri
2   !!======================================================================
3   !!                     ***  MODULE  diawri  ***
4   !! Ocean diagnostics :  write ocean output files
5   !!=====================================================================
6
7   !!----------------------------------------------------------------------
8   !! * Modules used
9   USE oce             ! ocean dynamics and tracers
10   USE dom_oce         ! ocean space and time domain
11   USE zdf_oce         ! ocean vertical physics
12   USE ldftra_oce      ! ocean active tracers: lateral physics
13   USE ldfdyn_oce      ! ocean dynamics: lateral physics
14   USE sol_oce         ! solver variables
15   USE ice_oce         ! ice variables
16   USE phycst          ! physical constants
17   USE ocfzpt          ! ocean freezing point
18   USE ocesbc          ! surface thermohaline fluxes
19   USE taumod          ! surface stress
20   USE flxrnf          ! ocean runoffs
21   USE zdfmxl          ! mixed layer
22   USE daymod          ! calendar
23   USE dianam          ! build name of file (routine)
24   USE zdfddm          ! vertical  physics: double diffusion
25   USE diahth          ! thermocline diagnostics
26   USE diaspr          ! surface pressure diagnostics (rigid lid case)
27   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
28   USE in_out_manager  ! I/O manager
29   USE flx_oce         ! sea-ice/ocean forcings variables
30   USE diadimg         ! dimg direct access file format output
31   USE ioipsl
32
33   IMPLICIT NONE
34   PRIVATE
35
36   !! * Accessibility
37   PUBLIC dia_wri                 ! routines called by step.F90
38   PUBLIC dia_wri_state
39
40   !! * Module variables
41   INTEGER ::   &
42      nid_T, nz_T, nh_T, ndim_T, ndim_hT,      &   ! grid_T file
43      nid_U, nz_U, nh_U, ndim_U, ndim_hU,      &   ! grid_U file
44      nid_V, nz_V, nh_V, ndim_V, ndim_hV,      &   ! grid_V file
45      nid_W, nz_W, nh_W,                       &   ! grid_W file
46      ndex(1)                                      ! ???
47   INTEGER, DIMENSION(jpi*jpj) ::   &
48      ndex_hT, ndex_hU, ndex_hV
49   INTEGER, DIMENSION(jpi*jpj*jpk) ::   &
50      ndex_T, ndex_U, ndex_V
51
52   !! * Substitutions
53#  include "zdfddm_substitute.h90"
54   !!----------------------------------------------------------------------
55   !!   OPA 9.0 , LOCEAN-IPSL (2005)
56   !! $Header$
57   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
58   !!----------------------------------------------------------------------
59
60CONTAINS
61
62#if defined key_dimgout
63   !!----------------------------------------------------------------------
64   !!   dia_wri       : create the dimg direct access output file (mpp)
65   !!----------------------------------------------------------------------
66#   include "diawri_dimg.h90"
67
68#else
69   !!----------------------------------------------------------------------
70   !!   Default option                                   NetCDF output file
71   !!----------------------------------------------------------------------
72   !!   dia_wri       : create the standart NetCDF output files
73   !!   dia_wri_state : create an output NetCDF file for a single
74   !!                   instantaeous ocean state and forcing fields
75   !!----------------------------------------------------------------------
76
77   SUBROUTINE dia_wri( kt, kindic )
78      !!---------------------------------------------------------------------
79      !!                  ***  ROUTINE dia_wri  ***
80      !!                   
81      !! ** Purpose :   Standard output of opa: dynamics and tracer fields
82      !!      NETCDF format is used by default
83      !!
84      !! ** Method  :   At the beginning of the first time step (nit000),
85      !!      define all the NETCDF files and fields
86      !!      At each time step call histdef to compute the mean if ncessary
87      !!      Each nwrite time step, output the instantaneous or mean fields
88      !!      IF kindic <0, output of fields before the model interruption.
89      !!      IF kindic =0, time step loop
90      !!      IF kindic >0, output of fields before the time step loop
91      !!
92      !! History :
93      !!        !  91-03  (M.-A. Foujols)  Original code
94      !!        !  91-11  (G. Madec)
95      !!        !  92-06  (M. Imbard)  correction restart file
96      !!        !  92-07  (M. Imbard)  split into diawri and rstwri
97      !!        !  93-03  (M. Imbard)  suppress writibm
98      !!        !  98-01  (C. Levy)  NETCDF format using ioipsl INTERFACE
99      !!        !  99-02  (E. Guilyardi)  name of netCDF files + variables
100      !!   8.5  !  02-09  (G. Madec)  F90: Free form and module
101      !!   9.0  !  05-11  (V. Garnier) Surface pressure gradient organization
102      !!----------------------------------------------------------------------
103      !! * Arguments
104      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index
105      INTEGER, INTENT( in ) ::   kindic  !
106
107      !! * Local declarations
108      LOGICAL ::   ll_print = .FALSE.    ! =T print and flush numout
109      CHARACTER (len=40) ::           &
110         clhstnam, clop, clmx            ! temporary names
111      INTEGER ::   inum = 11             ! temporary logical unit
112      INTEGER ::   &
113         iimi, iima, ipk, it,         &  ! temporary integers
114         ijmi, ijma                      !    "          "
115      REAL(wp) ::   &
116         zsto, zout, zmax,            &  ! temporary scalars
117         zjulian, zdt                    !    "         "
118      REAL(wp), DIMENSION(jpi,jpj) :: &
119         zw2d                            ! temporary workspace
120      CHARACTER (len=80) :: clname
121      !!----------------------------------------------------------------------
122
123      ! 0. Initialisation
124      ! -----------------
125
126      ! local variable for debugging
127      ll_print = .FALSE.
128      ll_print = ll_print .AND. lwp
129
130      ! Define frequency of output and means
131      zdt = rdt
132      IF( nacc == 1 ) zdt = rdtmin
133#if defined key_diainstant
134      zsto = nwrite * zdt
135      clop = "inst(x)"           ! no use of the mask value (require less cpu time)
136      !!! clop="inst(only(x))"   ! put 1.e+20 on land (very expensive!!)
137#else
138      zsto=zdt
139      clop="ave(x)"              ! no use of the mask value (require less cpu time)
140      !!! clop="ave(only(x))"    ! put 1.e+20 on land (very expensive!!)
141#endif
142      zout = nwrite * zdt
143      zmax = ( nitend - nit000 + 1 ) * zdt
144
145      ! Define indices of the horizontal output zoom and vertical limit storage
146      iimi = 1      ;      iima = jpi
147      ijmi = 1      ;      ijma = jpj
148      ipk = jpk
149
150      ! define time axis
151      it = kt - nit000 + 1
152
153
154      ! 1. Define NETCDF files and fields at beginning of first time step
155      ! -----------------------------------------------------------------
156
157      IF(ll_print) WRITE(numout,*) 'dia_wri kt = ', kt, ' kindic ', kindic
158
159      IF( kt == nit000 ) THEN
160
161         ! Define the NETCDF files (one per grid)
162
163         ! Compute julian date from starting date of the run
164         CALL ymds2ju( nyear, nmonth, nday, 0.e0, zjulian )
165         IF(lwp)WRITE(numout,*)
166         IF(lwp)WRITE(numout,*) 'Date 0 used :', nit000, ' YEAR ', nyear,   &
167            &                    ' MONTH ', nmonth, ' DAY ', nday, 'Julian day : ', zjulian
168         IF(lwp)WRITE(numout,*) ' indexes of zoom = ', iimi, iima, ijmi, ijma,   &
169                                 ' limit storage in depth = ', ipk
170
171         ! WRITE root name in date.file for use by postpro
172         CALL dia_nam( clhstnam, nwrite,' ' )
173         clname = 'date.file'
174         CALL ctlopn( inum, clname,  'UNKNOWN', 'FORMATTED', 'SEQUENTIAL', 1, numout, lwp, 1 )
175         WRITE(inum,*) clhstnam
176         CLOSE(inum)
177
178         ! Define the T grid FILE ( nid_T )
179
180         CALL dia_nam( clhstnam, nwrite, 'grid_T' )
181         IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam    ! filename
182         CALL histbeg( clhstnam, jpi, glamt, jpj, gphit,           &  ! Horizontal grid: glamt and gphit
183            &          iimi, iima-iimi+1, ijmi, ijma-ijmi+1,       &
184            &          0, zjulian, zdt, nh_T, nid_T, domain_id=nidom )
185         CALL histvert( nid_T, "deptht", "Vertical T levels",      &  ! Vertical grid: gdept
186            &           "m", ipk, gdept_0, nz_T )
187         !                                                            ! Index of ocean points
188         CALL wheneq( jpi*jpj*ipk, tmask, 1, 1., ndex_T , ndim_T  )      ! volume
189         CALL wheneq( jpi*jpj    , tmask, 1, 1., ndex_hT, ndim_hT )      ! surface
190
191         ! Define the U grid FILE ( nid_U )
192
193         CALL dia_nam( clhstnam, nwrite, 'grid_U' )
194         IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam    ! filename
195         CALL histbeg( clhstnam, jpi, glamu, jpj, gphiu,           &  ! Horizontal grid: glamu and gphiu
196            &          iimi, iima-iimi+1, ijmi, ijma-ijmi+1,       &
197            &          0, zjulian, zdt, nh_U, nid_U, domain_id=nidom )
198         CALL histvert( nid_U, "depthu", "Vertical U levels",      &  ! Vertical grid: gdept
199            &           "m", ipk, gdept_0, nz_U )
200         !                                                            ! Index of ocean points
201         CALL wheneq( jpi*jpj*ipk, umask, 1, 1., ndex_U , ndim_U  )      ! volume
202         CALL wheneq( jpi*jpj    , umask, 1, 1., ndex_hU, ndim_hU )      ! surface
203
204         ! Define the V grid FILE ( nid_V )
205
206         CALL dia_nam( clhstnam, nwrite, 'grid_V' )                   ! filename
207         IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam
208         CALL histbeg( clhstnam, jpi, glamv, jpj, gphiv,           &  ! Horizontal grid: glamv and gphiv
209            &          iimi, iima-iimi+1, ijmi, ijma-ijmi+1,       &
210            &          0, zjulian, zdt, nh_V, nid_V, domain_id=nidom )
211         CALL histvert( nid_V, "depthv", "Vertical V levels",      &  ! Vertical grid : gdept
212            &          "m", ipk, gdept_0, nz_V )
213         !                                                            ! Index of ocean points
214         CALL wheneq( jpi*jpj*ipk, vmask, 1, 1., ndex_V , ndim_V  )      ! volume
215         CALL wheneq( jpi*jpj    , vmask, 1, 1., ndex_hV, ndim_hV )      ! surface
216
217         ! Define the W grid FILE ( nid_W )
218
219         CALL dia_nam( clhstnam, nwrite, 'grid_W' )                   ! filename
220         IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam
221         CALL histbeg( clhstnam, jpi, glamt, jpj, gphit,           &  ! Horizontal grid: glamt and gphit
222            &          iimi, iima-iimi+1, ijmi, ijma-ijmi+1,       &
223            &          0, zjulian, zdt, nh_W, nid_W, domain_id=nidom )
224         CALL histvert( nid_W, "depthw", "Vertical W levels",      &  ! Vertical grid: gdepw
225            &          "m", ipk, gdepw_0, nz_W )
226
227
228         ! Declare all the output fields as NETCDF variables
229
230         !                                                                                      !!! nid_T : 3D
231         CALL histdef( nid_T, "votemper", "Temperature"                        , "C"      ,   &  ! tn
232            &          jpi, jpj, nh_T, ipk, 1, ipk, nz_T, 32, clop, zsto, zout )
233         CALL histdef( nid_T, "vosaline", "Salinity"                           , "PSU"    ,   &  ! sn
234            &          jpi, jpj, nh_T, ipk, 1, ipk, nz_T, 32, clop, zsto, zout )
235         !                                                                                      !!! nid_T : 2D
236         CALL histdef( nid_T, "sosstsst", "Sea Surface temperature"            , "C"      ,   &  ! sst
237            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
238         CALL histdef( nid_T, "sosaline", "Sea Surface Salinity"               , "PSU"    ,   &  ! sss
239            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
240#if defined key_dynspg_rl
241         CALL histdef( nid_T, "sobarstf","Barotropic StreamFunction"           , "m3/s2"  ,   &  ! bsf
242            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
243#else
244         CALL histdef( nid_T, "sossheig", "Sea Surface Height"                 , "m"      ,   &  ! ssh
245            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
246#endif
247#if ! defined key_dynspg_rl && defined key_ice_lim
248         ! sowaflup = sowaflep + sorunoff + sowafldp + a term associated to
249         !    internal damping to Levitus that can be diagnosed from others
250         ! sowaflcd = sowaflep + sorunoff + sowafldp + iowaflup
251         CALL histdef( nid_T, "iowaflup", "Ice=>ocean net freshwater"          , "kg/m2/s",   &  ! fsalt
252            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
253         CALL histdef( nid_T, "sowaflep", "atmos=>ocean net freshwater"        , "kg/m2/s",   &  ! fmass
254            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
255#endif
256         CALL histdef( nid_T, "sowaflup", "Net Upward Water Flux"              , "Kg/m2/s",   &  ! emp
257            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
258         CALL histdef( nid_T, "sorunoff", "Runoffs"                            , "Kg/m2/s",   &  ! runoffs
259            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
260         CALL histdef( nid_T, "sowaflcd", "concentration/dilution water flux"  , "kg/m2/s",   &  ! emps
261            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
262         CALL histdef( nid_T, "sosalflx", "Surface Salt Flux"                  , "Kg/m2/s",   &  ! emps * sn
263            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
264         CALL histdef( nid_T, "sohefldo", "Net Downward Heat Flux"             , "W/m2"   ,   &  ! qt
265            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
266         CALL histdef( nid_T, "soshfldo", "Shortwave Radiation"                , "W/m2"   ,   &  ! qsr
267            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
268         CALL histdef( nid_T, "somxl010", "Mixed Layer Depth 0.01"             , "m"      ,   &  ! hmlp
269            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
270         CALL histdef( nid_T, "somixhgt", "Turbocline Depth"                   , "m"      ,   &  ! hmld
271            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
272         CALL histdef( nid_T, "soicecov", "Ice Cover"                          , "[0,1]"  ,   &  ! freeze
273            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
274#if ! defined key_coupled
275         CALL histdef( nid_T, "sohefldp", "Surface Heat Flux: Damping"         , "W/m2"   ,   &  ! qrp
276            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
277         CALL histdef( nid_T, "sowafldp", "Surface Water Flux: Damping"        , "Kg/m2/s",   &  ! erp
278            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
279         CALL histdef( nid_T, "sosafldp", "Surface salt flux: damping"         , "Kg/m2/s",   &  ! erp * sn
280            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
281#endif
282
283#if defined key_flx_core
284         CALL histdef( nid_T, "solhflup", "Latent Heat Flux Upward"         , "W/m2"   ,   &  ! qla
285            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
286         CALL histdef( nid_T, "solwfldo", "Longwave Radiation downward"     , "W/m2"   ,   &  ! qlw
287            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
288         CALL histdef( nid_T, "sosbhfup", "Sensible Heat Flux upward"       , "W/m2"   ,   &  ! qsb
289            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
290#endif
291
292
293#if ( defined key_coupled && ! defined key_ice_lim )
294         CALL histdef( nid_T, "sohefldp", "Surface Heat Flux: Damping"         , "W/m2"   ,   &  ! qrp
295            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
296         CALL histdef( nid_T, "sowafldp", "Surface Water Flux: Damping"        , "Kg/m2/s",   &  ! erp
297            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
298         CALL histdef( nid_T, "sosafldp", "Surface salt flux: Damping"         , "Kg/m2/s",   &  ! erp * sn
299            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
300#endif
301#if defined key_diaspr
302         CALL histdef( nid_T, "sosurfps", "Surface Pressure"                   , "cm"     ,   &  ! sp
303            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
304#endif
305         clmx ="l_max(only(x))"    ! max index on a period
306         CALL histdef( nid_T, "sobowlin", "Bowl Index"                         , "W-point",   &  ! bowl INDEX
307            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clmx, zsto, zout )
308#if defined key_diahth
309         CALL histdef( nid_T, "sothedep", "Thermocline Depth"                  , "m"      ,   & ! hth
310            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
311         CALL histdef( nid_T, "so20chgt", "Depth of 20C isotherm"              , "m"      ,   & ! hd20
312            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
313         CALL histdef( nid_T, "so28chgt", "Depth of 28C isotherm"              , "m"      ,   & ! hd28
314            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
315         CALL histdef( nid_T, "sohtc300", "Heat content 300 m"                 , "W"      ,   & ! htc3
316            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
317#endif
318
319#if defined key_ice_lim && defined key_coupled
320         CALL histdef( nid_T,"soicetem" , "Ice Surface Temperature"            , "K"      ,   &  ! tn_ice
321            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
322         CALL histdef( nid_T,"soicealb" , "Ice Albedo"                         , "[0,1]"  ,   &  ! alb_ice
323            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
324#endif
325
326         CALL histend( nid_T )
327
328         !                                                                                      !!! nid_U : 3D
329         CALL histdef( nid_U, "vozocrtx", "Zonal Current"                      , "m/s"    ,   &  ! un
330            &          jpi, jpj, nh_U, ipk, 1, ipk, nz_U, 32, clop, zsto, zout )
331#if defined key_diaeiv
332         CALL histdef( nid_U, "vozoeivu", "Zonal EIV Current"                  , "m/s"    ,   &  ! u_eiv
333            &          jpi, jpj, nh_U, ipk, 1, ipk, nz_U, 32, clop, zsto, zout )
334#endif
335         !                                                                                      !!! nid_U : 2D
336         CALL histdef( nid_U, "sozotaux", "Wind Stress along i-axis"           , "N/m2"   ,   &  ! taux
337            &          jpi, jpj, nh_U, 1  , 1, 1  , - 99, 32, clop, zsto, zout )
338#if defined key_dynspg_rl
339         CALL histdef( nid_U, "sozospgx", "Zonal Surface Pressure Gradient"    , "N/kg"   ,   &  ! spgu
340            &          jpi, jpj, nh_U, 1  , 1, 1  , - 99, 32, clop, zsto, zout )
341#endif
342
343         CALL histend( nid_U )
344
345         !                                                                                      !!! nid_V : 3D
346         CALL histdef( nid_V, "vomecrty", "Meridional Current"                 , "m/s"    ,   &  ! vn
347            &          jpi, jpj, nh_V, ipk, 1, ipk, nz_V, 32, clop, zsto, zout )
348#if defined key_diaeiv
349         CALL histdef( nid_V, "vomeeivv", "Meridional EIV Current"             , "m/s"    ,   &  ! v_eiv
350            &          jpi, jpj, nh_V, ipk, 1, ipk, nz_V, 32, clop, zsto, zout )
351#endif
352         !                                                                                      !!! nid_V : 2D
353         CALL histdef( nid_V, "sometauy", "Wind Stress along j-axis"           , "N/m2"   ,   &  ! tauy
354            &          jpi, jpj, nh_V, 1  , 1, 1  , - 99, 32, clop, zsto, zout )
355#if defined key_dynspg_rl
356         CALL histdef( nid_V, "somespgy", "Meridional Surface Pressure Grad."  , "N/kg"   ,   &  ! spgv
357            &          jpi, jpj, nh_V, 1  , 1, 1  , - 99, 32, clop, zsto, zout )
358#endif
359
360         CALL histend( nid_V )
361
362         !                                                                                      !!! nid_W : 3D
363         CALL histdef( nid_W, "vovecrtz", "Vertical Velocity"                  , "m/s"    ,   &  ! wn
364            &          jpi, jpj, nh_W, ipk, 1, ipk, nz_W, 32, clop, zsto, zout )
365#if defined key_diaeiv
366         CALL histdef( nid_W, "voveeivw", "Vertical EIV Velocity"              , "m/s"    ,   &  ! w_eiv
367            &          jpi, jpj, nh_W, ipk, 1, ipk, nz_W, 32, clop, zsto, zout )
368#endif
369         CALL histdef( nid_W, "votkeavt", "Vertical Eddy Diffusivity"          , "m2/s"   ,   &  ! avt
370            &          jpi, jpj, nh_W, ipk, 1, ipk, nz_W, 32, clop, zsto, zout )
371
372         CALL histdef( nid_W, "votkeevd", "Enhanced Vertical Diffusivity",       "m2/s"   ,   &  ! avt_evd
373            &          jpi, jpj, nh_W, ipk, 1, ipk, nz_W, 32, clop, zsto, zout )
374         !
375         CALL histdef( nid_W, "votkeavm", "Vertical Eddy Viscosity"             , "m2/s"  ,   &  ! avmu
376            &          jpi, jpj, nh_W, ipk, 1, ipk, nz_W, 32, clop, zsto, zout )
377
378         CALL histdef( nid_W, "votkeevm", "Enhanced Vertical Viscosity",         "m2/s"   ,   &  ! avmu_evd
379            &          jpi, jpj, nh_W, ipk, 1, ipk, nz_W, 32, clop, zsto, zout )
380
381         IF( lk_zdfddm ) THEN
382            CALL histdef( nid_W,"voddmavs","Salt Vertical Eddy Diffusivity"    , "m2/s"   ,   &  ! avs
383               &          jpi, jpj, nh_W, ipk, 1, ipk, nz_W, 32, clop, zsto, zout )
384         ENDIF
385         !                                                                                      !!! nid_W : 2D
386#if defined key_traldf_c2d
387         CALL histdef( nid_W, "soleahtw", "lateral eddy diffusivity"           , "m2/s"   ,   &  ! ahtw
388            &          jpi, jpj, nh_W, 1  , 1, 1  , - 99, 32, clop, zsto, zout )
389# if defined key_traldf_eiv 
390            CALL histdef( nid_W, "soleaeiw", "eddy induced vel. coeff. at w-point", "m2/s",   &  ! aeiw
391               &       jpi, jpj, nh_W, 1  , 1, 1  , - 99, 32, clop, zsto, zout )
392# endif
393#endif
394
395         CALL histend( nid_W )
396
397         IF(lwp) WRITE(numout,*)
398         IF(lwp) WRITE(numout,*) 'End of NetCDF Initialization'
399         IF(ll_print) CALL FLUSH(numout )
400
401      ENDIF
402
403      ! 2. Start writing data
404      ! ---------------------
405
406      ! ndex(1) est utilise ssi l'avant dernier argument est diffferent de
407      ! la taille du tableau en sortie. Dans ce cas , l'avant dernier argument
408      ! donne le nombre d'elements, et ndex la liste des indices a sortir
409
410      IF( lwp .AND. MOD( kt, nwrite ) == 0 ) THEN
411         WRITE(numout,*) 'dia_wri : write model outputs in NetCDF files at ', kt, 'time-step'
412         WRITE(numout,*) '~~~~~~ '
413      ENDIF
414
415      ! Write fields on T grid
416      CALL histwrite( nid_T, "votemper", it, tn            , ndim_T , ndex_T  )   ! temperature
417      CALL histwrite( nid_T, "vosaline", it, sn            , ndim_T , ndex_T  )   ! salinity
418      CALL histwrite( nid_T, "sosstsst", it, tn(:,:,1)     , ndim_hT, ndex_hT )   ! sea surface temperature
419      CALL histwrite( nid_T, "sosaline", it, sn(:,:,1)     , ndim_hT, ndex_hT )   ! sea surface salinity
420#if defined key_dynspg_rl
421      CALL histwrite( nid_T, "sobarstf", it, bsfn          , ndim_hT, ndex_hT )   ! barotropic streamfunction
422#else
423      CALL histwrite( nid_T, "sossheig", it, sshn          , ndim_hT, ndex_hT )   ! sea surface height
424#endif
425#if ! defined key_dynspg_rl && defined key_ice_lim
426      CALL histwrite( nid_T, "iowaflup", it, fsalt(:,:)    , ndim_hT, ndex_hT )   ! ice=>ocean water flux
427      CALL histwrite( nid_T, "sowaflep", it, fmass(:,:)    , ndim_hT, ndex_hT )   ! atmos=>ocean water flux
428#endif
429      CALL histwrite( nid_T, "sowaflup", it, emp           , ndim_hT, ndex_hT )   ! upward water flux
430      CALL histwrite( nid_T, "sorunoff", it, runoff        , ndim_hT, ndex_hT )   ! runoff
431      CALL histwrite( nid_T, "sowaflcd", it, emps          , ndim_hT, ndex_hT )   ! c/d water flux
432      zw2d(:,:) = emps(:,:) * sn(:,:,1) * tmask(:,:,1)
433      CALL histwrite( nid_T, "sosalflx", it, zw2d          , ndim_hT, ndex_hT )   ! c/d salt flux
434      CALL histwrite( nid_T, "sohefldo", it, qt            , ndim_hT, ndex_hT )   ! total heat flux
435      CALL histwrite( nid_T, "soshfldo", it, qsr           , ndim_hT, ndex_hT )   ! solar heat flux
436      CALL histwrite( nid_T, "somxl010", it, hmlp          , ndim_hT, ndex_hT )   ! mixed layer depth
437      CALL histwrite( nid_T, "somixhgt", it, hmld          , ndim_hT, ndex_hT )   ! turbocline depth
438      CALL histwrite( nid_T, "soicecov", it, freeze        , ndim_hT, ndex_hT )   ! ice cover
439#if ! defined key_coupled
440      CALL histwrite( nid_T, "sohefldp", it, qrp           , ndim_hT, ndex_hT )   ! heat flux damping
441      CALL histwrite( nid_T, "sowafldp", it, erp           , ndim_hT, ndex_hT )   ! freshwater flux damping
442      zw2d(:,:) = erp(:,:) * sn(:,:,1) * tmask(:,:,1)
443      CALL histwrite( nid_T, "sosafldp", it, zw2d          , ndim_hT, ndex_hT )   ! salt flux damping
444#endif
445#if defined key_flx_core
446      CALL histwrite( nid_T, "solhflup", it, qla           , ndim_hT, ndex_hT )   ! latent heat flux
447      CALL histwrite( nid_T, "solwfldo", it, qlw           , ndim_hT, ndex_hT )   ! longwave heat flux
448      CALL histwrite( nid_T, "sosbhfup", it, qsb           , ndim_hT, ndex_hT )   ! sensible heat flux
449#endif
450#if ( defined key_coupled && ! defined key_ice_lim )
451      CALL histwrite( nid_T, "sohefldp", it, qrp           , ndim_hT, ndex_hT )   ! heat flux damping
452      CALL histwrite( nid_T, "sowafldp", it, erp           , ndim_hT, ndex_hT )   ! freshwater flux damping
453         zw2d(:,:) = erp(:,:) * sn(:,:,1) * tmask(:,:,1)
454      CALL histwrite( nid_T, "sosafldp", it, zw2d          , ndim_hT, ndex_hT )   ! salt flux damping
455#endif
456#if defined key_diaspr
457      CALL histwrite( nid_T, "sosurfps", it, gps           , ndim_hT, ndex_hT )   ! surface pressure
458#endif
459         zw2d(:,:) = FLOAT( nmln(:,:) ) * tmask(:,:,1)
460      CALL histwrite( nid_T, "sobowlin", it, zw2d          , ndim_hT, ndex_hT )   ! ???
461
462#if defined key_diahth
463      CALL histwrite( nid_T, "sothedep", it, hth           , ndim_hT, ndex_hT )   ! depth of the thermocline
464      CALL histwrite( nid_T, "so20chgt", it, hd20          , ndim_hT, ndex_hT )   ! depth of the 20 isotherm
465      CALL histwrite( nid_T, "so28chgt", it, hd28          , ndim_hT, ndex_hT )   ! depth of the 28 isotherm
466      CALL histwrite( nid_T, "sohtc300", it, htc3          , ndim_hT, ndex_hT )   ! first 300m heaat content
467#endif
468#if defined key_ice_lim &&  defined key_coupled 
469      CALL histwrite( nid_T, "soicetem", it, tn_ice        , ndim_hT, ndex_hT )   ! surf. ice temperature
470      CALL histwrite( nid_T, "soicealb", it, alb_ice       , ndim_hT, ndex_hT )   ! ice albedo
471#endif
472         ! Write fields on U grid
473      CALL histwrite( nid_U, "vozocrtx", it, un            , ndim_U , ndex_U )    ! i-current
474#if defined key_diaeiv
475      CALL histwrite( nid_U, "vozoeivu", it, u_eiv         , ndim_U , ndex_U )    ! i-eiv current
476#endif
477      CALL histwrite( nid_U, "sozotaux", it, taux          , ndim_hU, ndex_hU )   ! i-wind stress
478#if defined key_dynspg_rl
479      CALL lbc_lnk( spgu, 'U', -1. )
480      CALL histwrite( nid_U, "sozospgx", it, spgu          , ndim_hU, ndex_hU )   ! i-surf. press. grad.
481#endif
482
483         ! Write fields on V grid
484      CALL histwrite( nid_V, "vomecrty", it, vn            , ndim_V , ndex_V  )   ! j-current
485#if defined key_diaeiv
486      CALL histwrite( nid_V, "vomeeivv", it, v_eiv         , ndim_V , ndex_V  )   ! j-eiv current
487#endif
488      CALL histwrite( nid_V, "sometauy", it, tauy          , ndim_hV, ndex_hV )   ! j-wind stress
489#if defined key_dynspg_rl
490      CALL lbc_lnk( spgv, 'V', -1. )
491      CALL histwrite( nid_V, "somespgy", it, spgv          , ndim_hV, ndex_hV )   ! j-surf. pressure grad.
492#endif
493
494         ! Write fields on W grid
495      CALL histwrite( nid_W, "vovecrtz", it, wn             , ndim_T, ndex_T )    ! vert. current
496#   if defined key_diaeiv
497      CALL histwrite( nid_W, "voveeivw", it, w_eiv          , ndim_T, ndex_T )    ! vert. eiv current
498#   endif
499      CALL histwrite( nid_W, "votkeavt", it, avt            , ndim_T, ndex_T )    ! T vert. eddy diff. coef.
500      CALL histwrite( nid_W, "votkeevd", it, avt_evd        , ndim_T, ndex_T )    ! T enhan. vert. eddy diff. coef.
501      CALL histwrite( nid_W, "votkeavm", it, avmu           , ndim_T, ndex_T )    ! T vert. eddy visc. coef.
502      CALL histwrite( nid_W, "votkeevm", it, avmu_evd       , ndim_T, ndex_T )    ! T enhan. vert. eddy visc. coef.
503      IF( lk_zdfddm ) THEN
504         CALL histwrite( nid_W, "voddmavs", it, fsavs(:,:,:), ndim_T, ndex_T )    ! S vert. eddy diff. coef.
505      ENDIF
506#if defined key_traldf_c2d
507      CALL histwrite( nid_W, "soleahtw", it, ahtw          , ndim_hT, ndex_hT )   ! lateral eddy diff. coef.
508# if defined key_traldf_eiv
509         CALL histwrite( nid_W, "soleaeiw", it, aeiw       , ndim_hT, ndex_hT )   ! EIV coefficient at w-point
510# endif
511#endif
512
513      ! 3. Synchronise and close all files
514      ! ---------------------------------------
515      IF( MOD( kt, nwrite ) == 0 .OR. kindic < 0 ) THEN
516         CALL histsync( nid_T )
517         CALL histsync( nid_U )
518         CALL histsync( nid_V )
519         CALL histsync( nid_W )
520      ENDIF
521
522      !  Create an output files (output.abort.nc) if S < 0 or u > 20 m/s
523      IF( kindic < 0 )   CALL dia_wri_state( 'output.abort' )
524
525      IF( kt == nitend .OR. kindic < 0 ) THEN
526         CALL histclo( nid_T )
527         CALL histclo( nid_U )
528         CALL histclo( nid_V )
529         CALL histclo( nid_W )
530      ENDIF
531
532   END SUBROUTINE dia_wri
533
534
535   SUBROUTINE dia_wri_state( cdfile_name )
536      !!---------------------------------------------------------------------
537      !!                 ***  ROUTINE dia_wri_state  ***
538      !!       
539      !! ** Purpose :   create a NetCDF file named cdfile_name which contains
540      !!      the instantaneous ocean state and forcing fields.
541      !!        Used to find errors in the initial state or save the last
542      !!      ocean state in case of abnormal end of a simulation
543      !!
544      !! ** Method  :   NetCDF files using ioipsl
545      !!      File 'output.init.nc'  is created if ninist = 1 (namelist)
546      !!      File 'output.abort.nc' is created in case of abnormal job end
547      !!
548      !! History :
549      !!   8.2  !  00-06  (M. Imbard)  Original code (diabort.F)
550      !!   8.5  !  02-06  (A.Bozec, E. Durand)  Original code (diainit.F)
551      !!   9.0  !  02-12  (G. Madec)  merge of diabort and diainit, F90
552      !!    "   !  05-11  (V. Garnier) Surface pressure gradient organization
553      !!----------------------------------------------------------------------
554      !! * Arguments
555      CHARACTER (len=* ), INTENT( in ) ::   &
556         cdfile_name      ! name of the file created
557
558      !! * Local declarations
559      CHARACTER (len=32) :: clname
560      CHARACTER (len=40) :: clop
561      INTEGER  ::   &
562         id_i , nz_i, nh_i       
563      INTEGER, DIMENSION(1) ::   &
564         idex             ! temprary workspace
565      REAL(wp) ::   &
566         zsto, zout, zmax,   &
567         zjulian, zdt
568      !!----------------------------------------------------------------------
569
570      ! 0. Initialisation
571      ! -----------------
572
573      ! Define name, frequency of output and means
574      clname = cdfile_name
575#if defined key_agrif
576      if ( .NOT. Agrif_Root() ) clname = TRIM(Agrif_CFixed())//'_'//TRIM(clname)
577#endif
578      zdt  = rdt
579      zsto = rdt
580      clop = "inst(x)"           ! no use of the mask value (require less cpu time)
581      zout = rdt
582      zmax = ( nitend - nit000 + 1 ) * zdt
583
584      IF(lwp) WRITE(numout,*)
585      IF(lwp) WRITE(numout,*) 'dia_wri_state : single instantaneous ocean state'
586      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~   and forcing fields file created '
587      IF(lwp) WRITE(numout,*) '                and named :', clname, '.nc'
588
589
590      ! 1. Define NETCDF files and fields at beginning of first time step
591      ! -----------------------------------------------------------------
592
593      ! Compute julian date from starting date of the run
594      CALL ymds2ju( nyear, nmonth, nday, 0.e0, zjulian )         ! time axis
595      CALL histbeg( clname, jpi, glamt, jpj, gphit,   &
596          1, jpi, 1, jpj, 0, zjulian, zdt, nh_i, id_i, domain_id=nidom )          ! Horizontal grid : glamt and gphit
597      CALL histvert( id_i, "deptht", "Vertical T levels",   &    ! Vertical grid : gdept
598          "m", jpk, gdept_0, nz_i)
599
600      ! Declare all the output fields as NetCDF variables
601
602      CALL histdef( id_i, "vosaline", "Salinity"              , "PSU"    ,   &   ! salinity
603         &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout )
604      CALL histdef( id_i, "votemper", "Temperature"           , "C"      ,   &   ! temperature
605         &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout )
606#if defined key_dynspg_rl
607      CALL histdef( id_i, "sobarstf","Barotropic StreamFunction", "m3/s2"  ,   &  ! bsf
608         &          jpi, jpj, nh_i, 1  , 1, 1  , nz_i, 32, clop, zsto, zout )
609#else
610      CALL histdef( id_i, "sossheig", "Sea Surface Height"    , "m"      ,   &  ! ssh
611         &          jpi, jpj, nh_i, 1  , 1, 1  , nz_i, 32, clop, zsto, zout )
612#endif
613      CALL histdef( id_i, "vozocrtx", "Zonal Current"         , "m/s"    ,   &   ! zonal current
614         &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout )
615      CALL histdef( id_i, "vomecrty", "Meridional Current"    , "m/s"    ,   &   ! meridonal current
616         &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout ) 
617      CALL histdef( id_i, "vovecrtz", "Vertical Velocity"     , "m/s"    ,   &   ! vertical current
618         &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout ) 
619      CALL histdef( id_i, "sowaflup", "Net Upward Water Flux" , "Kg/m2/S",   &   ! net freshwater
620         &          jpi, jpj, nh_i, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
621      CALL histdef( id_i, "sohefldo", "Net Downward Heat Flux", "W/m2"   ,   &   ! net heat flux
622         &          jpi, jpj, nh_i, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
623      CALL histdef( id_i, "soshfldo", "Shortwave Radiation"   , "W/m2"   ,   &   ! solar flux
624         &          jpi, jpj, nh_i, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
625      CALL histdef( id_i, "soicecov", "Ice fraction"          , "[0,1]"  ,   &   ! freeze
626         &          jpi, jpj, nh_i, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
627      CALL histdef( id_i, "sozotaux", "Zonal Wind Stress"     , "N/m2"   ,   &   ! i-wind stress
628         &          jpi, jpj, nh_i, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
629      CALL histdef( id_i, "sometauy", "Meridional Wind Stress", "N/m2"   ,   &   ! j-wind stress
630         &          jpi, jpj, nh_i, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
631
632      CALL histend( id_i )
633
634      ! 2. Start writing data
635      ! ---------------------
636      ! idex(1) est utilise ssi l'avant dernier argument est diffferent de
637      ! la taille du tableau en sortie. Dans ce cas , l'avant dernier argument
638      ! donne le nombre d'elements, et idex la liste des indices a sortir
639      idex(1) = 1   ! init to avoid compil warning
640
641      ! Write all fields on T grid
642      CALL histwrite( id_i, "votemper", 1, tn    , jpi*jpj*jpk, idex )    ! now temperature
643      CALL histwrite( id_i, "vosaline", 1, sn    , jpi*jpj*jpk, idex )    ! now salinity
644#if defined key_dynspg_rl
645      CALL histwrite( id_i, "sobarstf", 1, bsfn  , jpi*jpj    , idex )    ! barotropic streamfunction
646#else
647      CALL histwrite( id_i, "sossheig", 1, sshn  , jpi*jpj    , idex )    ! sea surface height
648#endif
649      CALL histwrite( id_i, "vozocrtx", 1, un    , jpi*jpj*jpk, idex )    ! now i-velocity
650      CALL histwrite( id_i, "vomecrty", 1, vn    , jpi*jpj*jpk, idex )    ! now j-velocity
651      CALL histwrite( id_i, "vovecrtz", 1, wn    , jpi*jpj*jpk, idex )    ! now k-velocity
652      CALL histwrite( id_i, "sowaflup", 1, emp   , jpi*jpj    , idex )    ! freshwater budget
653      CALL histwrite( id_i, "sohefldo", 1, qt    , jpi*jpj    , idex )    ! total heat flux
654      CALL histwrite( id_i, "soshfldo", 1, qsr   , jpi*jpj    , idex )    ! total heat flux
655      CALL histwrite( id_i, "soicecov", 1, freeze, jpi*jpj    , idex )    ! ice cover
656      CALL histwrite( id_i, "sozotaux", 1, taux  , jpi*jpj    , idex )    ! i-wind stress
657      CALL histwrite( id_i, "sometauy", 1, tauy  , jpi*jpj    , idex )    ! j-wind stress
658
659      ! 3. Close the file
660      ! -----------------
661      CALL histclo( id_i )
662
663   END SUBROUTINE dia_wri_state
664
665#endif
666   !!======================================================================
667END MODULE diawri
Note: See TracBrowser for help on using the repository browser.