SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
modi_gltools_wriios.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_wriios ======================
41 ! =======================================================================
42 !
43 ! Goal:
44 ! -----
45 ! Write a diagnostic field using XIOS
46 !
47 ! Method :
48 ! --------
49 ! - Convert fields to kind wp
50 ! - Applies weighting if applicable
51 ! - Cast to a scalar if size is (1,1)
52 ! - Invoke Nemo (or dummy) routine iom_put, assuming that iom_init,
53 ! set_grid ...
54 ! was already done upstream
55 ! - Warn : the IOX namelist should set default value to big20 for Gelato fields
56 ! - Warn : Only 2d fields (genuine or degenerated to a scalar) are handled, yet
57 !
58 ! Created : 2013/08 (S. Senesi)
59 ! Modified: no
60 !
61 ! -------------------- BEGIN MODULE modi_gltools_wriios -------------------
62 !
63 !THXS_SFX!MODULE modi_gltools_wriios
64 !THXS_SFX!INTERFACE
65 !THXS_SFX!!
66 !THXS_SFX!SUBROUTINE gltools_wriios &
67 !THXS_SFX! ( hnam,pfield,pwgt )
68 !THXS_SFX! USE modd_glt_const_thm
69 !THXS_SFX! USE modd_glt_param
70 !THXS_SFX! USE iom
71 !THXS_SFX! USE par_kind
72 !THXS_SFX! CHARACTER(LEN=80), INTENT(IN) :: &
73 !THXS_SFX! hnam
74 !THXS_SFX! REAL, DIMENSION(:,:), INTENT(in) :: &
75 !THXS_SFX! pfield
76 !THXS_SFX! REAL, DIMENSION(:,:), OPTIONAL, INTENT(in) :: &
77 !THXS_SFX! pwgt
78 !THXS_SFX! END SUBROUTINE gltools_wriios
79 !THXS_SFX!!
80 !THXS_SFX!END INTERFACE
81 !THXS_SFX!END MODULE modi_gltools_wriios
82 
83 !
84 !
85 ! -------------------- END MODULE modi_gltools_wriios ---------------------
86 !
87 !
88 ! -------------------------------------------------------------------------
89 ! ----------------------- SUBROUTINE gltools_wriios -----------------------
90 !
91 SUBROUTINE gltools_wriios &
92  ( hnam,pfield,pwgt )
93 !
94  USE modd_glt_param
96 #if ! defined in_surfex
97  USE iom
98  USE par_kind
99 #else
100  USE modd_wp
101 #endif
102 
103  IMPLICIT NONE
104 
105 !
106 !* Arguments
107 !
108  CHARACTER(LEN=*), INTENT(IN) :: &
109  hnam
110  REAL, DIMENSION(:,:), INTENT(in) :: &
111  pfield
112  REAL, DIMENSION(:,:), OPTIONAL, INTENT(in) :: &
113  pwgt
114 !
115 !* Local variables
116 !
117  INTEGER :: &
118  ix,iy
119  REAL(wp), DIMENSION(:,:), ALLOCATABLE :: &
120  zwork2
121 !
122 ! .. Get sizes of input data field
123 !
124  ix = SIZE( pfield,1 )
125  iy = SIZE( pfield,2 )
126 
127  IF ((ix == 1) .AND. (iy == 1 )) THEN
128 #if ! defined in_surfex
129  CALL iom_put(hnam,pfield(1,1))
130 #else
131  print*,"Surfex cannot yet iom_put ",hnam
132 #endif
133  ELSE
134  IF ((ix == nx) .AND. (iy == ny )) THEN
135  ALLOCATE( zwork2(ix,iy))
136  IF ( present(pwgt) ) THEN
137  !
138  ! .. Weighting (pwgt is generally total sea ice concentration, or
139  ! average sea ice thickness)
140  !
141  WHERE( pwgt(:,:)>0. .AND. pfield(:,:)<xbig20 )
142  zwork2(:,:) = pfield(:,:) / pwgt(:,:)
143  ELSEWHERE
144  zwork2(:,:) = xbig20
145  ENDWHERE
146  ELSE
147  zwork2(:,:) = pfield(:,:)
148  ENDIF
149 ! IF(lwg) write(*,*) 'in wriios, field=',hnam,' min/max=',minval(pfield(:,:)),maxval(pfield(:,:))
150 #if ! defined in_surfex
151  CALL iom_put(hnam,zwork2)
152 #else
153  print*,"Surfex cannot yet iom_put ",hnam
154 #endif
155  DEALLOCATE(zwork2)
156  ELSE ! 2d case, with sizes consistent with iom.F90 assumptions
157  write(*,*) 'Gelato cannot use IOserver for sizes : ', ix, iy , 'of field', hnam
158  ENDIF
159  ENDIF
160 !
161 END SUBROUTINE gltools_wriios
162 !
163 ! ------------------------ END SUBROUTINE gltools_wriios ------------------------
164 ! -------------------------------------------------------------------------------
subroutine gltools_wriios(hnam, pfield, pwgt)