SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
modi_gltools_chkout.F90
Go to the documentation of this file.
1 !SFX_LIC Copyright 1994-2014 CNRS, Meteo-France and Universite Paul Sabatier
2 !SFX_LIC This is part of the SURFEX software governed by the CeCILL-C licence
3 !SFX_LIC version 1. See LICENSE, CeCILL-C_V1-en.txt and CeCILL-C_V1-fr.txt
4 !SFX_LIC for details. version 1.
5 !GLT_LIC The GELATO model is a seaice model used in stand-alone or embedded mode.
6 !GLT_LIC It has been developed by Meteo-France. The holder of GELATO is Meteo-France.
7 !GLT_LIC
8 !GLT_LIC This software is governed by the CeCILL-C license under French law and biding
9 !GLT_LIC by the rules of distribution of free software. See the CeCILL-C_V1-en.txt
10 !GLT_LIC (English) and CeCILL-C_V1-fr.txt (French) for details. The CeCILL is a free
11 !GLT_LIC software license, explicitly compatible with the GNU GPL
12 !GLT_LIC (see http://www.gnu.org/licenses/license-list.en.html#CeCILL)
13 !GLT_LIC
14 !GLT_LIC The CeCILL-C licence agreement grants users the right to modify and re-use the
15 !GLT_LIC software governed by this free software license. The exercising of this right
16 !GLT_LIC is conditional upon the obligation to make available to the community the
17 !GLT_LIC modifications made to the source code of the software so as to contribute to
18 !GLT_LIC its evolution.
19 !GLT_LIC
20 !GLT_LIC In consideration of access to the source code and the rights to copy, modify
21 !GLT_LIC and redistribute granted by the license, users are provided only with a limited
22 !GLT_LIC warranty and the software's author, the holder of the economic rights, and the
23 !GLT_LIC successive licensors only have limited liability. In this respect, the risks
24 !GLT_LIC associated with loading, using, modifying and/or developing or reproducing the
25 !GLT_LIC software by the user are brought to the user's attention, given its Free
26 !GLT_LIC Software status, which may make it complicated to use, with the result that its
27 !GLT_LIC use is reserved for developers and experienced professionals having in-depth
28 !GLT_LIC computer knowledge. Users are therefore encouraged to load and test the
29 !GLT_LIC suitability of the software as regards their requirements in conditions enabling
30 !GLT_LIC the security of their systems and/or data to be ensured and, more generally, to
31 !GLT_LIC use and operate it in the same conditions of security.
32 !GLT_LIC
33 !GLT_LIC The GELATO sofware is cureently distibuted with the SURFEX software, available at
34 !GLT_LIC http://www.cnrm.meteo.fr/surfex. The fact that you download the software deemed that
35 !GLT_LIC you had knowledge of the CeCILL-C license and that you accept its terms.
36 !GLT_LIC Attempts to use this software in a way not complying with CeCILL-C license
37 !GLT_LIC may lead to prosecution.
38 !GLT_LIC
39 ! =======================================================================
40 ! ====================== MODULE modi_gltools_chkout =======================
41 ! =======================================================================
42 !
43 ! Goal:
44 ! -----
45 ! This module contains a subroutine that prints for every glt_gelato
46 ! glt_output field :
47 ! - global minimum
48 ! - global maximum
49 ! - global average (no weighing with grid cell surfaces)
50 ! - values for every field at a specified grid point
51 ! Note that MPP_SUM, MPP_MIN, MPP_MAX (invoke all procs) cannot be
52 ! used under condition lp2=.TRUE. HEnce we use the nprinto==2 condition.
53 !
54 ! Created : 2003/12 (D. Salas y Melia)
55 ! Modified: 2009/08 (D. Salas y Melia) Adapted to Gelato's new interface
56 ! Modified: 2012/11 (D. Salas y Melia) parallelism & super-type
57 ! Modified: 2014/01 (D. Salas y Melia) use standard wrivai for writing
58 !
59 ! ------------------- BEGIN MODULE modi_gltools_chkout --------------------
60 !
61 !THXS_SFX!MODULE modi_gltools_chkout
62 !THXS_SFX!INTERFACE
63 !THXS_SFX!!
64 !THXS_SFX!SUBROUTINE gltools_chkout( kdate,tpglt )
65 !THXS_SFX!!
66 !THXS_SFX! USE modd_types_glt
67 !THXS_SFX! INTEGER, INTENT(in) :: &
68 !THXS_SFX! kdate
69 !THXS_SFX! TYPE(t_glt), INTENT(in) :: &
70 !THXS_SFX! tpglt
71 !THXS_SFX!END SUBROUTINE gltools_chkout
72 !THXS_SFX!!
73 !THXS_SFX!END INTERFACE
74 !THXS_SFX!END MODULE modi_gltools_chkout
75 !
76 ! -------------------- END MODULE modi_gltools_chkout ---------------------
77 !
78 !
79 ! -----------------------------------------------------------------------
80 ! ------------------------- SUBROUTINE gltools_chkout ---------------------------
81 !
82 ! * Subroutine that prints mini, maxi and average of every Gelato glt_output
83 ! field, plus field values at one specified grid point.
84 !
85 SUBROUTINE gltools_chkout( kdate,tpglt )
86 !
87  USE modd_types_glt
88  USE modd_glt_param
89  USE modi_gltools_nwords
90  USE modi_gltools_strsplit
92  USE lib_mpp
93  IMPLICIT none
94 !
95 ! .. Dummy arguments
96 !
97  INTEGER, INTENT(in) :: &
98  kdate
99  TYPE(t_glt), INTENT(inout) :: &
100  tpglt
101 !
102 ! .. Local variables
103 !
104  LOGICAL :: &
105  y3d,ydo
106  CHARACTER(2) :: &
107  ynum
108  CHARACTER(80) :: &
109  ystep,yfile
110  CHARACTER(200) :: &
111  yfld
112  CHARACTER(80), DIMENSION(:), ALLOCATABLE :: &
113  ylistfld
114  INTEGER :: &
115  infld,imonth,jf,jk
116  REAL :: &
117  zofac,zmin,zmax,zsum
118  REAL, DIMENSION(SIZE(tpglt%dom,1),SIZE(tpglt%dom,2)) :: &
119  zwork2
120  REAL, DIMENSION(SIZE(tpglt%ice_atm,1),SIZE(tpglt%dom,1),SIZE(tpglt%dom,2)) :: &
121  zwork3
122  TYPE(t_def) :: &
123  tznam
124 !
125 !
126 ! 1. Initialisations
127 ! ===================
128 !
129  IF ( nprinto >= 2 ) THEN
130 !
131 ! .. List of all fields to be analysed (in a single string variable)
132 ! The user can change this list at will, provided that:
133 ! - the length of this string (named yallfld) is less than
134 ! the declared value
135 ! - every word in this string is associated to an action in
136 ! the case construct that follows.
137 !
138  IF ( nnflxin==0 ) THEN
139  yfld='pfsit palbm ptsfm &
140 & pnsfi pswai pcdfli &
141 & pwatfli ptauxg ptauyg pustar psalf'
142  ELSE
143  yfld='pfsit palbi ptsfi &
144 & pnsfi pswai pcdfli &
145 & pwatfli ptauxg ptauyg pustar psalf'
146  ENDIF
147 !
148 ! .. Get number of words in yfld, then get the list of fields in a vector
149 !
150  infld = gltools_nwords( yfld )
151  ALLOCATE( ylistfld(infld) )
152 !
153  ylistfld = gltools_strsplit( yfld,infld )
154 !
155 ! .. Surface grid factor
156 !
157  zofac = 1. / xdomsrf_g
158 !
159 !
160 !
161 ! 2. Print information
162 ! =====================
163 !
164 ! 2.1. General prints
165 ! --------------------
166 !
167  IF ( lwg ) THEN
168  WRITE(noutlu,*)
169  WRITE(noutlu,*) &
170  '===================== Control Gelato output data ' // &
171  '====================='
172 !
173  WRITE(noutlu,*) 'First Time-Step :',tpglt%ind%beg
174  WRITE(noutlu,*) 'Current Time-Step:',tpglt%ind%cur
175  WRITE(noutlu,*) 'Last Time-Step :',tpglt%ind%end
176 !
177  WRITE(noutlu,*)
178  WRITE(noutlu,*) &
179  ' minimum maximum average'
180  WRITE(noutlu,*) &
181  ' ============ ============ ============'
182  ENDIF
183 !
184 !
185 ! 2.2. Loop on fields
186 ! --------------------
187 !
188  DO jf=1,infld
189 !
190 ! .. Determine to which field the input label is associated
191 !
192  y3d = .false.
193 !
194  IF ( trim(ylistfld(jf))=='pfsit' ) THEN
195  IF ( nnflxin==0 ) THEN
196  zwork2(:,:) = tpglt%mix_atm(1,:,:)%fsi
197  ELSE
198  y3d = .true.
199  zwork3(:,:,:) = tpglt%ice_atm(:,:,:)%fsi
200  ENDIF
201  ELSE IF ( trim(ylistfld(jf))=='palbi' ) THEN
202  y3d = .true.
203  zwork3(:,:,:) = tpglt%ice_atm(:,:,:)%alb
204  ELSE IF ( trim(ylistfld(jf))=='ptsfi' ) THEN
205  y3d = .true.
206  zwork3(:,:,:) = tpglt%ice_atm(:,:,:)%tsf
207  ELSE IF ( trim(ylistfld(jf))=='palbm' ) THEN
208  zwork2(:,:) = tpglt%mix_atm(1,:,:)%alb
209  ELSE IF ( trim(ylistfld(jf))=='ptsfm' ) THEN
210  zwork2(:,:) = tpglt%mix_atm(1,:,:)%tsf
211  ELSE IF ( trim(ylistfld(jf))=='pnsfi' ) THEN
212  zwork2(:,:) = tpglt%all_oce(:,:)%nsf
213  ELSE IF ( trim(ylistfld(jf))=='pswai' ) THEN
214  zwork2(:,:) = tpglt%all_oce(:,:)%swa
215  ELSE IF ( trim(ylistfld(jf))=='pcdfli' ) THEN
216  zwork2(:,:) = tpglt%all_oce(:,:)%cdf
217  ELSE IF ( trim(ylistfld(jf))=='pwatfli' ) THEN
218  zwork2(:,:) = tpglt%all_oce(:,:)%wfl
219  ELSE IF ( trim(ylistfld(jf))=='ptauxg' ) THEN
220  zwork2(:,:) = tpglt%all_oce(:,:)%ztx
221  ELSE IF ( trim(ylistfld(jf))=='ptauyg' ) THEN
222  zwork2(:,:) = tpglt%all_oce(:,:)%mty
223  ELSE IF ( trim(ylistfld(jf))=='pustar' ) THEN
224  zwork2(:,:) = tpglt%all_oce(:,:)%ust
225  ELSE IF ( trim(ylistfld(jf))=='psalf' ) THEN
226  zwork2(:,:) = tpglt%all_oce(:,:)%saf
227  ELSE
228  IF ( lwg ) THEN
229  WRITE(noutlu,*) '**** WARNING ****'
230  WRITE(noutlu,*) ' In routine imod_tools_chkout'
231  WRITE(noutlu,*) ' ==> field ' // trim(ylistfld(jf)) // &
232  ' is unknown.'
233  ENDIF
234  ENDIF
235 !
236 ! .. Print information
237 !
238  IF ( y3d ) THEN
239  DO jk=1,nnflxin
240  zmin = minval( zwork3(jk,:,:),mask=tpglt%dom%tmk==1 )
241  zmax = maxval( zwork3(jk,:,:),mask=tpglt%dom%tmk==1 )
242  zsum = sum( zwork3(jk,:,:)*tpglt%dom%srf ) * zofac
243  CALL mpp_min(zmin)
244  CALL mpp_max(zmax)
245  CALL mpp_sum(zsum)
246  IF ( lwg ) THEN
247  WRITE(noutlu,1020) jk
248  WRITE(noutlu,1010) adjustl(ylistfld(jf)),zmin,zmax,zsum
249  ENDIF
250  END DO
251  ELSE
252  zmin = minval( zwork2(:,:),mask=tpglt%dom%tmk==1 )
253  zmax = maxval( zwork2(:,:),mask=tpglt%dom%tmk==1 )
254  zsum = sum( zwork2(:,:)*tpglt%dom%srf ) * zofac
255  IF ( lwg ) WRITE(noutlu,1010) adjustl(ylistfld(jf)),zmin,zmax,zsum
256  ENDIF
257 !
258  END DO
259 !
260  IF ( lwg ) THEN
261  WRITE(noutlu,*)
262  WRITE(noutlu,*) &
263  '===================================================================='
264  WRITE(noutlu,*)
265  ENDIF
266  DEALLOCATE( ylistfld )
267 !
268  ENDIF
269 !
270 !
271 !
272 ! 3. Save gelato output fields
273 ! =============================
274 !
275  ydo = nsavout==1 .AND. lwg
276 !
277  IF ( ydo ) THEN
278 !
279  IF(lwg) THEN
280  WRITE(noutlu,*) 'CHKOUT: Saving Gelato glt_output data'
281  WRITE(noutlu,*) '=================================='
282  WRITE(noutlu,*) ' '
283  ENDIF
284 !
285 ! .. Compute file name
286  imonth = ( kdate - 10000*( kdate/10000 ) ) / 100
287  WRITE( ystep,fmt='(I7)' ) tpglt%ind%cur
288  WRITE( yfile,fmt='("/outfld_",I2.2,"_",A)' ) &
289  imonth,trim( adjustl(ystep) )
290  yfile = trim(ciopath) // trim( adjustl(yfile) )
291 !
292 ! .. Open and write file
293 !
294  OPEN( unit=nsavlu, file=yfile, form='UNFORMATTED' )
295  ENDIF
296 !
297  IF ( nsavout==1 ) THEN
298  IF (nnflxin /= 0) THEN
299  DO jk=1,nnflxin
300  WRITE(ynum,'(I2.2)') jk
301  tznam = t_def( "","","SIFRCI"//ynum,"","T","SCALAR" )
302  CALL gltools_wrivai( tznam,tpglt%ice_atm(jk,:,:)%fsi,kunit=nsavlu,kdbl=1 )
303  tznam = t_def( "","","SIALBI"//ynum,"","T","SCALAR" )
304  CALL gltools_wrivai( tznam,tpglt%ice_atm(jk,:,:)%alb,kunit=nsavlu,kdbl=1 )
305  tznam = t_def( "","","SITEMI"//ynum,"","T","SCALAR" )
306  CALL gltools_wrivai( tznam,tpglt%ice_atm(jk,:,:)%tsf,kunit=nsavlu,kdbl=1 )
307  END DO
308 !
309  ELSE
310 !
311  tznam = t_def( "","","SIFRCSIS","","T","SCALAR" )
312  CALL gltools_wrivai( tznam,tpglt%mix_atm(1,:,:)%fsi,kunit=nsavlu,kdbl=1 )
313  tznam = t_def( "","","SIALBSIM","","T","SCALAR" )
314  CALL gltools_wrivai( tznam,tpglt%mix_atm(1,:,:)%alb,kunit=nsavlu,kdbl=1 )
315  tznam = t_def( "","","SITEMSIW","","T","SCALAR" )
316  CALL gltools_wrivai( tznam,tpglt%mix_atm(1,:,:)%tsf,kunit=nsavlu,kdbl=1 )
317  !
318  ENDIF
319 !
320  tznam = t_def( "","","PNSFIXXX","","T","SCALAR" )
321  CALL gltools_wrivai( tznam,tpglt%all_oce%nsf,kunit=nsavlu,kdbl=1 )
322  tznam = t_def( "","","PSWAIXXX","","T","SCALAR" )
323  CALL gltools_wrivai( tznam,tpglt%all_oce%swa,kunit=nsavlu,kdbl=1 )
324  tznam = t_def( "","","PCDFLIXX","","T","SCALAR" )
325  CALL gltools_wrivai( tznam,tpglt%all_oce%cdf,kunit=nsavlu,kdbl=1 )
326  tznam = t_def( "","","PWATFLIX","","T","SCALAR" )
327  CALL gltools_wrivai( tznam,tpglt%all_oce%wfl,kunit=nsavlu,kdbl=1 )
328  tznam = t_def( "","","PTAUXGXX","","U","VECTOR" )
329  CALL gltools_wrivai( tznam,tpglt%all_oce%ztx,kunit=nsavlu,kdbl=1 )
330  tznam = t_def( "","","PTAUYGXX","","V","VECTOR" )
331  CALL gltools_wrivai( tznam,tpglt%all_oce%mty,kunit=nsavlu,kdbl=1 )
332  tznam = t_def( "","","PUSTARXX","","T","SCALAR" )
333  CALL gltools_wrivai( tznam,tpglt%all_oce%ust,kunit=nsavlu,kdbl=1 )
334  tznam = t_def( "","","SALFLUXX","","T","SCALAR" )
335  CALL gltools_wrivai( tznam,tpglt%all_oce%saf,kunit=nsavlu,kdbl=1 )
336  ENDIF
337 !
338  IF ( ydo ) CLOSE(nsavlu)
339 !
340 !
341 !
342 ! 4. End of time step operations
343 ! ===============================
344 !
345  IF(lp1) THEN
346  WRITE(noutlu,*) &
347  ' ************************************'
348  WRITE(noutlu,*) &
349  ' END OF gelato TIME STEP Nr =',tpglt%ind%cur
350  WRITE(noutlu,*) &
351  ' ************************************'
352  CALL flush(noutlu)
353  ENDIF
354 !
355 !
356 !
357 ! 5. Formats
358 ! ===========
359 !
360 1010 FORMAT( 1x,a7,e12.5,4x,e12.5,4x,e12.5 )
361 1020 FORMAT( "Category",i2.2,":" )
362 !
363 END SUBROUTINE gltools_chkout
364 !
365 ! -------------------- END SUBROUTINE gltools_chkout --------------------
366 ! -----------------------------------------------------------------------
subroutine gltools_chkout(kdate, tpglt)
character(80) function, dimension(knword) gltools_strsplit(hval, knword)
integer function gltools_nwords(hval)