SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
modi_gltools_outdia.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_outdia =======================
41 ! =======================================================================
42 !
43 ! Goal:
44 ! -----
45 ! Condenses two routine calls in one, to shorten results routine.
46 !
47 ! Created : 2008/02 (D. Salas y Melia)
48 ! Modified: 2010/09 (D. Salas y Melia) Adapted for CMIP5 diagnostics
49 !
50 ! -------------------- BEGIN MODULE modi_gltools_outdia -------------------
51 !
52 !THXS_SFX!MODULE modi_gltools_outdia
53 !THXS_SFX!INTERFACE
54 !THXS_SFX!!
55 !THXS_SFX!SUBROUTINE gltools_outdia &
56 !THXS_SFX! ( tpind,tpnam,tpdom,pfield,pcumdia,pwgt )
57 !THXS_SFX!!
58 !THXS_SFX! USE modd_glt_param
59 !THXS_SFX! USE modd_types_glt
60 !THXS_SFX! USE modi_gltools_strlower
61 !THXS_SFX! TYPE(t_ind), INTENT(inout) :: &
62 !THXS_SFX! tpind
63 !THXS_SFX! TYPE(t_def), INTENT(in) :: &
64 !THXS_SFX! tpnam
65 !THXS_SFX! TYPE(t_dom), DIMENSION(nx,ny), INTENT(in) :: &
66 !THXS_SFX! tpdom
67 !THXS_SFX! REAL, DIMENSION(:,:), INTENT(inout) :: &
68 !THXS_SFX! pfield
69 !THXS_SFX! REAL, DIMENSION(:,:,:), INTENT(inout) :: &
70 !THXS_SFX! pcumdia
71 !THXS_SFX! REAL, DIMENSION(:,:), OPTIONAL, INTENT(inout) :: &
72 !THXS_SFX! pwgt
73 !THXS_SFX!END SUBROUTINE gltools_outdia
74 !THXS_SFX!!
75 !THXS_SFX!END INTERFACE
76 !THXS_SFX!END MODULE modi_gltools_outdia
77 !
78 ! -------------------- END MODULE modi_gltools_outdia ---------------------
79 !
80 !
81 ! -----------------------------------------------------------------------
82 ! -------------------------- SUBROUTINE gltools_outdia --------------------------
83 !
84 SUBROUTINE gltools_outdia &
85  ( tpind,tpnam,tpdom,pfield,pcumdia,pwgt )
86 !
87  USE modd_glt_param
88  USE modd_types_glt
90  USE modi_gltools_strlower
91  USE modi_gltools_wriios
93  USE modi_gltools_avevai
94  IMPLICIT NONE
95 !
96 !* Arguments
97 !
98  TYPE(t_ind), INTENT(inout) :: &
99  tpind
100  TYPE(t_def), INTENT(in) :: &
101  tpnam
102  TYPE(t_dom), DIMENSION(nx,ny), INTENT(in) :: &
103  tpdom
104  REAL, DIMENSION(:,:), INTENT(inout) :: &
105  pfield
106  REAL, DIMENSION(:,:,:), INTENT(inout) :: &
107  pcumdia
108  REAL, DIMENSION(:,:), OPTIONAL, INTENT(inout) :: &
109  pwgt
110 !
111 !* Local variables
112 !
113  LOGICAL :: &
114  yis0d,yis2d
115  CHARACTER(80), PARAMETER :: &
116  yall='all'
117  INTEGER :: &
118  ix,iy,ixc,iyc,ixw,iyw
119  INTEGER, DIMENSION(nx,ny) :: &
120  imsk
121 !
122 !
123 !* Get sizes of input data field
124  ix = SIZE(pfield,1)
125  iy = SIZE(pfield,2)
126  yis0d = ( ix==1 .AND. iy==1 )
127  yis2d = ( ix==nx .AND. iy==ny )
128 !
129  IF ( trim(cdiafmt)=='GELATO' .OR. trim(cdiafmt)=='VMAR5' .OR. &
130  trim(cdiafmt)=='XIOS' ) THEN
131 !
132  IF ( tpind%cur==tpind%beg ) THEN
133  IF ( trim(cdiafmt)=='GELATO' .OR. trim(cdiafmt)=='VMAR5' ) THEN
134 !
135 !* Print field information to gltout (for subsequent use in post-processing)
136  IF(lp1) WRITE(noutlu,1000) tpnam%sna,trim(tpnam%lna), &
137  gltools_strlower(trim(tpnam%loc)),trim(tpnam%def),trim(tpnam%uni)
138 !
139 !* Check that input field and cumulative array are conformable
140  ixc = SIZE( pcumdia,2 )
141  iyc = SIZE( pcumdia,3 )
142  IF ( ix/=ixc .OR. iy/=iyc ) THEN
143  IF (lwg) THEN
144  WRITE(noutlu,*) '==> Writing field '//trim(tpnam%sna)//':'
145  WRITE(noutlu,*) '==> Input field size=',ix,iy
146  WRITE(noutlu,*) &
147  '==> not conformable with ndiamax space size=',ixc,iyc
148  WRITE(noutlu,*) '==> We stop.'
149  ENDIF
150  stop
151  ENDIF
152  ENDIF
153  ENDIF
154 !
155 !* Check that input field and weights (if any) are conformable
156  IF ( present(pwgt) ) THEN
157  ixw = SIZE( pwgt,1 )
158  iyw = SIZE( pwgt,2 )
159  IF ( ix/=ixw .OR. iy/=iyw ) THEN
160  IF (lwg) THEN
161  WRITE(noutlu,*) '==> Writing field '//trim(tpnam%sna)//':'
162  WRITE(noutlu,*) '==> Input field size=',ix,iy
163  WRITE(noutlu,*) &
164  '==> not conformable with weights size=',ixw,iyw
165  WRITE(noutlu,*) '==> We stop.'
166  ENDIF
167  stop
168  ENDIF
169  ENDIF
170 !
171 !* Mask field before any use (if field is 2d)
172  IF ( yis2d ) THEN
173  SELECT CASE( trim(tpnam%loc) )
174  CASE('T') ; imsk(:,:) = tpdom(:,:)%tmk
175  CASE('U') ; imsk(:,:) = tpdom(:,:)%umk
176  CASE('V') ; imsk(:,:) = tpdom(:,:)%vmk
177  END SELECT
178  WHERE( imsk(:,:)==0 )
179  pfield(:,:) = xbig20
180  ENDWHERE
181  ENDIF
182 !
183 !* Write data
184  IF ( trim(cdiafmt)=='GELATO' .OR. trim(cdiafmt)=='VMAR5' ) THEN
185  IF ( ninsdia==1 ) THEN
186  IF ( any( cinsfld(:)==yall ) .OR. &
187  any( cinsfld(:)==tpnam%sna ) .OR. &
188  yis0d ) &
189  CALL gltools_wrivai( tpnam,pfield,pwgt=pwgt )
190  ENDIF
191  IF ( navedia==1 ) &
192  CALL gltools_avevai( tpind,tpnam,pfield,pcumdia,pwgt=pwgt )
193  ELSE
194  CALL gltools_wriios(tpnam%sna,pfield,pwgt=pwgt )
195  ENDIF
196  ENDIF
197 !
198 1000 FORMAT(3x,a20," ; ",a," ; ",a1," ; ",a," ; ",a)
199 !
200 END SUBROUTINE gltools_outdia
201 !
202 ! ------------------------ END SUBROUTINE gltools_outdia ------------------------
203 ! -----------------------------------------------------------------------
subroutine gltools_outdia(tpind, tpnam, tpdom, pfield, pcumdia, pwgt)
character(len=len(hstring)) function gltools_strlower(hstring)
subroutine gltools_wriios(hnam, pfield, pwgt)
subroutine gltools_avevai(tpind, tpnam, pfield, pcumdia, pwgt)