source: LMDZ4/branches/LMDZ4-dev/libf/phylmd/phys_output_mod.F90 @ 1183

Last change on this file since 1183 was 1176, checked in by Laurent Fairhead, 15 years ago

Modif pour la compilation avec fcm sur Vargas SD
Corrections relatives au controle de histins et de l'utilisation des
options INST(X) pour l'appel au routines de IOIPSL FH
Mise en place de diagnostics sur les critères CFL pour l'advection
de traceurs. FH
Controle dans les .def de la dépendance verticale de l'efficacite
de la diffusion. Actif pour le moment uniquement avec ok_strato=y et llm=39. FH
LF

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 60.2 KB
Line 
1!
2! $Id: phys_output_mod.F90 1176 2009-06-11 08:54:10Z jghattas $
3!
4! Abderrahmane 12 2007
5!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6!!! Ecreture des Sorties du modele dans les fichiers Netcdf :
7! histmth.nc : moyennes mensuelles
8! histday.nc : moyennes journalieres
9! histhf.nc  : moyennes toutes les 3 heures
10! histins.nc : valeurs instantanees
11!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12
13MODULE phys_output_mod
14
15  IMPLICIT NONE
16
17  private histdef2d, histdef3d, conf_physoutputs
18
19
20   integer, parameter                           :: nfiles = 5
21   logical, dimension(nfiles), save             :: clef_files
22   integer, dimension(nfiles), save             :: lev_files
23   integer, dimension(nfiles), save             :: nid_files
24!$OMP THREADPRIVATE(clef_files, lev_files,nid_files)
25 
26   integer, dimension(nfiles), private, save :: nhorim, nvertm
27   real, dimension(nfiles), private, save                :: zoutm
28   real,                    private, save                :: zdtime
29   CHARACTER(len=20), dimension(nfiles), private, save   :: type_ecri
30!$OMP THREADPRIVATE(nhorim, nvertm, zoutm,zdtime,type_ecri)
31
32!   integer, save                     :: nid_hf3d
33
34!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
35!! Definition pour chaque variable du niveau d ecriture dans chaque fichier
36!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!/ histmth, histday, histhf, histins /),'!!!!!!!!!!!!
37!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
38
39  integer, private:: levmin(nfiles) = 1
40  integer, private:: levmax(nfiles)
41
42  TYPE ctrl_out
43   integer,dimension(5) :: flag
44   character(len=20)     :: name
45  END TYPE ctrl_out
46
47
48!!! 1D
49  type(ctrl_out) :: o_phis         = ctrl_out((/ 1, 1, 10, 1, 1 /), 'phis')
50  type(ctrl_out) :: o_aire         = ctrl_out((/ 1, 1, 10,  1, 1 /),'aire')
51  type(ctrl_out) :: o_contfracATM  = ctrl_out((/ 10, 1,  1, 10, 10 /),'contfracATM')
52  type(ctrl_out) :: o_contfracOR   = ctrl_out((/ 10, 1,  1, 10, 10 /),'contfracOR')
53  type(ctrl_out) :: o_aireTER      = ctrl_out((/ 10, 10, 1, 10, 10 /),'aireTER')
54 
55!!! 2D
56  type(ctrl_out) :: o_flat         = ctrl_out((/ 10, 1, 10, 10, 1 /),'flat')
57  type(ctrl_out) :: o_slp          = ctrl_out((/ 1, 1, 1, 10, 1 /),'slp')
58  type(ctrl_out) :: o_tsol         = ctrl_out((/ 1, 1, 1, 1, 1 /),'tsol')
59  type(ctrl_out) :: o_t2m          = ctrl_out((/ 1, 1, 1, 1, 1 /),'t2m')
60  type(ctrl_out) :: o_t2m_min      = ctrl_out((/ 1, 1, 10, 10, 10 /),'t2m_min')
61  type(ctrl_out) :: o_t2m_max      = ctrl_out((/ 1, 1, 10, 10, 10 /),'t2m_max')
62  type(ctrl_out),dimension(4) :: o_t2m_srf      = (/ ctrl_out((/ 10, 4, 10, 10, 10 /),'t2m_ter'), &
63                                                 ctrl_out((/ 10, 4, 10, 10, 10 /),'t2m_lic'), &
64                                                 ctrl_out((/ 10, 4, 10, 10, 10 /),'t2m_oce'), &
65                                                 ctrl_out((/ 10, 4, 10, 10, 10 /),'t2m_sic') /)
66
67  type(ctrl_out) :: o_wind10m      = ctrl_out((/ 1, 1, 1, 10, 10 /),'wind10m')
68  type(ctrl_out) :: o_wind10max    = ctrl_out((/ 10, 1, 10, 10, 10 /),'wind10max')
69  type(ctrl_out) :: o_sicf         = ctrl_out((/ 1, 1, 10, 10, 10 /),'sicf')
70  type(ctrl_out) :: o_q2m          = ctrl_out((/ 1, 1, 1, 1, 1 /),'q2m')
71  type(ctrl_out) :: o_u10m         = ctrl_out((/ 1, 1, 1, 1, 1 /),'u10m')
72  type(ctrl_out) :: o_v10m         = ctrl_out((/ 1, 1, 1, 1, 1 /),'v10m')
73  type(ctrl_out) :: o_psol         = ctrl_out((/ 1, 1, 1, 1, 1 /),'psol')
74  type(ctrl_out) :: o_qsurf        = ctrl_out((/ 1, 10, 10, 10, 10 /),'qsurf')
75
76  type(ctrl_out),dimension(4) :: o_u10m_srf     = (/ ctrl_out((/ 10, 4, 10, 10, 10 /),'u10m_ter'), &
77                                              ctrl_out((/ 10, 4, 10, 10, 10 /),'u10m_lic'), &
78                                              ctrl_out((/ 10, 4, 10, 10, 10 /),'u10m_oce'), &
79                                              ctrl_out((/ 10, 4, 10, 10, 10 /),'u10m_sic') /)
80
81  type(ctrl_out),dimension(4) :: o_v10m_srf     = (/ ctrl_out((/ 10, 4, 10, 10, 10 /),'v10m_ter'), &
82                                              ctrl_out((/ 10, 4, 10, 10, 10 /),'v10m_lic'), &
83                                              ctrl_out((/ 10, 4, 10, 10, 10 /),'v10m_oce'), &
84                                              ctrl_out((/ 10, 4, 10, 10, 10 /),'v10m_sic') /)
85
86  type(ctrl_out) :: o_qsol         = ctrl_out((/ 1, 10, 10, 1, 1 /),'qsol')
87
88  type(ctrl_out) :: o_ndayrain     = ctrl_out((/ 1, 10, 10, 10, 10 /),'ndayrain')
89  type(ctrl_out) :: o_precip       = ctrl_out((/ 1, 1, 1, 1, 1 /),'precip')
90  type(ctrl_out) :: o_plul         = ctrl_out((/ 1, 1, 1, 1, 10 /),'plul')
91
92  type(ctrl_out) :: o_pluc         = ctrl_out((/ 1, 1, 1, 1, 10 /),'pluc')
93  type(ctrl_out) :: o_snow         = ctrl_out((/ 1, 1, 10, 1, 10 /),'snow')
94  type(ctrl_out) :: o_evap         = ctrl_out((/ 1, 1, 10, 1, 10 /),'evap')
95  type(ctrl_out) :: o_tops         = ctrl_out((/ 1, 1, 10, 10, 10 /),'tops')
96  type(ctrl_out) :: o_tops0        = ctrl_out((/ 1, 5, 10, 10, 10 /),'tops0')
97  type(ctrl_out) :: o_topl         = ctrl_out((/ 1, 1, 10, 1, 10 /),'topl')
98  type(ctrl_out) :: o_topl0        = ctrl_out((/ 1, 5, 10, 10, 10 /),'topl0')
99  type(ctrl_out) :: o_SWupTOA      = ctrl_out((/ 1, 4, 10, 10, 10 /),'SWupTOA')
100  type(ctrl_out) :: o_SWupTOAclr   = ctrl_out((/ 1, 4, 10, 10, 10 /),'SWupTOAclr')
101  type(ctrl_out) :: o_SWdnTOA      = ctrl_out((/ 1, 4, 10, 10, 10 /),'SWdnTOA')
102  type(ctrl_out) :: o_SWdnTOAclr   = ctrl_out((/ 1, 4, 10, 10, 10 /),'SWdnTOAclr')
103  type(ctrl_out) :: o_SWup200      = ctrl_out((/ 1, 10, 10, 10, 10 /),'SWup200')
104  type(ctrl_out) :: o_SWup200clr   = ctrl_out((/ 10, 1, 10, 10, 10 /),'SWup200clr')
105  type(ctrl_out) :: o_SWdn200      = ctrl_out((/ 1, 10, 10, 10, 10 /),'SWdn200')
106  type(ctrl_out) :: o_SWdn200clr   = ctrl_out((/ 10, 1, 10, 10, 10 /),'SWdn200clr')
107
108! arajouter
109!  type(ctrl_out) :: o_LWupTOA     = ctrl_out((/ 1, 4, 10, 10, 10 /),'LWupTOA')
110!  type(ctrl_out) :: o_LWupTOAclr  = ctrl_out((/ 1, 4, 10, 10, 10 /),'LWupTOAclr')
111!  type(ctrl_out) :: o_LWdnTOA     = ctrl_out((/ 1, 4, 10, 10, 10 /),'LWdnTOA')
112!  type(ctrl_out) :: o_LWdnTOAclr  = ctrl_out((/ 1, 4, 10, 10, 10 /),'LWdnTOAclr')
113
114  type(ctrl_out) :: o_LWup200      = ctrl_out((/ 1, 10, 10, 10, 10 /),'LWup200')
115  type(ctrl_out) :: o_LWup200clr   = ctrl_out((/ 1, 10, 10, 10, 10 /),'LWup200clr')
116  type(ctrl_out) :: o_LWdn200      = ctrl_out((/ 1, 10, 10, 10, 10 /),'LWdn200')
117  type(ctrl_out) :: o_LWdn200clr   = ctrl_out((/ 1, 10, 10, 10, 10 /),'LWdn200clr')
118  type(ctrl_out) :: o_sols         = ctrl_out((/ 1, 1, 10, 1, 10 /),'sols')
119  type(ctrl_out) :: o_sols0        = ctrl_out((/ 1, 5, 10, 10, 10 /),'sols0')
120  type(ctrl_out) :: o_soll         = ctrl_out((/ 1, 1, 10, 1, 10 /),'soll')
121  type(ctrl_out) :: o_soll0        = ctrl_out((/ 1, 5, 10, 10, 10 /),'soll0')
122  type(ctrl_out) :: o_radsol       = ctrl_out((/ 1, 1, 10, 10, 10 /),'radsol')
123  type(ctrl_out) :: o_SWupSFC      = ctrl_out((/ 1, 4, 10, 10, 10 /),'SWupSFC')
124  type(ctrl_out) :: o_SWupSFCclr   = ctrl_out((/ 1, 4, 10, 10, 10 /),'SWupSFCclr')
125  type(ctrl_out) :: o_SWdnSFC      = ctrl_out((/ 1, 1, 10, 10, 10 /),'SWdnSFC')
126  type(ctrl_out) :: o_SWdnSFCclr   = ctrl_out((/ 1, 4, 10, 10, 10 /),'SWdnSFCclr')
127  type(ctrl_out) :: o_LWupSFC      = ctrl_out((/ 1, 4, 10, 10, 10 /),'LWupSFC')
128  type(ctrl_out) :: o_LWupSFCclr   = ctrl_out((/ 1, 4, 10, 10, 10 /),'LWupSFCclr')
129  type(ctrl_out) :: o_LWdnSFC      = ctrl_out((/ 1, 4, 10, 10, 10 /),'LWdnSFC')
130  type(ctrl_out) :: o_LWdnSFCclr   = ctrl_out((/ 1, 4, 10, 10, 10 /),'LWdnSFCclr')
131  type(ctrl_out) :: o_bils         = ctrl_out((/ 1, 2, 10, 1, 10 /),'bils')
132  type(ctrl_out) :: o_sens         = ctrl_out((/ 1, 1, 10, 1, 1 /),'sens')
133  type(ctrl_out) :: o_fder         = ctrl_out((/ 1, 2, 10, 1, 10 /),'fder')
134  type(ctrl_out) :: o_ffonte       = ctrl_out((/ 1, 10, 10, 10, 10 /),'ffonte')
135  type(ctrl_out) :: o_fqcalving    = ctrl_out((/ 1, 10, 10, 10, 10 /),'fqcalving')
136  type(ctrl_out) :: o_fqfonte      = ctrl_out((/ 1, 10, 10, 10, 10 /),'fqfonte')
137
138  type(ctrl_out),dimension(4) :: o_taux_srf     = (/ ctrl_out((/ 1, 4, 10, 1, 10 /),'taux_ter'), &
139                                                 ctrl_out((/ 1, 4, 10, 1, 10 /),'taux_lic'), &
140                                                 ctrl_out((/ 1, 4, 10, 1, 10 /),'taux_oce'), &
141                                                 ctrl_out((/ 1, 4, 10, 1, 10 /),'taux_sic') /)
142
143  type(ctrl_out),dimension(4) :: o_tauy_srf     = (/ ctrl_out((/ 1, 4, 10, 1, 10 /),'tauy_ter'), &
144                                                 ctrl_out((/ 1, 4, 10, 1, 10 /),'tauy_lic'), &
145                                                 ctrl_out((/ 1, 4, 10, 1, 10 /),'tauy_oce'), &
146                                                 ctrl_out((/ 1, 4, 10, 1, 10 /),'tauy_sic') /)
147
148
149  type(ctrl_out),dimension(4) :: o_pourc_srf    = (/ ctrl_out((/ 1, 4, 10, 1, 10 /),'pourc_ter'), &
150                                                 ctrl_out((/ 1, 4, 10, 1, 10 /),'pourc_lic'), &
151                                                 ctrl_out((/ 1, 4, 10, 1, 10 /),'pourc_oce'), &
152                                                 ctrl_out((/ 1, 4, 10, 1, 10 /),'pourc_sic') /)     
153
154  type(ctrl_out),dimension(4) :: o_fract_srf    = (/ ctrl_out((/ 1, 4, 10, 1, 10 /),'fract_ter'), &
155                                                 ctrl_out((/ 1, 4, 10, 1, 10 /),'fract_lic'), &
156                                                 ctrl_out((/ 1, 4, 10, 1, 10 /),'fract_oce'), &
157                                                 ctrl_out((/ 1, 4, 10, 1, 10 /),'fract_sic') /)
158
159  type(ctrl_out),dimension(4) :: o_tsol_srf     = (/ ctrl_out((/ 1, 4, 10, 1, 10 /),'tsol_ter'), &
160                                                 ctrl_out((/ 1, 4, 10, 1, 10 /),'tsol_lic'), &
161                                                 ctrl_out((/ 1, 4, 10, 1, 10 /),'tsol_oce'), &
162                                                 ctrl_out((/ 1, 4, 10, 1, 10 /),'tsol_sic') /)
163
164  type(ctrl_out),dimension(4) :: o_sens_srf     = (/ ctrl_out((/ 1, 4, 10, 1, 10 /),'sens_ter'), &
165                                                 ctrl_out((/ 1, 4, 10, 1, 10 /),'sens_lic'), &
166                                                 ctrl_out((/ 1, 4, 10, 1, 10 /),'sens_oce'), &
167                                                 ctrl_out((/ 1, 4, 10, 1, 10 /),'sens_sic') /)
168
169  type(ctrl_out),dimension(4) :: o_lat_srf      = (/ ctrl_out((/ 1, 4, 10, 1, 10 /),'lat_ter'), &
170                                                 ctrl_out((/ 1, 4, 10, 1, 10 /),'lat_lic'), &
171                                                 ctrl_out((/ 1, 4, 10, 1, 10 /),'lat_oce'), &
172                                                 ctrl_out((/ 1, 4, 10, 1, 10 /),'lat_sic') /)
173
174  type(ctrl_out),dimension(4) :: o_flw_srf      = (/ ctrl_out((/ 1, 10, 10, 10, 10 /),'flw_ter'), &
175                                                 ctrl_out((/ 1, 10, 10, 10, 10 /),'flw_lic'), &
176                                                 ctrl_out((/ 1, 10, 10, 10, 10 /),'flw_oce'), &
177                                                 ctrl_out((/ 1, 10, 10, 10, 10 /),'flw_sic') /)
178                                                 
179  type(ctrl_out),dimension(4) :: o_fsw_srf      = (/ ctrl_out((/ 1, 10, 10, 10, 10 /),'fsw_ter'), &
180                                                  ctrl_out((/ 1, 10, 10, 10, 10 /),'fsw_lic'), &
181                                                  ctrl_out((/ 1, 10, 10, 10, 10 /),'fsw_oce'), &
182                                                  ctrl_out((/ 1, 10, 10, 10, 10 /),'fsw_sic') /)
183
184  type(ctrl_out),dimension(4) :: o_wbils_srf    = (/ ctrl_out((/ 1, 10, 10, 10, 10 /),'wbils_ter'), &
185                                                 ctrl_out((/ 1, 10, 10, 10, 10 /),'wbils_lic'), &
186                                                 ctrl_out((/ 1, 10, 10, 10, 10 /),'wbils_oce'), &
187                                                 ctrl_out((/ 1, 10, 10, 10, 10 /),'wbils_sic') /)
188
189  type(ctrl_out),dimension(4) :: o_wbilo_srf    = (/ ctrl_out((/ 1, 10, 10, 10, 10 /),'wbilo_ter'), &
190                                                     ctrl_out((/ 1, 10, 10, 10, 10 /),'wbilo_lic'), &
191                                                 ctrl_out((/ 1, 10, 10, 10, 10 /),'wbilo_oce'), &
192                                                 ctrl_out((/ 1, 10, 10, 10, 10 /),'wbilo_sic') /)
193
194
195  type(ctrl_out) :: o_cdrm         = ctrl_out((/ 1, 10, 10, 1, 10 /),'cdrm')
196  type(ctrl_out) :: o_cdrh         = ctrl_out((/ 1, 10, 10, 1, 10 /),'cdrh')
197  type(ctrl_out) :: o_cldl         = ctrl_out((/ 1, 1, 10, 10, 10 /),'cldl')
198  type(ctrl_out) :: o_cldm         = ctrl_out((/ 1, 1, 10, 10, 10 /),'cldm')
199  type(ctrl_out) :: o_cldh         = ctrl_out((/ 1, 1, 10, 10, 10 /),'cldh')
200  type(ctrl_out) :: o_cldt         = ctrl_out((/ 1, 1, 2, 10, 10 /),'cldt')
201  type(ctrl_out) :: o_cldq         = ctrl_out((/ 1, 1, 10, 10, 10 /),'cldq')
202  type(ctrl_out) :: o_lwp          = ctrl_out((/ 1, 5, 10, 10, 10 /),'lwp')
203  type(ctrl_out) :: o_iwp          = ctrl_out((/ 1, 5, 10, 10, 10 /),'iwp')
204  type(ctrl_out) :: o_ue           = ctrl_out((/ 1, 10, 10, 10, 10 /),'ue')
205  type(ctrl_out) :: o_ve           = ctrl_out((/ 1, 10, 10, 10, 10 /),'ve')
206  type(ctrl_out) :: o_uq           = ctrl_out((/ 1, 10, 10, 10, 10 /),'uq')
207  type(ctrl_out) :: o_vq           = ctrl_out((/ 1, 10, 10, 10, 10 /),'vq')
208 
209  type(ctrl_out) :: o_cape         = ctrl_out((/ 1, 10, 10, 10, 10 /),'cape')
210  type(ctrl_out) :: o_pbase        = ctrl_out((/ 1, 10, 10, 10, 10 /),'pbase')
211  type(ctrl_out) :: o_ptop         = ctrl_out((/ 1, 4, 10, 10, 10 /),'ptop')
212  type(ctrl_out) :: o_fbase        = ctrl_out((/ 1, 10, 10, 10, 10 /),'fbase')
213  type(ctrl_out) :: o_prw          = ctrl_out((/ 1, 1, 10, 10, 10 /),'prw')
214
215  type(ctrl_out) :: o_s_pblh       = ctrl_out((/ 1, 10, 10, 1, 1 /),'s_pblh')
216  type(ctrl_out) :: o_s_pblt       = ctrl_out((/ 1, 10, 10, 1, 1 /),'s_pblt')
217  type(ctrl_out) :: o_s_lcl        = ctrl_out((/ 1, 10, 10, 1, 10 /),'s_lcl')
218  type(ctrl_out) :: o_s_capCL      = ctrl_out((/ 1, 10, 10, 1, 10 /),'s_capCL')
219  type(ctrl_out) :: o_s_oliqCL     = ctrl_out((/ 1, 10, 10, 1, 10 /),'s_oliqCL')
220  type(ctrl_out) :: o_s_cteiCL     = ctrl_out((/ 1, 10, 10, 1, 1 /),'s_cteiCL')
221  type(ctrl_out) :: o_s_therm      = ctrl_out((/ 1, 10, 10, 1, 1 /),'s_therm')
222  type(ctrl_out) :: o_s_trmb1      = ctrl_out((/ 1, 10, 10, 1, 10 /),'s_trmb1')
223  type(ctrl_out) :: o_s_trmb2      = ctrl_out((/ 1, 10, 10, 1, 10 /),'s_trmb2')
224  type(ctrl_out) :: o_s_trmb3      = ctrl_out((/ 1, 10, 10, 1, 10 /),'s_trmb3')
225
226  type(ctrl_out) :: o_slab_bils    = ctrl_out((/ 1, 1, 10, 10, 10 /),'slab_bils_oce')
227
228  type(ctrl_out) :: o_ale_bl       = ctrl_out((/ 1, 1, 1, 1, 10 /),'ale_bl')
229  type(ctrl_out) :: o_alp_bl       = ctrl_out((/ 1, 1, 1, 1, 10 /),'alp_bl')
230  type(ctrl_out) :: o_ale_wk       = ctrl_out((/ 1, 1, 1, 1, 10 /),'ale_wk')
231  type(ctrl_out) :: o_alp_wk       = ctrl_out((/ 1, 1, 1, 1, 10 /),'alp_wk')
232
233  type(ctrl_out) :: o_ale          = ctrl_out((/ 1, 1, 1, 1, 10 /),'ale')
234  type(ctrl_out) :: o_alp          = ctrl_out((/ 1, 1, 1, 1, 10 /),'alp')
235  type(ctrl_out) :: o_cin          = ctrl_out((/ 1, 1, 1, 1, 10 /),'cin')
236  type(ctrl_out) :: o_wape         = ctrl_out((/ 1, 1, 1, 1, 10 /),'wape')
237
238
239! Champs interpolles sur des niveaux de pression ??? a faire correctement
240! if=1 on ecrit u v w phi sur 850 700 500 200 au niv 1
241! if=2 on ecrit w et ph 500 seulement au niv 1
242!        et u v sur 850 700 500 200
243! if=3 on ecrit ph a 500 seulement au niv 1
244!      on ecrit u v t q a 850 700 500 200 au niv 3
245!      on ecrit ph  a 500   au niv 3
246
247                                             
248  type(ctrl_out),dimension(4) :: o_uSTDlevs     = (/ ctrl_out((/ 1, 1, 3, 10, 10 /),'u850'), &
249                                                     ctrl_out((/ 1, 1, 3, 10, 10 /),'u700'), &
250                                                     ctrl_out((/ 1, 1, 3, 10, 10 /),'u500'), &
251                                                     ctrl_out((/ 1, 1, 3, 10, 10 /),'u200') /)
252
253  type(ctrl_out),dimension(4) :: o_vSTDlevs     = (/ ctrl_out((/ 1, 1, 3, 10, 10 /),'v850'), &
254                                                     ctrl_out((/ 1, 1, 3, 10, 10 /),'v700'), &
255                                                     ctrl_out((/ 1, 1, 3, 10, 10 /),'v500'), &
256                                                     ctrl_out((/ 1, 1, 3, 10, 10 /),'v200') /)
257
258  type(ctrl_out),dimension(4) :: o_wSTDlevs     = (/ ctrl_out((/ 1, 1, 3, 10, 10 /),'w850'), &
259                                                     ctrl_out((/ 1, 1, 3, 10, 10 /),'w700'), &
260                                                     ctrl_out((/ 1, 1, 3, 10, 10 /),'w500'), &
261                                                     ctrl_out((/ 1, 1, 3, 10, 10 /),'w200') /)
262
263  type(ctrl_out),dimension(4) :: o_tSTDlevs     = (/ ctrl_out((/ 1, 1, 3, 10, 10 /),'t850'), &
264                                                     ctrl_out((/ 1, 1, 3, 10, 10 /),'t700'), &
265                                                     ctrl_out((/ 1, 1, 3, 10, 10 /),'t500'), &
266                                                     ctrl_out((/ 1, 1, 3, 10, 10 /),'t200') /)
267
268  type(ctrl_out),dimension(4) :: o_qSTDlevs     = (/ ctrl_out((/ 1, 1, 3, 10, 10 /),'q850'), &
269                                                     ctrl_out((/ 1, 1, 3, 10, 10 /),'q700'), &
270                                                     ctrl_out((/ 1, 1, 3, 10, 10 /),'q500'), &
271                                                     ctrl_out((/ 1, 1, 3, 10, 10 /),'q200') /)
272
273  type(ctrl_out),dimension(4) :: o_phiSTDlevs   = (/ ctrl_out((/ 1, 1, 3, 10, 10 /),'phi850'), &
274                                                     ctrl_out((/ 1, 1, 3, 10, 10 /),'phi700'), &
275                                                     ctrl_out((/ 1, 1, 3, 10, 10 /),'phi500'), &
276                                                     ctrl_out((/ 1, 1, 3, 10, 10 /),'phi200') /)
277
278
279  type(ctrl_out) :: o_t_oce_sic    = ctrl_out((/ 1, 10, 10, 10, 10 /),'t_oce_sic')
280
281  type(ctrl_out) :: o_weakinv      = ctrl_out((/ 10, 1, 10, 10, 10 /),'weakinv')
282  type(ctrl_out) :: o_dthmin       = ctrl_out((/ 10, 1, 10, 10, 10 /),'dthmin')
283  type(ctrl_out),dimension(4) :: o_u10_srf      = (/ ctrl_out((/ 10, 4, 10, 10, 10 /),'u10_ter'), &
284                                                     ctrl_out((/ 10, 4, 10, 10, 10 /),'u10_lic'), &
285                                                     ctrl_out((/ 10, 4, 10, 10, 10 /),'u10_oce'), &
286                                                     ctrl_out((/ 10, 4, 10, 10, 10 /),'u10_sic') /)
287
288  type(ctrl_out),dimension(4) :: o_v10_srf      = (/ ctrl_out((/ 10, 4, 10, 10, 10 /),'v10_ter'), &
289                                                     ctrl_out((/ 10, 4, 10, 10, 10 /),'v10_lic'), &
290                                                     ctrl_out((/ 10, 4, 10, 10, 10 /),'v10_oce'), &
291                                                     ctrl_out((/ 10, 4, 10, 10, 10 /),'v10_sic') /)
292
293  type(ctrl_out) :: o_cldtau       = ctrl_out((/ 10, 5, 10, 10, 10 /),'cldtau')                     
294  type(ctrl_out) :: o_cldemi       = ctrl_out((/ 10, 5, 10, 10, 10 /),'cldemi')
295  type(ctrl_out) :: o_rh2m         = ctrl_out((/ 10, 5, 10, 10, 10 /),'rh2m')
296  type(ctrl_out) :: o_qsat2m       = ctrl_out((/ 10, 5, 10, 10, 10 /),'qsat2m')
297  type(ctrl_out) :: o_tpot         = ctrl_out((/ 10, 5, 10, 10, 10 /),'tpot')
298  type(ctrl_out) :: o_tpote        = ctrl_out((/ 10, 5, 10, 10, 10 /),'tpote')
299  type(ctrl_out) :: o_tke          = ctrl_out((/ 4, 10, 10, 10, 10 /),'tke ')
300  type(ctrl_out) :: o_tke_max      = ctrl_out((/ 4, 10, 10, 10, 10 /),'tke_max')
301
302  type(ctrl_out),dimension(4) :: o_tke_srf      = (/ ctrl_out((/ 10, 4, 10, 10, 10 /),'tke_ter'), &
303                                                     ctrl_out((/ 10, 4, 10, 10, 10 /),'tke_lic'), &
304                                                     ctrl_out((/ 10, 4, 10, 10, 10 /),'tke_oce'), &
305                                                     ctrl_out((/ 10, 4, 10, 10, 10 /),'tke_sic') /)
306
307  type(ctrl_out),dimension(4) :: o_tke_max_srf  = (/ ctrl_out((/ 10, 4, 10, 10, 10 /),'tke_max_ter'), &
308                                                     ctrl_out((/ 10, 4, 10, 10, 10 /),'tke_max_lic'), &
309                                                     ctrl_out((/ 10, 4, 10, 10, 10 /),'tke_max_oce'), &
310                                                     ctrl_out((/ 10, 4, 10, 10, 10 /),'tke_max_sic') /)
311
312  type(ctrl_out) :: o_kz           = ctrl_out((/ 4, 10, 10, 10, 10 /),'kz')
313  type(ctrl_out) :: o_kz_max       = ctrl_out((/ 4, 10, 10, 10, 10 /),'kz_max')
314  type(ctrl_out) :: o_SWnetOR      = ctrl_out((/ 10, 10, 2, 10, 10 /),'SWnetOR')
315  type(ctrl_out) :: o_SWdownOR     = ctrl_out((/ 10, 10, 2, 10, 10 /),'SWdownOR')
316  type(ctrl_out) :: o_LWdownOR     = ctrl_out((/ 10, 10, 2, 10, 10 /),'LWdownOR')
317
318  type(ctrl_out) :: o_snowl        = ctrl_out((/ 10, 1, 10, 10, 10 /),'snowl')
319  type(ctrl_out) :: o_cape_max     = ctrl_out((/ 10, 1, 10, 10, 10 /),'cape_max')
320  type(ctrl_out) :: o_solldown     = ctrl_out((/ 10, 1, 10, 1, 10 /),'solldown')
321
322  type(ctrl_out) :: o_dtsvdfo      = ctrl_out((/ 10, 10, 10, 1, 10 /),'dtsvdfo')
323  type(ctrl_out) :: o_dtsvdft      = ctrl_out((/ 10, 10, 10, 1, 10 /),'dtsvdft')
324  type(ctrl_out) :: o_dtsvdfg      = ctrl_out((/ 10, 10, 10, 1, 10 /),'dtsvdfg')
325  type(ctrl_out) :: o_dtsvdfi      = ctrl_out((/ 10, 10, 10, 1, 10 /),'dtsvdfi')
326  type(ctrl_out) :: o_rugs         = ctrl_out((/ 10, 10, 10, 1, 1 /),'rugs')
327
328  type(ctrl_out) :: o_topswad      = ctrl_out((/ 4, 10, 10, 10, 10 /),'topswad')
329  type(ctrl_out) :: o_topswai      = ctrl_out((/ 4, 10, 10, 10, 10 /),'topswai')
330  type(ctrl_out) :: o_solswad      = ctrl_out((/ 4, 10, 10, 10, 10 /),'solswad')
331  type(ctrl_out) :: o_solswai      = ctrl_out((/ 4, 10, 10, 10, 10 /),'solswai')
332!!!!!!!!!!!!!!!!!!!!!! 3D !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
333  type(ctrl_out) :: o_lwcon        = ctrl_out((/ 2, 5, 10, 10, 1 /),'lwcon')
334  type(ctrl_out) :: o_iwcon        = ctrl_out((/ 2, 5, 10, 10, 10 /),'iwcon')
335  type(ctrl_out) :: o_temp         = ctrl_out((/ 2, 3, 4, 1, 1 /),'temp')
336  type(ctrl_out) :: o_theta        = ctrl_out((/ 2, 3, 4, 1, 1 /),'theta')
337  type(ctrl_out) :: o_ovap         = ctrl_out((/ 2, 3, 4, 1, 1 /),'ovap')
338  type(ctrl_out) :: o_ovapinit         = ctrl_out((/ 2, 3, 4, 1, 1 /),'ovapinit')
339  type(ctrl_out) :: o_wvapp        = ctrl_out((/ 2, 10, 10, 10, 10 /),'wvapp')
340  type(ctrl_out) :: o_geop         = ctrl_out((/ 2, 3, 10, 1, 1 /),'geop')
341  type(ctrl_out) :: o_vitu         = ctrl_out((/ 2, 3, 4, 1, 1 /),'vitu')
342  type(ctrl_out) :: o_vitv         = ctrl_out((/ 2, 3, 4, 1, 1 /),'vitv')
343  type(ctrl_out) :: o_vitw         = ctrl_out((/ 2, 3, 10, 10, 1 /),'vitw')
344  type(ctrl_out) :: o_pres         = ctrl_out((/ 2, 3, 10, 1, 1 /),'pres')
345  type(ctrl_out) :: o_rneb         = ctrl_out((/ 2, 5, 10, 10, 1 /),'rneb')
346  type(ctrl_out) :: o_rnebcon      = ctrl_out((/ 2, 5, 10, 10, 1 /),'rnebcon')
347  type(ctrl_out) :: o_rhum         = ctrl_out((/ 2, 10, 10, 10, 10 /),'rhum')
348  type(ctrl_out) :: o_ozone        = ctrl_out((/ 2, 10, 10, 10, 10 /),'ozone')
349  type(ctrl_out) :: o_upwd         = ctrl_out((/ 2, 10, 10, 10, 10 /),'upwd')
350  type(ctrl_out) :: o_dtphy        = ctrl_out((/ 2, 10, 10, 10, 1 /),'dtphy')
351  type(ctrl_out) :: o_dqphy        = ctrl_out((/ 2, 10, 10, 10, 1 /),'dqphy')
352  type(ctrl_out) :: o_pr_con_l     = ctrl_out((/ 2, 10, 10, 10, 10 /),'pr_con_l')
353  type(ctrl_out) :: o_pr_con_i     = ctrl_out((/ 2, 10, 10, 10, 10 /),'pr_con_i')
354  type(ctrl_out) :: o_pr_lsc_l     = ctrl_out((/ 2, 10, 10, 10, 10 /),'pr_lsc_l')
355  type(ctrl_out) :: o_pr_lsc_i     = ctrl_out((/ 2, 10, 10, 10, 10 /),'pr_lsc_i')
356!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
357
358  type(ctrl_out),dimension(4) :: o_albe_srf     = (/ ctrl_out((/ 3, 4, 10, 1, 10 /),'albe_ter'), &
359                                                     ctrl_out((/ 3, 4, 10, 1, 10 /),'albe_lic'), &
360                                                     ctrl_out((/ 3, 4, 10, 1, 10 /),'albe_oce'), &
361                                                     ctrl_out((/ 3, 4, 10, 1, 10 /),'albe_sic') /)
362
363  type(ctrl_out),dimension(4) :: o_ages_srf     = (/ ctrl_out((/ 3, 10, 10, 10, 10 /),'ages_ter'), &
364                                                     ctrl_out((/ 3, 10, 10, 10, 10 /),'ages_lic'), &
365                                                     ctrl_out((/ 3, 10, 10, 10, 10 /),'ages_oce'), &
366                                                     ctrl_out((/ 3, 10, 10, 10, 10 /),'ages_sic') /)
367
368  type(ctrl_out),dimension(4) :: o_rugs_srf     = (/ ctrl_out((/ 3, 4, 10, 1, 10 /),'rugs_ter'), &
369                                                     ctrl_out((/ 3, 4, 10, 1, 10 /),'rugs_lic'), &
370                                                     ctrl_out((/ 3, 4, 10, 1, 10 /),'rugs_oce'), &
371                                                     ctrl_out((/ 3, 4, 10, 1, 10 /),'rugs_sic') /)
372
373  type(ctrl_out) :: o_albs         = ctrl_out((/ 3, 10, 10, 1, 10 /),'albs')
374  type(ctrl_out) :: o_albslw       = ctrl_out((/ 3, 10, 10, 1, 10 /),'albslw')
375
376  type(ctrl_out) :: o_clwcon       = ctrl_out((/ 4, 10, 10, 10, 10 /),'clwcon')
377  type(ctrl_out) :: o_Ma           = ctrl_out((/ 4, 10, 10, 10, 10 /),'Ma')
378  type(ctrl_out) :: o_dnwd         = ctrl_out((/ 4, 10, 10, 10, 10 /),'dnwd')
379  type(ctrl_out) :: o_dnwd0        = ctrl_out((/ 4, 10, 10, 10, 10 /),'dnwd0')
380  type(ctrl_out) :: o_dtdyn        = ctrl_out((/ 4, 10, 10, 10, 1 /),'dtdyn')
381  type(ctrl_out) :: o_dqdyn        = ctrl_out((/ 4, 10, 10, 10, 1 /),'dqdyn')
382  type(ctrl_out) :: o_dudyn        = ctrl_out((/ 4, 10, 10, 10, 1 /),'dudyn')  !AXC
383  type(ctrl_out) :: o_dvdyn        = ctrl_out((/ 4, 10, 10, 10, 1 /),'dvdyn')  !AXC
384  type(ctrl_out) :: o_dtcon        = ctrl_out((/ 4, 5, 10, 10, 10 /),'dtcon')
385  type(ctrl_out) :: o_ducon        = ctrl_out((/ 4, 10, 10, 10, 10 /),'ducon')
386  type(ctrl_out) :: o_dqcon        = ctrl_out((/ 4, 5, 10, 10, 10 /),'dqcon')
387  type(ctrl_out) :: o_dtwak        = ctrl_out((/ 4, 5, 10, 10, 10 /),'dtwak')
388  type(ctrl_out) :: o_dqwak        = ctrl_out((/ 4, 5, 10, 10, 10 /),'dqwak')
389  type(ctrl_out) :: o_wake_h       = ctrl_out((/ 4, 5, 10, 10, 10 /),'wake_h')
390  type(ctrl_out) :: o_wake_s       = ctrl_out((/ 4, 5, 10, 10, 10 /),'wake_s')
391  type(ctrl_out) :: o_wake_deltat  = ctrl_out((/ 4, 5, 10, 10, 10 /),'wake_deltat')
392  type(ctrl_out) :: o_wake_deltaq  = ctrl_out((/ 4, 5, 10, 10, 10 /),'wake_deltaq')
393  type(ctrl_out) :: o_wake_omg     = ctrl_out((/ 4, 5, 10, 10, 10 /),'wake_omg')
394  type(ctrl_out) :: o_Vprecip      = ctrl_out((/ 10, 10, 10, 10, 10 /),'Vprecip')
395  type(ctrl_out) :: o_ftd          = ctrl_out((/ 4, 5, 10, 10, 10 /),'ftd')
396  type(ctrl_out) :: o_fqd          = ctrl_out((/ 4, 5, 10, 10, 10 /),'fqd')
397  type(ctrl_out) :: o_dtlsc        = ctrl_out((/ 4, 10, 10, 10, 10 /),'dtlsc')
398  type(ctrl_out) :: o_dtlschr      = ctrl_out((/ 4, 10, 10, 10, 10 /),'dtlschr')
399  type(ctrl_out) :: o_dqlsc        = ctrl_out((/ 4, 10, 10, 10, 10 /),'dqlsc')
400  type(ctrl_out) :: o_dtvdf        = ctrl_out((/ 4, 10, 10, 1, 10 /),'dtvdf')
401  type(ctrl_out) :: o_dqvdf        = ctrl_out((/ 4, 10, 10, 1, 10 /),'dqvdf')
402  type(ctrl_out) :: o_dteva        = ctrl_out((/ 4, 10, 10, 10, 10 /),'dteva')
403  type(ctrl_out) :: o_dqeva        = ctrl_out((/ 4, 10, 10, 10, 10 /),'dqeva')
404  type(ctrl_out) :: o_ptconv       = ctrl_out((/ 4, 10, 10, 10, 10 /),'ptconv')
405  type(ctrl_out) :: o_ratqs        = ctrl_out((/ 4, 10, 10, 10, 10 /),'ratqs')
406  type(ctrl_out) :: o_dtthe        = ctrl_out((/ 4, 10, 10, 10, 10 /),'dtthe')
407  type(ctrl_out) :: o_f_th         = ctrl_out((/ 4, 10, 10, 10, 10 /),'f_th')
408  type(ctrl_out) :: o_e_th         = ctrl_out((/ 4, 10, 10, 10, 10 /),'e_th')
409  type(ctrl_out) :: o_w_th         = ctrl_out((/ 4, 10, 10, 10, 10 /),'w_th')
410  type(ctrl_out) :: o_lambda_th    = ctrl_out((/ 4, 10, 10, 10, 10 /),'lambda_th')
411  type(ctrl_out) :: o_q_th         = ctrl_out((/ 4, 10, 10, 10, 10 /),'q_th')
412  type(ctrl_out) :: o_a_th         = ctrl_out((/ 4, 10, 10, 10, 10 /),'a_th')
413  type(ctrl_out) :: o_d_th         = ctrl_out((/ 4, 10, 10, 10, 10 /),'d_th')
414  type(ctrl_out) :: o_f0_th        = ctrl_out((/ 4, 10, 10, 10, 10 /),'f0_th')
415  type(ctrl_out) :: o_zmax_th      = ctrl_out((/ 4, 10, 10, 10, 10 /),'zmax_th')
416  type(ctrl_out) :: o_dqthe        = ctrl_out((/ 4, 10, 10, 10, 1 /),'dqthe')
417  type(ctrl_out) :: o_dtajs        = ctrl_out((/ 4, 10, 10, 10, 10 /),'dtajs')
418  type(ctrl_out) :: o_dqajs        = ctrl_out((/ 4, 10, 10, 10, 10 /),'dqajs')
419  type(ctrl_out) :: o_dtswr        = ctrl_out((/ 4, 10, 10, 10, 1 /),'dtswr')
420  type(ctrl_out) :: o_dtsw0        = ctrl_out((/ 4, 10, 10, 10, 10 /),'dtsw0')
421  type(ctrl_out) :: o_dtlwr        = ctrl_out((/ 4, 10, 10, 10, 1 /),'dtlwr')
422  type(ctrl_out) :: o_dtlw0        = ctrl_out((/ 4, 10, 10, 10, 10 /),'dtlw0')
423  type(ctrl_out) :: o_dtec         = ctrl_out((/ 4, 10, 10, 10, 10 /),'dtec')
424  type(ctrl_out) :: o_duvdf        = ctrl_out((/ 4, 10, 10, 10, 10 /),'duvdf')
425  type(ctrl_out) :: o_dvvdf        = ctrl_out((/ 4, 10, 10, 10, 10 /),'dvvdf')
426  type(ctrl_out) :: o_duoro        = ctrl_out((/ 4, 10, 10, 10, 10 /),'duoro')
427  type(ctrl_out) :: o_dvoro        = ctrl_out((/ 4, 10, 10, 10, 10 /),'dvoro')
428  type(ctrl_out) :: o_dulif        = ctrl_out((/ 4, 10, 10, 10, 10 /),'dulif')
429  type(ctrl_out) :: o_dvlif        = ctrl_out((/ 4, 10, 10, 10, 10 /),'dvlif')
430
431! Attention a refaire correctement
432  type(ctrl_out),dimension(2) :: o_trac         = (/ ctrl_out((/ 4, 10, 10, 10, 10 /),'trac01'), &
433                                                     ctrl_out((/ 4, 10, 10, 10, 10 /),'trac02') /)
434    CONTAINS
435
436!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
437!!!!!!!!! Ouverture des fichier et definition des variable de sortie !!!!!!!!
438!! histbeg, histvert et histdef
439!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
440 
441  SUBROUTINE phys_output_open(jjmp1,nlevSTD,clevSTD,nbteta, &
442                              ctetaSTD,dtime, presnivs, ok_veget, &
443                              type_ocean, iflag_pbl,ok_mensuel,ok_journe, &
444                              ok_hf,ok_instan,ok_LES,ok_ade,ok_aie)   
445
446  USE iophy
447  USE dimphy
448  USE infotrac
449  USE ioipsl
450  USE mod_phys_lmdz_para
451
452  IMPLICIT NONE
453  include "dimensions.h"
454  include "temps.h"
455  include "indicesol.h"
456  include "clesphys.h"
457  include "thermcell.h"
458
459  integer                               :: jjmp1
460  integer                               :: nbteta, nlevSTD, radpas
461  logical                               :: ok_mensuel, ok_journe, ok_hf, ok_instan
462  logical                               :: ok_LES,ok_ade,ok_aie
463  real                                  :: dtime
464  integer                               :: idayref
465  real                                  :: zjulian
466  real, dimension(klev)                 :: presnivs
467  character(len=4), dimension(nlevSTD)  :: clevSTD
468  integer                               :: nsrf, k, iq, iiq, iff, i, j, ilev
469  logical                               :: ok_veget
470  integer                               :: iflag_pbl
471  CHARACTER(len=4)                      :: bb2
472  CHARACTER(len=2)                      :: bb3
473  character(len=6)                      :: type_ocean
474  CHARACTER(len=3)                      :: ctetaSTD(nbteta)
475  real, dimension(nfiles)               :: ecrit_files
476  CHARACTER(len=20), dimension(nfiles)  :: name_files
477  INTEGER, dimension(iim*jjmp1)         ::  ndex2d
478  INTEGER, dimension(iim*jjmp1*klev)    :: ndex3d
479  integer                               :: imin_ins, imax_ins
480  integer                               :: jmin_ins, jmax_ins
481  CHARACTER(len=20), dimension(nfiles)  :: type_ecri_files
482
483!!!!!!!!!! stockage dans une region limitee pour chaque fichier !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
484!                 entre [lonmin_reg,lonmax_reg] et [latmin_reg,latmax_reg]
485
486  logical, dimension(nfiles), save  :: ok_reglim         = (/ .false., .false., .false., .false., .true. /)
487  real, dimension(nfiles), save     :: lonmin_reg        = (/ 0., -45., 0., 0., -162. /)
488  real, dimension(nfiles), save     :: lonmax_reg        = (/ 90., 45., 90., 90., -144. /)
489  real, dimension(nfiles), save     :: latmin_reg        = (/ 0., -45., 0., 0., 7. /)
490  real, dimension(nfiles), save     :: latmax_reg        = (/ 90., 90., 90., 90., 21. /)
491
492   levmax = (/ klev, klev, klev, klev, klev /)
493
494   name_files(1) = 'histmth'
495   name_files(2) = 'histday'
496   name_files(3) = 'histhf'
497   name_files(4) = 'histins'
498   name_files(5) = 'histLES'
499
500   type_ecri_files(1) = 'ave(X)'
501   type_ecri_files(2) = 'ave(X)'
502   type_ecri_files(3) = 'inst(X)'
503   type_ecri_files(4) = 'inst(X)'
504   type_ecri_files(5) = 'ave(X)'
505
506   clef_files(1) = ok_mensuel
507   clef_files(2) = ok_journe
508   clef_files(3) = ok_hf
509   clef_files(4) = ok_instan
510   clef_files(5) = ok_LES
511
512   lev_files(1) = lev_histmth
513   lev_files(2) = lev_histday
514   lev_files(3) = lev_histhf
515   lev_files(4) = 1
516   lev_files(5) = 1
517
518   ecrit_files(1) = ecrit_mth
519   ecrit_files(2) = ecrit_day
520   ecrit_files(3) = ecrit_hf
521   ecrit_files(4) = ecrit_ins
522   ecrit_files(5) = ecrit_LES
523 
524!! Lectures des parametres de sorties dans physiq.def
525   call getin('phys_out_regfkey',ok_reglim)
526   call getin('phys_out_lonmin',lonmin_reg)
527   call getin('phys_out_lonmax',lonmax_reg)
528   call getin('phys_out_latmin',latmin_reg)
529   call getin('phys_out_latmax',latmax_reg)
530   call getin('phys_out_levmin',levmin)
531   call getin('phys_out_levmax',levmax)
532   call getin('phys_out_filenames',name_files)
533   call getin('phys_out_filetypes',type_ecri_files)
534   call getin('phys_out_filekeys',clef_files)
535   call getin('phys_out_filelevels',lev_files)
536   call getin('phys_out_filetimesteps',ecrit_files)
537
538   type_ecri(:) = type_ecri_files(:)
539
540!!!!!!!!!!!!!!!!!!!!!!! Boucle sur les fichiers !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
541! Appel de histbeg et histvert pour creer le fichier et les niveaux verticaux !!
542! Appel des histbeg pour definir les variables (nom, moy ou inst, freq de sortie ..
543!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
544
545 zdtime = dtime         ! Frequence ou l on moyenne
546
547 DO iff=1,nfiles
548
549    IF (clef_files(iff)) THEN
550     
551      zoutm(iff) = ecrit_files(iff) ! Frequence ou l on ecrit
552
553      idayref = day_ref
554      CALL ymds2ju(annee_ref, 1, idayref, 0.0, zjulian)
555
556!!!!!!!!!!!!!!!!! Traitement dans le cas ou l'on veut stocker sur un domaine limite !!
557!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
558     if (ok_reglim(iff)) then
559
560        imin_ins=1
561        imax_ins=iim
562        jmin_ins=1
563        jmax_ins=jjmp1
564
565! correction abderr        do i=1,iim-1
566        do i=1,iim
567           print*,'io_lon(i)=',io_lon(i)
568           if (io_lon(i).le.lonmin_reg(iff)) imin_ins=i
569           if (io_lon(i).le.lonmax_reg(iff)) imax_ins=i
570        enddo
571
572        do j=1,jjmp1-1
573            print*,'io_lat(j)=',io_lat(j)
574            if (io_lat(j).ge.latmin_reg(iff)) jmax_ins=j+1
575            if (io_lat(j).ge.latmax_reg(iff)) jmin_ins=j
576        enddo
577
578         print*,'On stoke le fichier hist sur, ', &
579         imin_ins,imax_ins,jmin_ins,jmax_ins
580         print*,'On stoke le fichier instantanne sur, ', &
581         io_lon(imin_ins),io_lon(imax_ins), &
582         io_lat(jmin_ins),io_lat(jmax_ins)
583
584 CALL histbeg(name_files(iff),iim,io_lon,jjmp1,io_lat, &
585              imin_ins,imax_ins-imin_ins+1, &
586              jmin_ins,jmax_ins-jmin_ins+1, &
587              itau_phy,zjulian,dtime,nhorim(iff),nid_files(iff))
588!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
589       else
590 CALL histbeg_phy(name_files(iff),itau_phy,zjulian,dtime,nhorim(iff),nid_files(iff))
591       endif
592 
593      CALL histvert(nid_files(iff), "presnivs", "Vertical levels", "mb", &
594           levmax(iff) - levmin(iff) + 1, &
595           presnivs(levmin(iff):levmax(iff))/100., nvertm(iff))
596
597!!!!!!!!!!!!! Traitement des champs 3D pour histhf !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
598!!!!!!!!!!!!!!! A Revoir plus tard !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
599!          IF (iff.eq.3.and.lev_files(iff).ge.4) THEN
600!          CALL histbeg_phy("histhf3d",itau_phy, &
601!     &                     zjulian, dtime, &
602!     &                     nhorim, nid_hf3d)
603
604!         CALL histvert(nid_hf3d, "presnivs", &
605!     &                 "Vertical levels", "mb", &
606!     &                 klev, presnivs/100., nvertm)
607!          ENDIF
608
609!!! Champs 1D !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
610 CALL histdef2d(iff,o_phis%flag,o_phis%name,"Surface geop.height", "m2/s2")
611   type_ecri(1) = 'once'
612   type_ecri(2) = 'once'
613   type_ecri(3) = 'once'
614   type_ecri(4) = 'once'
615   type_ecri(5) = 'once'
616 CALL histdef2d(iff,o_aire%flag,o_aire%name,"Grid area", "-")
617 CALL histdef2d(iff,o_contfracATM%flag,o_contfracATM%name,"% sfce ter+lic", "-")
618   type_ecri(:) = type_ecri_files(:)
619
620!!! Champs 2D !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
621 CALL histdef2d(iff,o_contfracOR%flag,o_contfracOR%name,"% sfce terre OR", "-" )
622 CALL histdef2d(iff,o_aireTER%flag,o_aireTER%name,"Grid area CONT", "-" )
623 CALL histdef2d(iff,o_flat%flag,o_flat%name, "Latent heat flux", "W/m2")
624 CALL histdef2d(iff,o_slp%flag,o_slp%name, "Sea Level Pressure", "Pa" )
625 CALL histdef2d(iff,o_tsol%flag,o_tsol%name, "Surface Temperature", "K")
626 CALL histdef2d(iff,o_t2m%flag,o_t2m%name, "Temperature 2m", "K" )
627   type_ecri(1) = 't_min(X)'
628   type_ecri(2) = 't_min(X)'
629   type_ecri(3) = 't_min(X)'
630   type_ecri(4) = 't_min(X)'
631   type_ecri(5) = 't_min(X)'
632 CALL histdef2d(iff,o_t2m_min%flag,o_t2m_min%name, "Temp 2m min", "K" )
633   type_ecri(1) = 't_max(X)'
634   type_ecri(2) = 't_max(X)'
635   type_ecri(3) = 't_max(X)'
636   type_ecri(4) = 't_max(X)'
637   type_ecri(5) = 't_max(X)'
638 CALL histdef2d(iff,o_t2m_max%flag,o_t2m_max%name, "Temp 2m max", "K" )
639   type_ecri(:) = type_ecri_files(:)
640 CALL histdef2d(iff,o_wind10m%flag,o_wind10m%name, "10-m wind speed", "m/s")
641 CALL histdef2d(iff,o_wind10max%flag,o_wind10max%name, "10m wind speed max", "m/s")
642 CALL histdef2d(iff,o_sicf%flag,o_sicf%name, "Sea-ice fraction", "-" )
643 CALL histdef2d(iff,o_q2m%flag,o_q2m%name, "Specific humidity 2m", "kg/kg")
644 CALL histdef2d(iff,o_u10m%flag,o_u10m%name, "Vent zonal 10m", "m/s" )
645 CALL histdef2d(iff,o_v10m%flag,o_v10m%name, "Vent meridien 10m", "m/s")
646 CALL histdef2d(iff,o_psol%flag,o_psol%name, "Surface Pressure", "Pa" )
647 CALL histdef2d(iff,o_qsurf%flag,o_qsurf%name, "Surface Air humidity", "kg/kg")
648
649  if (.not. ok_veget) then
650 CALL histdef2d(iff,o_qsol%flag,o_qsol%name, "Soil watter content", "mm" )
651  endif
652
653 CALL histdef2d(iff,o_ndayrain%flag,o_ndayrain%name, "Number of dayrain(liq+sol)", "-")
654 CALL histdef2d(iff,o_precip%flag,o_precip%name, "Precip Totale liq+sol", "kg/(s*m2)" )
655 CALL histdef2d(iff,o_plul%flag,o_plul%name, "Large-scale Precip.", "kg/(s*m2)")
656 CALL histdef2d(iff,o_pluc%flag,o_pluc%name, "Convective Precip.", "kg/(s*m2)")
657 CALL histdef2d(iff,o_snow%flag,o_snow%name, "Snow fall", "kg/(s*m2)" )
658 CALL histdef2d(iff,o_evap%flag,o_evap%name, "Evaporat", "kg/(s*m2)" )
659 CALL histdef2d(iff,o_tops%flag,o_tops%name, "Solar rad. at TOA", "W/m2")
660 CALL histdef2d(iff,o_tops0%flag,o_tops0%name, "CS Solar rad. at TOA", "W/m2")
661 CALL histdef2d(iff,o_topl%flag,o_topl%name, "IR rad. at TOA", "W/m2" )
662 CALL histdef2d(iff,o_topl0%flag,o_topl0%name, "IR rad. at TOA", "W/m2")
663 CALL histdef2d(iff,o_SWupTOA%flag,o_SWupTOA%name, "SWup at TOA", "W/m2")
664 CALL histdef2d(iff,o_SWupTOAclr%flag,o_SWupTOAclr%name, "SWup clear sky at TOA", "W/m2")
665 CALL histdef2d(iff,o_SWdnTOA%flag,o_SWdnTOA%name, "SWdn at TOA", "W/m2" )
666 CALL histdef2d(iff,o_SWdnTOAclr%flag,o_SWdnTOAclr%name, "SWdn clear sky at TOA", "W/m2")
667 CALL histdef2d(iff,o_SWup200%flag,o_SWup200%name, "SWup at 200mb", "W/m2" )
668 CALL histdef2d(iff,o_SWup200clr%flag,o_SWup200clr%name, "SWup clear sky at 200mb", "W/m2")
669 CALL histdef2d(iff,o_SWdn200%flag,o_SWdn200%name, "SWdn at 200mb", "W/m2" )
670 CALL histdef2d(iff,o_SWdn200clr%flag,o_SWdn200clr%name, "SWdn clear sky at 200mb", "W/m2")
671 CALL histdef2d(iff,o_LWup200%flag,o_LWup200%name, "LWup at 200mb", "W/m2")
672 CALL histdef2d(iff,o_LWup200clr%flag,o_LWup200clr%name, "LWup clear sky at 200mb", "W/m2")
673 CALL histdef2d(iff,o_LWdn200%flag,o_LWdn200%name, "LWdn at 200mb", "W/m2")
674 CALL histdef2d(iff,o_LWdn200clr%flag,o_LWdn200clr%name, "LWdn clear sky at 200mb", "W/m2")
675 CALL histdef2d(iff,o_sols%flag,o_sols%name, "Solar rad. at surf.", "W/m2")
676 CALL histdef2d(iff,o_sols0%flag,o_sols0%name, "Solar rad. at surf.", "W/m2")
677 CALL histdef2d(iff,o_soll%flag,o_soll%name, "IR rad. at surface", "W/m2") 
678 CALL histdef2d(iff,o_radsol%flag,o_radsol%name, "Rayonnement au sol", "W/m2")
679 CALL histdef2d(iff,o_soll0%flag,o_soll0%name, "IR rad. at surface", "W/m2")
680 CALL histdef2d(iff,o_SWupSFC%flag,o_SWupSFC%name, "SWup at surface", "W/m2")
681 CALL histdef2d(iff,o_SWupSFCclr%flag,o_SWupSFCclr%name, "SWup clear sky at surface", "W/m2")
682 CALL histdef2d(iff,o_SWdnSFC%flag,o_SWdnSFC%name, "SWdn at surface", "W/m2")
683 CALL histdef2d(iff,o_SWdnSFCclr%flag,o_SWdnSFCclr%name, "SWdn clear sky at surface", "W/m2")
684 CALL histdef2d(iff,o_LWupSFC%flag,o_LWupSFC%name, "Upwd. IR rad. at surface", "W/m2")
685 CALL histdef2d(iff,o_LWdnSFC%flag,o_LWdnSFC%name, "Down. IR rad. at surface", "W/m2")
686 CALL histdef2d(iff,o_LWupSFCclr%flag,o_LWupSFCclr%name, "CS Upwd. IR rad. at surface", "W/m2")
687 CALL histdef2d(iff,o_LWdnSFCclr%flag,o_LWdnSFCclr%name, "Down. CS IR rad. at surface", "W/m2")
688 CALL histdef2d(iff,o_bils%flag,o_bils%name, "Surf. total heat flux", "W/m2")
689 CALL histdef2d(iff,o_sens%flag,o_sens%name, "Sensible heat flux", "W/m2")
690 CALL histdef2d(iff,o_fder%flag,o_fder%name, "Heat flux derivation", "W/m2")
691 CALL histdef2d(iff,o_ffonte%flag,o_ffonte%name, "Thermal flux for snow melting", "W/m2")
692 CALL histdef2d(iff,o_fqcalving%flag,o_fqcalving%name, "Ice Calving", "kg/m2/s")
693 CALL histdef2d(iff,o_fqfonte%flag,o_fqfonte%name, "Land ice melt", "kg/m2/s")
694
695     DO nsrf = 1, nbsrf
696 CALL histdef2d(iff,o_pourc_srf(nsrf)%flag,o_pourc_srf(nsrf)%name,"% "//clnsurf(nsrf),"%")
697 CALL histdef2d(iff,o_fract_srf(nsrf)%flag,o_fract_srf(nsrf)%name,"Fraction "//clnsurf(nsrf),"1")
698 CALL histdef2d(iff,o_taux_srf(nsrf)%flag,o_taux_srf(nsrf)%name,"Zonal wind stress"//clnsurf(nsrf),"Pa")
699 CALL histdef2d(iff,o_tauy_srf(nsrf)%flag,o_tauy_srf(nsrf)%name,"Meridional wind stress "//clnsurf(nsrf),"Pa")
700 CALL histdef2d(iff,o_tsol_srf(nsrf)%flag,o_tsol_srf(nsrf)%name,"Temperature "//clnsurf(nsrf),"K")
701 CALL histdef2d(iff,o_u10m_srf(nsrf)%flag,o_u10m_srf(nsrf)%name,"Vent Zonal 10m "//clnsurf(nsrf),"m/s")
702 CALL histdef2d(iff,o_v10m_srf(nsrf)%flag,o_v10m_srf(nsrf)%name,"Vent meredien 10m "//clnsurf(nsrf),"m/s")
703 CALL histdef2d(iff,o_t2m_srf(nsrf)%flag,o_t2m_srf(nsrf)%name,"Temp 2m "//clnsurf(nsrf),"K")
704 CALL histdef2d(iff,o_sens_srf(nsrf)%flag,o_sens_srf(nsrf)%name,"Sensible heat flux "//clnsurf(nsrf),"W/m2")
705 CALL histdef2d(iff,o_lat_srf(nsrf)%flag,o_lat_srf(nsrf)%name,"Latent heat flux "//clnsurf(nsrf),"W/m2")
706 CALL histdef2d(iff,o_flw_srf(nsrf)%flag,o_flw_srf(nsrf)%name,"LW "//clnsurf(nsrf),"W/m2")
707 CALL histdef2d(iff,o_fsw_srf(nsrf)%flag,o_fsw_srf(nsrf)%name,"SW "//clnsurf(nsrf),"W/m2")
708 CALL histdef2d(iff,o_wbils_srf(nsrf)%flag,o_wbils_srf(nsrf)%name,"Bilan sol "//clnsurf(nsrf),"W/m2" )
709 CALL histdef2d(iff,o_wbilo_srf(nsrf)%flag,o_wbilo_srf(nsrf)%name,"Bilan eau "//clnsurf(nsrf),"kg/(m2*s)")
710  if (iflag_pbl>1 .and. lev_files(iff).gt.10 ) then
711 CALL histdef2d(iff,o_tke_srf(nsrf)%flag,o_tke_srf(nsrf)%name,"Max Turb. Kinetic Energy "//clnsurf(nsrf),"-")
712   type_ecri(1) = 't_max(X)'
713   type_ecri(2) = 't_max(X)'
714   type_ecri(3) = 't_max(X)'
715   type_ecri(4) = 't_max(X)'
716   type_ecri(5) = 't_max(X)'
717 CALL histdef2d(iff,o_tke_max_srf(nsrf)%flag,o_tke_max_srf(nsrf)%name,"Max Turb. Kinetic Energy "//clnsurf(nsrf),"-")
718   type_ecri(:) = type_ecri_files(:)
719  endif
720 CALL histdef2d(iff,o_albe_srf(nsrf)%flag,o_albe_srf(nsrf)%name,"Albedo surf. "//clnsurf(nsrf),"-")
721 CALL histdef2d(iff,o_rugs_srf(nsrf)%flag,o_rugs_srf(nsrf)%name,"Latent heat flux "//clnsurf(nsrf),"W/m2")
722 CALL histdef2d(iff,o_ages_srf(nsrf)%flag,o_ages_srf(nsrf)%name,"Snow age", "day")
723     END DO
724
725 IF (ok_ade) THEN
726  CALL histdef2d(iff,o_topswad%flag,o_topswad%name, "ADE at TOA", "W/m2")
727  CALL histdef2d(iff,o_solswad%flag,o_solswad%name, "ADE at SRF", "W/m2")
728 ENDIF
729
730 IF (ok_aie) THEN
731  CALL histdef2d(iff,o_topswai%flag,o_topswai%name, "AIE at TOA", "W/m2")
732  CALL histdef2d(iff,o_solswai%flag,o_solswai%name, "AIE at SFR", "W/m2")
733 ENDIF
734
735
736 CALL histdef2d(iff,o_albs%flag,o_albs%name, "Surface albedo", "-")
737 CALL histdef2d(iff,o_albslw%flag,o_albslw%name, "Surface albedo LW", "-")
738 CALL histdef2d(iff,o_cdrm%flag,o_cdrm%name, "Momentum drag coef.", "-")
739 CALL histdef2d(iff,o_cdrh%flag,o_cdrh%name, "Heat drag coef.", "-" )
740 CALL histdef2d(iff,o_cldl%flag,o_cldl%name, "Low-level cloudiness", "-")
741 CALL histdef2d(iff,o_cldm%flag,o_cldm%name, "Mid-level cloudiness", "-")
742 CALL histdef2d(iff,o_cldh%flag,o_cldh%name, "High-level cloudiness", "-")
743 CALL histdef2d(iff,o_cldt%flag,o_cldt%name, "Total cloudiness", "%")
744 CALL histdef2d(iff,o_cldq%flag,o_cldq%name, "Cloud liquid water path", "kg/m2")
745 CALL histdef2d(iff,o_lwp%flag,o_lwp%name, "Cloud water path", "kg/m2")
746 CALL histdef2d(iff,o_iwp%flag,o_iwp%name, "Cloud ice water path", "kg/m2" )
747 CALL histdef2d(iff,o_ue%flag,o_ue%name, "Zonal energy transport", "-")
748 CALL histdef2d(iff,o_ve%flag,o_ve%name, "Merid energy transport", "-")
749 CALL histdef2d(iff,o_uq%flag,o_uq%name, "Zonal humidity transport", "-")
750 CALL histdef2d(iff,o_vq%flag,o_vq%name, "Merid humidity transport", "-")
751
752     IF(iflag_con.GE.3) THEN ! sb
753 CALL histdef2d(iff,o_cape%flag,o_cape%name, "Conv avlbl pot ener", "J/kg")
754 CALL histdef2d(iff,o_pbase%flag,o_pbase%name, "Cld base pressure", "mb")
755 CALL histdef2d(iff,o_ptop%flag,o_ptop%name, "Cld top pressure", "mb")
756 CALL histdef2d(iff,o_fbase%flag,o_fbase%name, "Cld base mass flux", "kg/m2/s")
757 CALL histdef2d(iff,o_prw%flag,o_prw%name, "Precipitable water", "kg/m2")
758   type_ecri(1) = 't_max(X)'
759   type_ecri(2) = 't_max(X)'
760   type_ecri(3) = 't_max(X)'
761   type_ecri(4) = 't_max(X)'
762   type_ecri(5) = 't_max(X)'
763 CALL histdef2d(iff,o_cape_max%flag,o_cape_max%name, "CAPE max.", "J/kg")
764   type_ecri(:) = type_ecri_files(:)
765 CALL histdef3d(iff,o_upwd%flag,o_upwd%name, "saturated updraft", "kg/m2/s")
766 CALL histdef3d(iff,o_Ma%flag,o_Ma%name, "undilute adiab updraft", "kg/m2/s")
767 CALL histdef3d(iff,o_dnwd%flag,o_dnwd%name, "saturated downdraft", "kg/m2/s")
768 CALL histdef3d(iff,o_dnwd0%flag,o_dnwd0%name, "unsat. downdraft", "kg/m2/s")
769     ENDIF !iflag_con .GE. 3
770
771 CALL histdef2d(iff,o_s_pblh%flag,o_s_pblh%name, "Boundary Layer Height", "m")
772 CALL histdef2d(iff,o_s_pblt%flag,o_s_pblt%name, "t at Boundary Layer Height", "K")
773 CALL histdef2d(iff,o_s_lcl%flag,o_s_lcl%name, "Condensation level", "m")
774 CALL histdef2d(iff,o_s_capCL%flag,o_s_capCL%name, "Conv avlbl pot enerfor ABL", "J/m2" )
775 CALL histdef2d(iff,o_s_oliqCL%flag,o_s_oliqCL%name, "Liq Water in BL", "kg/m2")
776 CALL histdef2d(iff,o_s_cteiCL%flag,o_s_cteiCL%name, "Instability criteria(ABL)", "K")
777 CALL histdef2d(iff,o_s_therm%flag,o_s_therm%name, "Exces du thermique", "K")
778 CALL histdef2d(iff,o_s_trmb1%flag,o_s_trmb1%name, "deep_cape(HBTM2)", "J/m2")
779 CALL histdef2d(iff,o_s_trmb2%flag,o_s_trmb2%name, "inhibition (HBTM2)", "J/m2")
780 CALL histdef2d(iff,o_s_trmb3%flag,o_s_trmb3%name, "Point Omega (HBTM2)", "m")
781
782! Champs interpolles sur des niveaux de pression
783! iif=1 on ecrit u v w phi sur 850 700 500 200 au niv 1
784! iif=2 on ecrit w et ph 500 seulement au niv 1
785!        et u v sur 850 700 500 200
786! iif=3 on ecrit ph a 500 seulement au niv 1
787!      on ecrit u v t q a 850 700 500 200 au niv 3
788
789   type_ecri(1) = 'inst(X)'
790   type_ecri(2) = 'inst(X)'
791   type_ecri(3) = 'inst(X)'
792   type_ecri(4) = 'inst(X)'
793   type_ecri(5) = 'inst(X)'
794
795! Attention a reverifier
796
797        ilev=0       
798        DO k=1, nlevSTD
799     IF(k.GE.2.AND.k.LE.12) bb2=clevSTD(k)
800!     IF(k.GE.13.AND.k.LE.17) bb3=clevSTD(k)
801     IF(bb2.EQ."850".OR.bb2.EQ."700".OR.bb2.EQ."500".OR.bb2.EQ."200")THEN
802      ilev=ilev+1
803      print*,'ilev bb2 flag name ',ilev,bb2,o_uSTDlevs(ilev)%flag,o_uSTDlevs(ilev)%name
804 CALL histdef2d(iff,o_uSTDlevs(ilev)%flag,o_uSTDlevs(ilev)%name,"Zonal wind "//bb2//"mb", "m/s")
805 CALL histdef2d(iff,o_vSTDlevs(ilev)%flag,o_vSTDlevs(ilev)%name,"Meridional wind "//bb2//"mb", "m/s")
806 CALL histdef2d(iff,o_wSTDlevs(ilev)%flag,o_wSTDlevs(ilev)%name,"Vertical wind "//bb2//"mb", "Pa/s")
807 CALL histdef2d(iff,o_phiSTDlevs(ilev)%flag,o_phiSTDlevs(ilev)%name,"Geopotential "//bb2//"mb", "m")
808 CALL histdef2d(iff,o_qSTDlevs(ilev)%flag,o_qSTDlevs(ilev)%name,"Specific humidity "//bb2//"mb", "kg/kg" )
809 CALL histdef2d(iff,o_tSTDlevs(ilev)%flag,o_tSTDlevs(ilev)%name,"Temperature "//bb2//"mb", "K")
810     ENDIF !(bb2.EQ."850".OR.bb2.EQ."700".OR."500".OR.bb2.EQ."200")
811       ENDDO
812   type_ecri(:) = type_ecri_files(:)
813
814 CALL histdef2d(iff,o_t_oce_sic%flag,o_t_oce_sic%name, "Temp mixte oce-sic", "K")
815
816 IF (type_ocean=='slab') &
817     CALL histdef2d(iff,o_slab_bils%flag, o_slab_bils%name,"Bilan au sol sur ocean slab", "W/m2")
818
819! Couplage conv-CL
820 IF (iflag_con.GE.3) THEN
821    IF (iflag_coupl.EQ.1) THEN
822 CALL histdef2d(iff,o_ale_bl%flag,o_ale_bl%name, "ALE BL", "m2/s2")
823 CALL histdef2d(iff,o_alp_bl%flag,o_alp_bl%name, "ALP BL", "m2/s2")
824    ENDIF
825 ENDIF !(iflag_con.GE.3)
826
827 CALL histdef2d(iff,o_weakinv%flag,o_weakinv%name, "Weak inversion", "-")
828 CALL histdef2d(iff,o_dthmin%flag,o_dthmin%name, "dTheta mini", "K/m")
829 CALL histdef2d(iff,o_rh2m%flag,o_rh2m%name, "Relative humidity at 2m", "%" )
830 CALL histdef2d(iff,o_qsat2m%flag,o_qsat2m%name, "Saturant humidity at 2m", "%")
831 CALL histdef2d(iff,o_tpot%flag,o_tpot%name, "Surface air potential temperature", "K")
832 CALL histdef2d(iff,o_tpote%flag,o_tpote%name, "Surface air equivalent potential temperature", "K")
833 CALL histdef2d(iff,o_SWnetOR%flag,o_SWnetOR%name, "Sfce net SW radiation OR", "W/m2")
834 CALL histdef2d(iff,o_SWdownOR%flag,o_SWdownOR%name, "Sfce incident SW radiation OR", "W/m2")
835 CALL histdef2d(iff,o_LWdownOR%flag,o_LWdownOR%name, "Sfce incident LW radiation OR", "W/m2")
836 CALL histdef2d(iff,o_snowl%flag,o_snowl%name, "Solid Large-scale Precip.", "kg/(m2*s)")
837
838 CALL histdef2d(iff,o_solldown%flag,o_solldown%name, "Down. IR rad. at surface", "W/m2")
839 CALL histdef2d(iff,o_dtsvdfo%flag,o_dtsvdfo%name, "Boundary-layer dTs(o)", "K/s")
840 CALL histdef2d(iff,o_dtsvdft%flag,o_dtsvdft%name, "Boundary-layer dTs(t)", "K/s")
841 CALL histdef2d(iff,o_dtsvdfg%flag,o_dtsvdfg%name, "Boundary-layer dTs(g)", "K/s")
842 CALL histdef2d(iff,o_dtsvdfi%flag,o_dtsvdfi%name, "Boundary-layer dTs(g)", "K/s")
843 CALL histdef2d(iff,o_rugs%flag,o_rugs%name, "rugosity", "-" )
844
845! Champs 3D:
846 CALL histdef3d(iff,o_lwcon%flag,o_lwcon%name, "Cloud liquid water content", "kg/kg")
847 CALL histdef3d(iff,o_iwcon%flag,o_iwcon%name, "Cloud ice water content", "kg/kg")
848 CALL histdef3d(iff,o_temp%flag,o_temp%name, "Air temperature", "K" )
849 CALL histdef3d(iff,o_theta%flag,o_theta%name, "Potential air temperature", "K" )
850 CALL histdef3d(iff,o_ovap%flag,o_ovap%name, "Specific humidity + dqphy", "kg/kg" )
851 CALL histdef3d(iff,o_ovapinit%flag,o_ovapinit%name, "Specific humidity", "kg/kg" )
852 CALL histdef3d(iff,o_geop%flag,o_geop%name, "Geopotential height", "m2/s2")
853 CALL histdef3d(iff,o_vitu%flag,o_vitu%name, "Zonal wind", "m/s" )
854 CALL histdef3d(iff,o_vitv%flag,o_vitv%name, "Meridional wind", "m/s" )
855 CALL histdef3d(iff,o_vitw%flag,o_vitw%name, "Vertical wind", "Pa/s" )
856 CALL histdef3d(iff,o_pres%flag,o_pres%name, "Air pressure", "Pa" )
857 CALL histdef3d(iff,o_rneb%flag,o_rneb%name, "Cloud fraction", "-")
858 CALL histdef3d(iff,o_rnebcon%flag,o_rnebcon%name, "Convective Cloud Fraction", "-")
859 CALL histdef3d(iff,o_rhum%flag,o_rhum%name, "Relative humidity", "-")
860 CALL histdef3d(iff,o_ozone%flag,o_ozone%name, "Ozone concentration", "ppmv")
861 CALL histdef3d(iff,o_dtphy%flag,o_dtphy%name, "Physics dT", "K/s")
862 CALL histdef3d(iff,o_dqphy%flag,o_dqphy%name, "Physics dQ", "(kg/kg)/s")
863 CALL histdef3d(iff,o_cldtau%flag,o_cldtau%name, "Cloud optical thickness", "1")
864 CALL histdef3d(iff,o_cldemi%flag,o_cldemi%name, "Cloud optical emissivity", "1")
865!IM: bug ?? dimensionnement variables (klon,klev+1) pmflxr, pmflxs, prfl, psfl
866! CALL histdef3d(iff,o_pr_con_l%flag,o_pmflxr%name, "Convective precipitation lic", " ")
867! CALL histdef3d(iff,o_pr_con_i%flag,o_pmflxs%name, "Convective precipitation ice", " ")
868! CALL histdef3d(iff,o_pr_lsc_l%flag,o_prfl%name, "Large scale precipitation lic", " ")
869! CALL histdef3d(iff,o_pr_lsc_i%flag,o_psfl%name, "Large scale precipitation ice", " ")
870
871!FH Sorties pour la couche limite
872     if (iflag_pbl>1) then
873 CALL histdef3d(iff,o_tke%flag,o_tke%name, "TKE", "m2/s2")
874   type_ecri(1) = 't_max(X)'
875   type_ecri(2) = 't_max(X)'
876   type_ecri(3) = 't_max(X)'
877   type_ecri(4) = 't_max(X)'
878   type_ecri(5) = 't_max(X)'
879 CALL histdef3d(iff,o_tke_max%flag,o_tke_max%name, "TKE max", "m2/s2")
880   type_ecri(:) = type_ecri_files(:)
881     endif
882
883 CALL histdef3d(iff,o_kz%flag,o_kz%name, "Kz melange", "m2/s")
884   type_ecri(1) = 't_max(X)'
885   type_ecri(2) = 't_max(X)'
886   type_ecri(3) = 't_max(X)'
887   type_ecri(4) = 't_max(X)'
888   type_ecri(5) = 't_max(X)'
889 CALL histdef3d(iff,o_kz_max%flag,o_kz_max%name, "Kz melange max", "m2/s" )
890   type_ecri(:) = type_ecri_files(:)
891 CALL histdef3d(iff,o_clwcon%flag,o_clwcon%name, "Convective Cloud Liquid water content", "kg/kg")
892 CALL histdef3d(iff,o_dtdyn%flag,o_dtdyn%name, "Dynamics dT", "K/s")
893 CALL histdef3d(iff,o_dqdyn%flag,o_dqdyn%name, "Dynamics dQ", "(kg/kg)/s")
894 CALL histdef3d(iff,o_dudyn%flag,o_dudyn%name, "Dynamics dU", "m/s2")
895 CALL histdef3d(iff,o_dvdyn%flag,o_dvdyn%name, "Dynamics dV", "m/s2")
896 CALL histdef3d(iff,o_dtcon%flag,o_dtcon%name, "Convection dT", "K/s")
897 CALL histdef3d(iff,o_ducon%flag,o_ducon%name, "Convection du", "m/s2")
898 CALL histdef3d(iff,o_dqcon%flag,o_dqcon%name, "Convection dQ", "(kg/kg)/s")
899
900! Wakes
901 IF(iflag_con.EQ.3) THEN
902 IF (iflag_wake == 1) THEN
903   CALL histdef2d(iff,o_ale_wk%flag,o_ale_wk%name, "ALE WK", "m2/s2")
904   CALL histdef2d(iff,o_alp_wk%flag,o_alp_wk%name, "ALP WK", "m2/s2")
905   CALL histdef2d(iff,o_ale%flag,o_ale%name, "ALE", "m2/s2")
906   CALL histdef2d(iff,o_alp%flag,o_alp%name, "ALP", "W/m2")
907   CALL histdef2d(iff,o_cin%flag,o_cin%name, "Convective INhibition", "m2/s2")
908   CALL histdef2d(iff,o_wape%flag,o_WAPE%name, "WAPE", "m2/s2")
909   CALL histdef2d(iff,o_wake_h%flag,o_wake_h%name, "wake_h", "-")
910   CALL histdef2d(iff,o_wake_s%flag,o_wake_s%name, "wake_s", "-")
911   CALL histdef3d(iff,o_dtwak%flag,o_dtwak%name, "Wake dT", "K/s")
912   CALL histdef3d(iff,o_dqwak%flag,o_dqwak%name, "Wake dQ", "(kg/kg)/s")
913   CALL histdef3d(iff,o_wake_deltat%flag,o_wake_deltat%name, "wake_deltat", " ")
914   CALL histdef3d(iff,o_wake_deltaq%flag,o_wake_deltaq%name, "wake_deltaq", " ")
915   CALL histdef3d(iff,o_wake_omg%flag,o_wake_omg%name, "wake_omg", " ")
916 ENDIF
917   CALL histdef3d(iff,o_Vprecip%flag,o_Vprecip%name, "precipitation vertical profile", "-")
918   CALL histdef3d(iff,o_ftd%flag,o_ftd%name, "tend temp due aux descentes precip", "-")
919   CALL histdef3d(iff,o_fqd%flag,o_fqd%name,"tend vap eau due aux descentes precip", "-")
920 ENDIF !(iflag_con.EQ.3)
921
922 CALL histdef3d(iff,o_dtlsc%flag,o_dtlsc%name, "Condensation dT", "K/s")
923 CALL histdef3d(iff,o_dtlschr%flag,o_dtlschr%name,"Large-scale condensational heating rate","K/s")
924 CALL histdef3d(iff,o_dqlsc%flag,o_dqlsc%name, "Condensation dQ", "(kg/kg)/s")
925 CALL histdef3d(iff,o_dtvdf%flag,o_dtvdf%name, "Boundary-layer dT", "K/s")
926 CALL histdef3d(iff,o_dqvdf%flag,o_dqvdf%name, "Boundary-layer dQ", "(kg/kg)/s")
927 CALL histdef3d(iff,o_dteva%flag,o_dteva%name, "Reevaporation dT", "K/s")
928 CALL histdef3d(iff,o_dqeva%flag,o_dqeva%name, "Reevaporation dQ", "(kg/kg)/s")
929 CALL histdef3d(iff,o_ptconv%flag,o_ptconv%name, "POINTS CONVECTIFS", " ")
930 CALL histdef3d(iff,o_ratqs%flag,o_ratqs%name, "RATQS", " ")
931 CALL histdef3d(iff,o_dtthe%flag,o_dtthe%name, "Dry adjust. dT", "K/s")
932
933if(iflag_thermals.gt.1) THEN
934 CALL histdef3d(iff,o_f_th%flag,o_f_th%name, "Thermal plume mass flux", "K/s")
935 CALL histdef3d(iff,o_e_th%flag,o_e_th%name,"Thermal plume entrainment","K/s")
936 CALL histdef3d(iff,o_w_th%flag,o_w_th%name,"Thermal plume vertical velocity","m/s")
937 CALL histdef3d(iff,o_lambda_th%flag,o_lambda_th%name,"Thermal plume vertical velocity","m/s")
938 CALL histdef3d(iff,o_q_th%flag,o_q_th%name, "Thermal plume total humidity", "kg/kg")
939 CALL histdef3d(iff,o_a_th%flag,o_a_th%name, "Thermal plume fraction", "")
940 CALL histdef3d(iff,o_d_th%flag,o_d_th%name, "Thermal plume detrainment", "K/s")
941endif !iflag_thermals.gt.1
942 CALL histdef2d(iff,o_f0_th%flag,o_f0_th%name, "Thermal closure mass flux", "K/s")
943 CALL histdef2d(iff,o_zmax_th%flag,o_zmax_th%name, "Thermal plume height", "K/s")
944 CALL histdef3d(iff,o_dqthe%flag,o_dqthe%name, "Dry adjust. dQ", "(kg/kg)/s")
945 CALL histdef3d(iff,o_dtajs%flag,o_dtajs%name, "Dry adjust. dT", "K/s")
946 CALL histdef3d(iff,o_dqajs%flag,o_dqajs%name, "Dry adjust. dQ", "(kg/kg)/s")
947 CALL histdef3d(iff,o_dtswr%flag,o_dtswr%name, "SW radiation dT", "K/s")
948 CALL histdef3d(iff,o_dtsw0%flag,o_dtsw0%name, "CS SW radiation dT", "K/s")
949 CALL histdef3d(iff,o_dtlwr%flag,o_dtlwr%name, "LW radiation dT", "K/s")
950 CALL histdef3d(iff,o_dtlw0%flag,o_dtlw0%name, "CS LW radiation dT", "K/s")
951 CALL histdef3d(iff,o_dtec%flag,o_dtec%name, "Cinetic dissip dT", "K/s")
952 CALL histdef3d(iff,o_duvdf%flag,o_duvdf%name, "Boundary-layer dU", "m/s2")
953 CALL histdef3d(iff,o_dvvdf%flag,o_dvvdf%name, "Boundary-layer dV", "m/s2")
954
955     IF (ok_orodr) THEN
956 CALL histdef3d(iff,o_duoro%flag,o_duoro%name, "Orography dU", "m/s2")
957 CALL histdef3d(iff,o_dvoro%flag,o_dvoro%name, "Orography dV", "m/s2")
958     ENDIF
959
960     IF (ok_orolf) THEN
961 CALL histdef3d(iff,o_dulif%flag,o_dulif%name, "Orography dU", "m/s2")
962 CALL histdef3d(iff,o_dvlif%flag,o_dvlif%name, "Orography dV", "m/s2")
963     ENDIF
964
965      if (nqtot>=3) THEN
966!Attention    DO iq=3,nqtot
967    DO iq=3,4 
968       iiq=niadv(iq)
969! CALL histdef3d (iff, o_trac%flag,'o_'//tnom(iq)%name,ttext(iiq), "-" )
970  CALL histdef3d (iff, o_trac(iq-2)%flag,o_trac(iq-2)%name,ttext(iiq), "-" )
971    ENDDO
972      endif
973
974        CALL histend(nid_files(iff))
975
976         ndex2d = 0
977         ndex3d = 0
978
979         ENDIF ! clef_files
980
981         ENDDO !
982      end subroutine phys_output_open
983
984      SUBROUTINE histdef2d (iff,flag_var,nomvar,titrevar,unitvar)
985     
986       use ioipsl
987       USE dimphy
988       USE mod_phys_lmdz_para
989
990       IMPLICIT NONE
991       
992       include "dimensions.h"
993       include "temps.h"
994       include "indicesol.h"
995       include "clesphys.h"
996
997       integer                          :: iff
998       integer, dimension(nfiles)       :: flag_var
999       character(len=20)                 :: nomvar
1000       character(len=*)                 :: titrevar
1001       character(len=*)                 :: unitvar
1002
1003       real zstophym
1004
1005       if (type_ecri(iff)=='inst(X)') then
1006         zstophym=zoutm(iff)
1007       else
1008         zstophym=zdtime
1009       endif
1010
1011! Appel a la lecture des noms et niveau d'ecriture des variables dans output.def
1012       call conf_physoutputs(nomvar,flag_var)
1013       
1014       if ( flag_var(iff)<=lev_files(iff) ) then
1015 call histdef (nid_files(iff),nomvar,titrevar,unitvar, &
1016               iim,jj_nb,nhorim(iff), 1,1,1, -99, 32, &
1017               type_ecri(iff), zstophym,zoutm(iff))               
1018       endif                     
1019      end subroutine histdef2d
1020
1021      SUBROUTINE histdef3d (iff,flag_var,nomvar,titrevar,unitvar)
1022
1023       use ioipsl
1024       USE dimphy
1025       USE mod_phys_lmdz_para
1026
1027       IMPLICIT NONE
1028
1029       include "dimensions.h"
1030       include "temps.h"
1031       include "indicesol.h"
1032       include "clesphys.h"
1033
1034       integer                          :: iff
1035       integer, dimension(nfiles)       :: flag_var
1036       character(len=20)                 :: nomvar
1037       character(len=*)                 :: titrevar
1038       character(len=*)                 :: unitvar
1039
1040       real zstophym
1041
1042! Appel a la lecture des noms et niveau d'ecriture des variables dans output.def
1043       call conf_physoutputs(nomvar,flag_var)
1044
1045       if (type_ecri(iff)=='inst(X)') then
1046         zstophym=zoutm(iff)
1047       else
1048         zstophym=zdtime
1049       endif
1050
1051       if ( flag_var(iff)<=lev_files(iff) ) then
1052          call histdef (nid_files(iff), nomvar, titrevar, unitvar, &
1053               iim, jj_nb, nhorim(iff), klev, levmin(iff), &
1054               levmax(iff)-levmin(iff)+1, nvertm(iff), 32, type_ecri(iff), &
1055               zstophym, zoutm(iff))
1056       endif
1057      end subroutine histdef3d
1058
1059      SUBROUTINE conf_physoutputs(nam_var,flag_var)
1060!!! Lecture des noms et niveau de sortie des variables dans output.def
1061!   en utilisant les routines getin de IOIPSL 
1062       use ioipsl
1063
1064       IMPLICIT NONE
1065
1066       include 'iniprint.h'
1067
1068       character(len=20)                :: nam_var
1069       integer, dimension(nfiles)      :: flag_var
1070       integer, dimension(nfiles),save :: flag_var_omp
1071       character(len=20),save           :: nam_var_omp
1072
1073        flag_var_omp = flag_var
1074        nam_var_omp = nam_var
1075        IF(prt_level>10) WRITE(lunout,*)'Avant getin: nam_var flag_var ',nam_var,flag_var(:)
1076        call getin('flag_'//nam_var,flag_var_omp)
1077        flag_var = flag_var_omp
1078        call getin('name_'//nam_var,nam_var_omp)
1079        nam_var=nam_var_omp
1080       
1081        IF(prt_level>10) WRITE(lunout,*)'Apres getin: nam_var flag_var ',nam_var,flag_var(:)
1082
1083      END SUBROUTINE conf_physoutputs
1084
1085END MODULE phys_output_mod
1086
Note: See TracBrowser for help on using the repository browser.