1 | MODULE iom |
---|
2 | !!===================================================================== |
---|
3 | !! *** MODULE iom *** |
---|
4 | !! Input/Output manager : Library to read input files |
---|
5 | !!==================================================================== |
---|
6 | !! History : 2.0 ! 2005-12 (J. Belier) Original code |
---|
7 | !! 2.0 ! 2006-02 (S. Masson) Adaptation to NEMO |
---|
8 | !! 3.0 ! 2007-07 (D. Storkey) Changes to iom_gettime |
---|
9 | !! 3.4 ! 2012-12 (R. Bourdalle-Badie and G. Reffray) add C1D case |
---|
10 | !! 3.6 ! 2014-15 DIMG format removed |
---|
11 | !! 3.6 ! 2015-15 (J. Harle) Added procedure to read REAL attributes |
---|
12 | !!-------------------------------------------------------------------- |
---|
13 | |
---|
14 | !!-------------------------------------------------------------------- |
---|
15 | !! iom_open : open a file read only |
---|
16 | !! iom_close : close a file or all files opened by iom |
---|
17 | !! iom_get : read a field (interfaced to several routines) |
---|
18 | !! iom_gettime : read the time axis cdvar in the file |
---|
19 | !! iom_varid : get the id of a variable in a file |
---|
20 | !! iom_rstput : write a field in a restart file (interfaced to several routines) |
---|
21 | !!-------------------------------------------------------------------- |
---|
22 | USE dom_oce ! ocean space and time domain |
---|
23 | USE c1d ! 1D vertical configuration |
---|
24 | USE flo_oce ! floats module declarations |
---|
25 | USE lbclnk ! lateal boundary condition / mpp exchanges |
---|
26 | USE iom_def ! iom variables definitions |
---|
27 | USE iom_nf90 ! NetCDF format with native NetCDF library |
---|
28 | USE in_out_manager ! I/O manager |
---|
29 | USE lib_mpp ! MPP library |
---|
30 | #if defined key_iomput |
---|
31 | USE sbc_oce, ONLY : nn_fsbc ! ocean space and time domain |
---|
32 | USE trc_oce, ONLY : nn_dttrc ! !: frequency of step on passive tracers |
---|
33 | USE icb_oce, ONLY : nclasses, class_num ! !: iceberg classes |
---|
34 | #if defined key_lim3 |
---|
35 | USE ice , ONLY : jpl |
---|
36 | #elif defined key_lim2 |
---|
37 | USE par_ice_2 |
---|
38 | #endif |
---|
39 | USE domngb ! ocean space and time domain |
---|
40 | USE phycst ! physical constants |
---|
41 | USE dianam ! build name of file |
---|
42 | USE xios |
---|
43 | USE iom_def, ONLY : max_rst_fields, rst_fields |
---|
44 | # endif |
---|
45 | USE ioipsl, ONLY : ju2ymds ! for calendar |
---|
46 | USE crs ! Grid coarsening |
---|
47 | USE lib_fortran |
---|
48 | |
---|
49 | IMPLICIT NONE |
---|
50 | PUBLIC ! must be public to be able to access iom_def through iom |
---|
51 | |
---|
52 | #if defined key_iomput |
---|
53 | LOGICAL, PUBLIC, PARAMETER :: lk_iomput = .TRUE. !: iom_put flag |
---|
54 | #else |
---|
55 | LOGICAL, PUBLIC, PARAMETER :: lk_iomput = .FALSE. !: iom_put flag |
---|
56 | #endif |
---|
57 | PUBLIC iom_init, iom_swap, iom_open, iom_close, iom_setkt, iom_varid, iom_get |
---|
58 | PUBLIC iom_getatt, iom_putatt, iom_gettime, iom_rstput, iom_put |
---|
59 | PUBLIC iom_use, iom_context_finalize |
---|
60 | |
---|
61 | PRIVATE iom_rp0d, iom_rp1d, iom_rp2d, iom_rp3d |
---|
62 | PRIVATE iom_g0d, iom_g1d, iom_g2d, iom_g3d, iom_get_123d |
---|
63 | PRIVATE iom_p1d, iom_p2d, iom_p3d |
---|
64 | #if defined key_iomput |
---|
65 | PRIVATE iom_set_domain_attr, iom_set_axis_attr, iom_set_field_attr, iom_set_file_attr, iom_get_file_attr, iom_set_grid_attr |
---|
66 | PRIVATE set_grid, set_grid_bounds, set_scalar, set_xmlatt, set_mooring, iom_update_file_name, iom_sdate |
---|
67 | PRIVATE set_rst_vars, set_rstr_active, set_rst_context |
---|
68 | # endif |
---|
69 | |
---|
70 | INTERFACE iom_get |
---|
71 | MODULE PROCEDURE iom_g0d, iom_g1d, iom_g2d, iom_g3d |
---|
72 | END INTERFACE |
---|
73 | INTERFACE iom_getatt |
---|
74 | MODULE PROCEDURE iom_g0d_iatt, iom_g0d_ratt, iom_g0d_catt |
---|
75 | END INTERFACE |
---|
76 | INTERFACE iom_putatt |
---|
77 | MODULE PROCEDURE iom_p0d_iatt, iom_p0d_ratt, iom_p0d_catt |
---|
78 | END INTERFACE |
---|
79 | INTERFACE iom_rstput |
---|
80 | MODULE PROCEDURE iom_rp0d, iom_rp1d, iom_rp2d, iom_rp3d |
---|
81 | END INTERFACE |
---|
82 | INTERFACE iom_put |
---|
83 | MODULE PROCEDURE iom_p0d, iom_p1d, iom_p2d, iom_p3d |
---|
84 | END INTERFACE |
---|
85 | |
---|
86 | !!---------------------------------------------------------------------- |
---|
87 | !! NEMO/OPA 3.3 , NEMO Consortium (2010) |
---|
88 | !! $Id$ |
---|
89 | !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) |
---|
90 | !!---------------------------------------------------------------------- |
---|
91 | |
---|
92 | CONTAINS |
---|
93 | |
---|
94 | SUBROUTINE iom_init( cdname ) |
---|
95 | !!---------------------------------------------------------------------- |
---|
96 | !! *** ROUTINE *** |
---|
97 | !! |
---|
98 | !! ** Purpose : |
---|
99 | !! |
---|
100 | !!---------------------------------------------------------------------- |
---|
101 | CHARACTER(len=*), INTENT(in) :: cdname |
---|
102 | #if defined key_iomput |
---|
103 | |
---|
104 | TYPE(xios_duration) :: dtime = xios_duration(0, 0, 0, 0, 0, 0) |
---|
105 | TYPE(xios_date) :: start_date |
---|
106 | CHARACTER(len=10) :: clname |
---|
107 | INTEGER :: ji, jkmin |
---|
108 | LOGICAL :: llrst_context ! is context related to restart |
---|
109 | ! |
---|
110 | REAL(wp), ALLOCATABLE, DIMENSION(:,:) :: zt_bnds, zw_bnds |
---|
111 | !!---------------------------------------------------------------------- |
---|
112 | |
---|
113 | ALLOCATE( zt_bnds(2,jpk), zw_bnds(2,jpk) ) |
---|
114 | |
---|
115 | clname = cdname |
---|
116 | IF( TRIM(Agrif_CFixed()) /= '0' ) clname = TRIM(Agrif_CFixed())//"_"//TRIM(cdname) |
---|
117 | CALL xios_context_initialize(TRIM(clname), mpi_comm_opa) |
---|
118 | CALL iom_swap( cdname ) |
---|
119 | llrst_context = (TRIM(cdname) == TRIM(crxios_context)) |
---|
120 | |
---|
121 | ! Calendar type is now defined in xml file |
---|
122 | SELECT CASE ( nleapy ) ! Choose calendar for IOIPSL |
---|
123 | CASE ( 1) ; CALL xios_define_calendar( TYPE = "Gregorian", time_origin = xios_date(1900,01,01,00,00,00), & |
---|
124 | & start_date = xios_date(nyear,nmonth,nday,0,0,0) ) |
---|
125 | CASE ( 0) ; CALL xios_define_calendar( TYPE = "NoLeap" , time_origin = xios_date(1900,01,01,00,00,00), & |
---|
126 | & start_date = xios_date(nyear,nmonth,nday,0,0,0) ) |
---|
127 | CASE (30) ; CALL xios_define_calendar( TYPE = "D360" , time_origin = xios_date(1900,01,01,00,00,00), & |
---|
128 | & start_date = xios_date(nyear,nmonth,nday,0,0,0) ) |
---|
129 | END SELECT |
---|
130 | |
---|
131 | ! horizontal grid definition |
---|
132 | IF(.NOT.llrst_context) CALL set_scalar |
---|
133 | |
---|
134 | IF( TRIM(cdname) == TRIM(cxios_context) ) THEN |
---|
135 | CALL set_grid( "T", glamt, gphit, .FALSE. ) |
---|
136 | CALL set_grid( "U", glamu, gphiu, .FALSE. ) |
---|
137 | CALL set_grid( "V", glamv, gphiv, .FALSE. ) |
---|
138 | CALL set_grid( "W", glamt, gphit, .FALSE. ) |
---|
139 | CALL set_grid_znl( gphit ) |
---|
140 | ! |
---|
141 | IF( ln_cfmeta ) THEN ! Add additional grid metadata |
---|
142 | CALL iom_set_domain_attr("grid_T", area = e1e2t(nldi:nlei, nldj:nlej)) |
---|
143 | CALL iom_set_domain_attr("grid_U", area = e1e2u(nldi:nlei, nldj:nlej)) |
---|
144 | CALL iom_set_domain_attr("grid_V", area = e1e2v(nldi:nlei, nldj:nlej)) |
---|
145 | CALL iom_set_domain_attr("grid_W", area = e1e2t(nldi:nlei, nldj:nlej)) |
---|
146 | CALL set_grid_bounds( "T", glamf, gphif, glamt, gphit ) |
---|
147 | CALL set_grid_bounds( "U", glamv, gphiv, glamu, gphiu ) |
---|
148 | CALL set_grid_bounds( "V", glamu, gphiu, glamv, gphiv ) |
---|
149 | CALL set_grid_bounds( "W", glamf, gphif, glamt, gphit ) |
---|
150 | ENDIF |
---|
151 | ENDIF |
---|
152 | |
---|
153 | IF( TRIM(cdname) == TRIM(cxios_context)//"_crs" ) THEN |
---|
154 | CALL dom_grid_crs ! Save the parent grid information & Switch to coarse grid domain |
---|
155 | ! |
---|
156 | CALL set_grid( "T", glamt_crs, gphit_crs, .FALSE. ) |
---|
157 | CALL set_grid( "U", glamu_crs, gphiu_crs, .FALSE. ) |
---|
158 | CALL set_grid( "V", glamv_crs, gphiv_crs, .FALSE. ) |
---|
159 | CALL set_grid( "W", glamt_crs, gphit_crs, .FALSE. ) |
---|
160 | CALL set_grid_znl( gphit_crs ) |
---|
161 | ! |
---|
162 | CALL dom_grid_glo ! Return to parent grid domain |
---|
163 | ! |
---|
164 | IF( ln_cfmeta .AND. TRIM(cdname) .NE. TRIM(crxios_context)) THEN ! Add additional grid metadata |
---|
165 | CALL iom_set_domain_attr("grid_T", area = e1e2t_crs(nldi:nlei, nldj:nlej)) |
---|
166 | CALL iom_set_domain_attr("grid_U", area = e1u_crs(nldi:nlei, nldj:nlej) * e2u_crs(nldi:nlei, nldj:nlej)) |
---|
167 | CALL iom_set_domain_attr("grid_V", area = e1v_crs(nldi:nlei, nldj:nlej) * e2v_crs(nldi:nlei, nldj:nlej)) |
---|
168 | CALL iom_set_domain_attr("grid_W", area = e1e2t_crs(nldi:nlei, nldj:nlej)) |
---|
169 | CALL set_grid_bounds( "T", glamf_crs, gphif_crs, glamt_crs, gphit_crs ) |
---|
170 | CALL set_grid_bounds( "U", glamv_crs, gphiv_crs, glamu_crs, gphiu_crs ) |
---|
171 | CALL set_grid_bounds( "V", glamu_crs, gphiu_crs, glamv_crs, gphiv_crs ) |
---|
172 | CALL set_grid_bounds( "W", glamf_crs, gphif_crs, glamt_crs, gphit_crs ) |
---|
173 | ENDIF |
---|
174 | ENDIF |
---|
175 | |
---|
176 | ! vertical grid definition |
---|
177 | IF(.NOT.llrst_context) THEN |
---|
178 | CALL iom_set_axis_attr( "deptht", paxis = gdept_1d ) |
---|
179 | CALL iom_set_axis_attr( "depthu", paxis = gdept_1d ) |
---|
180 | CALL iom_set_axis_attr( "depthv", paxis = gdept_1d ) |
---|
181 | CALL iom_set_axis_attr( "depthw", paxis = gdepw_1d ) |
---|
182 | |
---|
183 | ! Add vertical grid bounds |
---|
184 | jkmin = MIN(2,jpk) ! in case jpk=1 (i.e. sas2D) |
---|
185 | zt_bnds(2,: ) = gdept_1d(:) |
---|
186 | zt_bnds(1,jkmin:jpk) = gdept_1d(1:jpkm1) |
---|
187 | zt_bnds(1,1 ) = gdept_1d(1) - e3w_1d(1) |
---|
188 | zw_bnds(1,: ) = gdepw_1d(:) |
---|
189 | zw_bnds(2,1:jpkm1 ) = gdepw_1d(jkmin:jpk) |
---|
190 | zw_bnds(2,jpk: ) = gdepw_1d(jpk) + e3t_1d(jpk) |
---|
191 | CALL iom_set_axis_attr( "deptht", bounds=zt_bnds ) |
---|
192 | CALL iom_set_axis_attr( "depthu", bounds=zt_bnds ) |
---|
193 | CALL iom_set_axis_attr( "depthv", bounds=zt_bnds ) |
---|
194 | CALL iom_set_axis_attr( "depthw", bounds=zw_bnds ) |
---|
195 | |
---|
196 | |
---|
197 | # if defined key_floats |
---|
198 | CALL iom_set_axis_attr( "nfloat", (/ (REAL(ji,wp), ji=1,nfloat) /) ) |
---|
199 | # endif |
---|
200 | #if defined key_lim3 || defined key_lim2 |
---|
201 | CALL iom_set_axis_attr( "ncatice", (/ (REAL(ji,wp), ji=1,jpl) /) ) |
---|
202 | #endif |
---|
203 | CALL iom_set_axis_attr( "icbcla", class_num ) |
---|
204 | CALL iom_set_axis_attr( "iax_20C", (/ REAL(20,wp) /) ) |
---|
205 | CALL iom_set_axis_attr( "iax_28C", (/ REAL(28,wp) /) ) |
---|
206 | ENDIF |
---|
207 | ! automatic definitions of some of the xml attributs |
---|
208 | IF( llrst_context ) THEN |
---|
209 | !set names of the fields in restart file IF using XIOS to read/write data |
---|
210 | CALL set_rst_context() |
---|
211 | CALL set_rst_vars() |
---|
212 | !set which fields are to be read from restart file |
---|
213 | CALL set_rstr_active() |
---|
214 | ELSE |
---|
215 | CALL set_xmlatt |
---|
216 | ENDIF |
---|
217 | |
---|
218 | ! end file definition |
---|
219 | dtime%second = rdt |
---|
220 | CALL xios_set_timestep(dtime) |
---|
221 | CALL xios_close_context_definition() |
---|
222 | |
---|
223 | CALL xios_update_calendar(0) |
---|
224 | |
---|
225 | DEALLOCATE( zt_bnds, zw_bnds ) |
---|
226 | |
---|
227 | #endif |
---|
228 | |
---|
229 | END SUBROUTINE iom_init |
---|
230 | |
---|
231 | |
---|
232 | SUBROUTINE set_rst_vars() |
---|
233 | !set names for variables in restart file |
---|
234 | INTEGER :: i |
---|
235 | rst_fields(:)%vname="NO_NAME"; rst_fields(:)%grid="NO_GRID" |
---|
236 | i = 0 |
---|
237 | i = i + 1; rst_fields(i)%vname="rdt"; rst_fields(i)% grid="grid_scalar" |
---|
238 | i = i + 1; rst_fields(i)%vname="un"; rst_fields(i)% grid="grid_N_3D" |
---|
239 | i = i + 1; rst_fields(i)%vname="ub"; rst_fields(i)% grid="grid_N_3D" |
---|
240 | i = i + 1; rst_fields(i)%vname="vn"; rst_fields(i)% grid="grid_N_3D" |
---|
241 | i = i + 1; rst_fields(i)%vname="vb"; rst_fields(i)% grid="grid_N_3D" |
---|
242 | i = i + 1; rst_fields(i)%vname="tn"; rst_fields(i)% grid="grid_N_3D" |
---|
243 | i = i + 1; rst_fields(i)%vname="tb"; rst_fields(i)% grid="grid_N_3D" |
---|
244 | i = i + 1; rst_fields(i)%vname="sn"; rst_fields(i)% grid="grid_N_3D" |
---|
245 | i = i + 1; rst_fields(i)%vname="sb"; rst_fields(i)%grid="grid_N_3D" |
---|
246 | i = i + 1; rst_fields(i)%vname="sshn"; rst_fields(i)%grid="grid_N" |
---|
247 | i = i + 1; rst_fields(i)%vname="sshb"; rst_fields(i)%grid="grid_N" |
---|
248 | i = i + 1; rst_fields(i)%vname="rhop"; rst_fields(i)%grid="grid_N_3D" |
---|
249 | i = i + 1; rst_fields(i)%vname="kt"; rst_fields(i)%grid="grid_scalar" |
---|
250 | i = i + 1; rst_fields(i)%vname="ndastp"; rst_fields(i)%grid="grid_scalar" |
---|
251 | i = i + 1; rst_fields(i)%vname="adatrj"; rst_fields(i)%grid="grid_scalar" |
---|
252 | i = i + 1; rst_fields(i)%vname="utau_b"; rst_fields(i)%grid="grid_N" |
---|
253 | i = i + 1; rst_fields(i)%vname="vtau_b"; rst_fields(i)%grid="grid_N" |
---|
254 | i = i + 1; rst_fields(i)%vname="qns_b"; rst_fields(i)%grid="grid_N" |
---|
255 | i = i + 1; rst_fields(i)%vname="emp_b"; rst_fields(i)%grid="grid_N" |
---|
256 | i = i + 1; rst_fields(i)%vname="sfx_b"; rst_fields(i)%grid="grid_N" |
---|
257 | i = i + 1; rst_fields(i)%vname="en" ; rst_fields(i)%grid="grid_N_3D" |
---|
258 | i = i + 1; rst_fields(i)%vname="avt"; rst_fields(i)%grid="grid_N_3D" |
---|
259 | i = i + 1; rst_fields(i)%vname="avm"; rst_fields(i)%grid="grid_N_3D" |
---|
260 | i = i + 1; rst_fields(i)%vname="avmu"; rst_fields(i)%grid="grid_N_3D" |
---|
261 | i = i + 1; rst_fields(i)%vname="avmv"; rst_fields(i)%grid="grid_N_3D" |
---|
262 | i = i + 1; rst_fields(i)%vname="dissl"; rst_fields(i)%grid="grid_N_3D" |
---|
263 | i = i + 1; rst_fields(i)%vname="sbc_hc_b"; rst_fields(i)%grid="grid_N" |
---|
264 | i = i + 1; rst_fields(i)%vname="sbc_sc_b"; rst_fields(i)%grid="grid_N" |
---|
265 | i = i + 1; rst_fields(i)%vname="qsr_hc_b"; rst_fields(i)%grid="grid_N_3D" |
---|
266 | i = i + 1; rst_fields(i)%vname="fraqsr_1lev"; rst_fields(i)%grid="grid_N" |
---|
267 | i = i + 1; rst_fields(i)%vname="greenland_icesheet_mass" |
---|
268 | rst_fields(i)%grid="grid_scalar" |
---|
269 | i = i + 1; rst_fields(i)%vname="greenland_icesheet_timelapsed" |
---|
270 | rst_fields(i)%grid="grid_scalar" |
---|
271 | i = i + 1; rst_fields(i)%vname="greenland_icesheet_mass_roc" |
---|
272 | rst_fields(i)%grid="grid_scalar" |
---|
273 | i = i + 1; rst_fields(i)%vname="antarctica_icesheet_mass" |
---|
274 | rst_fields(i)%grid="grid_scalar" |
---|
275 | i = i + 1; rst_fields(i)%vname="antarctica_icesheet_timelapsed" |
---|
276 | rst_fields(i)%grid="grid_scalar" |
---|
277 | i = i + 1; rst_fields(i)%vname="antarctica_icesheet_mass_roc" |
---|
278 | rst_fields(i)%grid="grid_scalar" |
---|
279 | i = i + 1; rst_fields(i)%vname="frc_v"; rst_fields(i)%grid="grid_scalar" |
---|
280 | i = i + 1; rst_fields(i)%vname="frc_t"; rst_fields(i)%grid="grid_scalar" |
---|
281 | i = i + 1; rst_fields(i)%vname="frc_s"; rst_fields(i)%grid="grid_scalar" |
---|
282 | i = i + 1; rst_fields(i)%vname="frc_wn_t"; rst_fields(i)%grid="grid_scalar" |
---|
283 | i = i + 1; rst_fields(i)%vname="frc_wn_s"; rst_fields(i)%grid="grid_scalar" |
---|
284 | i = i + 1; rst_fields(i)%vname="ssh_ini"; rst_fields(i)%grid="grid_N" |
---|
285 | i = i + 1; rst_fields(i)%vname="e3t_ini"; rst_fields(i)%grid="grid_N_3D" |
---|
286 | i = i + 1; rst_fields(i)%vname="hc_loc_ini"; rst_fields(i)%grid="grid_N_3D" |
---|
287 | i = i + 1; rst_fields(i)%vname="sc_loc_ini"; rst_fields(i)%grid="grid_N_3D" |
---|
288 | i = i + 1; rst_fields(i)%vname="ssh_hc_loc_ini"; rst_fields(i)%grid="grid_N" |
---|
289 | i = i + 1; rst_fields(i)%vname="ssh_sc_loc_ini"; rst_fields(i)%grid="grid_N" |
---|
290 | i = i + 1; rst_fields(i)%vname="tilde_e3t_b"; rst_fields(i)%grid="grid_N" |
---|
291 | i = i + 1; rst_fields(i)%vname="tilde_e3t_n"; rst_fields(i)%grid="grid_N" |
---|
292 | i = i + 1; rst_fields(i)%vname="hdiv_lf"; rst_fields(i)%grid="grid_N" |
---|
293 | i = i + 1; rst_fields(i)%vname="ub2_b"; rst_fields(i)%grid="grid_N" |
---|
294 | i = i + 1; rst_fields(i)%vname="vb2_b"; rst_fields(i)%grid="grid_N" |
---|
295 | i = i + 1; rst_fields(i)%vname="sshbb_e"; rst_fields(i)%grid="grid_N" |
---|
296 | i = i + 1; rst_fields(i)%vname="ubb_e"; rst_fields(i)%grid="grid_N" |
---|
297 | i = i + 1; rst_fields(i)%vname="vbb_e"; rst_fields(i)%grid="grid_N" |
---|
298 | i = i + 1; rst_fields(i)%vname="sshb_e"; rst_fields(i)%grid="grid_N" |
---|
299 | i = i + 1; rst_fields(i)%vname="ub_e"; rst_fields(i)%grid="grid_N" |
---|
300 | i = i + 1; rst_fields(i)%vname="vb_e"; rst_fields(i)%grid="grid_N" |
---|
301 | i = i + 1; rst_fields(i)%vname="fwf_isf_b"; rst_fields(i)%grid="grid_N" |
---|
302 | i = i + 1; rst_fields(i)%vname="isf_sc_b"; rst_fields(i)%grid="grid_N" |
---|
303 | i = i + 1; rst_fields(i)%vname="isf_hc_b"; rst_fields(i)%grid="grid_N" |
---|
304 | i = i + 1; rst_fields(i)%vname="ssh_ibb"; rst_fields(i)%grid="grid_N" |
---|
305 | i = i + 1; rst_fields(i)%vname="rnf_b"; rst_fields(i)%grid="grid_N" |
---|
306 | i = i + 1; rst_fields(i)%vname="rnf_hc_b"; rst_fields(i)%grid="grid_N" |
---|
307 | i = i + 1; rst_fields(i)%vname="rnf_sc_b"; rst_fields(i)%grid="grid_N" |
---|
308 | i = i + 1; rst_fields(i)%vname="nn_fsbc"; rst_fields(i)%grid="grid_scalar" |
---|
309 | i = i + 1; rst_fields(i)%vname="ssu_m"; rst_fields(i)%grid="grid_N" |
---|
310 | i = i + 1; rst_fields(i)%vname="ssv_m"; rst_fields(i)%grid="grid_N" |
---|
311 | i = i + 1; rst_fields(i)%vname="sst_m"; rst_fields(i)%grid="grid_N" |
---|
312 | i = i + 1; rst_fields(i)%vname="sss_m"; rst_fields(i)%grid="grid_N" |
---|
313 | i = i + 1; rst_fields(i)%vname="ssh_m"; rst_fields(i)%grid="grid_N" |
---|
314 | i = i + 1; rst_fields(i)%vname="e3t_m"; rst_fields(i)%grid="grid_N" |
---|
315 | i = i + 1; rst_fields(i)%vname="frq_m"; rst_fields(i)%grid="grid_N" |
---|
316 | i = i + 1; rst_fields(i)%vname="avmb"; rst_fields(i)%grid="grid_vector" |
---|
317 | i = i + 1; rst_fields(i)%vname="avtb"; rst_fields(i)%grid="grid_vector" |
---|
318 | i = i + 1; rst_fields(i)%vname="ub2_i_b"; rst_fields(i)%grid="grid_N" |
---|
319 | i = i + 1; rst_fields(i)%vname="vb2_i_b"; rst_fields(i)%grid="grid_N" |
---|
320 | i = i + 1; rst_fields(i)%vname="ntime"; rst_fields(i)%grid="grid_scalar" |
---|
321 | i = i + 1; rst_fields(i)%vname="Dsst"; rst_fields(i)%grid="grid_scalar" |
---|
322 | i = i + 1; rst_fields(i)%vname="tmask"; rst_fields(i)%grid="grid_N_3D" |
---|
323 | i = i + 1; rst_fields(i)%vname="umask"; rst_fields(i)%grid="grid_N_3D" |
---|
324 | i = i + 1; rst_fields(i)%vname="vmask"; rst_fields(i)%grid="grid_N_3D" |
---|
325 | i = i + 1; rst_fields(i)%vname="smask"; rst_fields(i)%grid="grid_N_3D" |
---|
326 | i = i + 1; rst_fields(i)%vname="gdepw_n"; rst_fields(i)%grid="grid_N_3D" |
---|
327 | i = i + 1; rst_fields(i)%vname="e3t_n"; rst_fields(i)%grid="grid_N_3D" |
---|
328 | i = i + 1; rst_fields(i)%vname="e3u_n"; rst_fields(i)%grid="grid_N_3D" |
---|
329 | i = i + 1; rst_fields(i)%vname="e3v_n"; rst_fields(i)%grid="grid_N_3D" |
---|
330 | i = i + 1; rst_fields(i)%vname="surf_ini"; rst_fields(i)%grid="grid_N" |
---|
331 | i = i + 1; rst_fields(i)%vname="e3t_b"; rst_fields(i)%grid="grid_N_3D" |
---|
332 | i = i + 1; rst_fields(i)%vname="e3t_n"; rst_fields(i)%grid="grid_N_3D" |
---|
333 | i = i + 1; rst_fields(i)%vname="mxln"; rst_fields(i)%grid="grid_N_3D" |
---|
334 | i = i + 1; rst_fields(i)%vname="e3t_m"; rst_fields(i)%grid="grid_N_3D" |
---|
335 | END SUBROUTINE set_rst_vars |
---|
336 | |
---|
337 | |
---|
338 | SUBROUTINE set_rstr_active() |
---|
339 | !sets enabled = .TRUE. for each field in restart file |
---|
340 | CHARACTER(len=256) :: rst_file |
---|
341 | TYPE(xios_field) :: field_hdl |
---|
342 | TYPE(xios_file) :: file_hdl |
---|
343 | TYPE(xios_filegroup) :: filegroup_hdl |
---|
344 | INTEGER :: i |
---|
345 | CHARACTER(lc) :: clpath |
---|
346 | |
---|
347 | clpath = TRIM(cn_ocerst_indir) |
---|
348 | IF( clpath(LEN_TRIM(clpath):) /= '/' ) clpath = TRIM(clpath) // '/' |
---|
349 | IF( TRIM(Agrif_CFixed()) == '0' ) THEN |
---|
350 | rst_file = TRIM(clpath)//TRIM(cn_ocerst_in) |
---|
351 | ELSE |
---|
352 | rst_file = TRIM(clpath)//'1_'//TRIM(cn_ocerst_in) |
---|
353 | ENDIF |
---|
354 | !set name of the restart file and enable available fields |
---|
355 | if(lwp) WRITE(numout,*) 'Setting restart filename (for XIOS) to: ',rst_file |
---|
356 | CALL xios_get_handle("file_definition", filegroup_hdl ) |
---|
357 | CALL xios_add_child(filegroup_hdl, file_hdl, 'rrestart') |
---|
358 | CALL xios_set_file_attr( "rrestart", name=trim(rst_file), type="one_file", & |
---|
359 | par_access="collective", enabled=.TRUE., mode="read", & |
---|
360 | output_freq=xios_timestep) |
---|
361 | !defin files for restart context |
---|
362 | DO i = 1, max_rst_fields |
---|
363 | IF( TRIM(rst_fields(i)%vname) /= "NO_NAME") THEN |
---|
364 | IF( iom_varid( numror, TRIM(rst_fields(i)%vname), ldstop = .FALSE. ) > 0 ) THEN |
---|
365 | CALL xios_add_child(file_hdl, field_hdl, TRIM(rst_fields(i)%vname)) |
---|
366 | SELECT CASE (TRIM(rst_fields(i)%grid)) |
---|
367 | CASE ("grid_N_3D") |
---|
368 | CALL xios_set_attr (field_hdl, enabled = .TRUE., name = TRIM(rst_fields(i)%vname), & |
---|
369 | domain_ref="grid_N", axis_ref="deptht", operation = "instant") |
---|
370 | CASE ("grid_N") |
---|
371 | CALL xios_set_attr (field_hdl, enabled = .TRUE., name = TRIM(rst_fields(i)%vname), & |
---|
372 | domain_ref="grid_N", operation = "instant") |
---|
373 | CASE ("grid_vector") |
---|
374 | CALL xios_set_attr (field_hdl, enabled = .TRUE., name = TRIM(rst_fields(i)%vname), & |
---|
375 | axis_ref="deptht", operation = "instant") |
---|
376 | CASE ("grid_scalar") |
---|
377 | CALL xios_set_attr (field_hdl, enabled = .TRUE., name = TRIM(rst_fields(i)%vname), & |
---|
378 | scalar_ref = "grid_scalar", operation = "instant") |
---|
379 | END SELECT |
---|
380 | IF(lwp) WRITE(numout,*) 'XIOS read: ', TRIM(rst_fields(i)%vname), ' enabled in ', TRIM(rst_file) |
---|
381 | ENDIF |
---|
382 | ENDIF |
---|
383 | END DO |
---|
384 | END SUBROUTINE set_rstr_active |
---|
385 | |
---|
386 | SUBROUTINE set_rst_context( ) |
---|
387 | #if defined key_iomput |
---|
388 | TYPE(xios_domaingroup) :: domaingroup_hdl |
---|
389 | TYPE(xios_domain) :: domain_hdl |
---|
390 | TYPE(xios_axisgroup) :: axisgroup_hdl |
---|
391 | TYPE(xios_axis) :: axis_hdl |
---|
392 | TYPE(xios_scalar) :: scalar_hdl |
---|
393 | TYPE(xios_scalargroup) :: scalargroup_hdl |
---|
394 | |
---|
395 | CALL xios_get_handle("domain_definition",domaingroup_hdl) |
---|
396 | CALL xios_add_child(domaingroup_hdl, domain_hdl, "grid_N") |
---|
397 | CALL set_grid("N", glamt, gphit, .TRUE.) |
---|
398 | |
---|
399 | CALL xios_get_handle("axis_definition",axisgroup_hdl) |
---|
400 | CALL xios_add_child(axisgroup_hdl, axis_hdl, "deptht") |
---|
401 | !AGRIF fails to compile when unit= is in call to xios_set_axis_attr |
---|
402 | ! CALL xios_set_axis_attr( "deptht", long_name="Vertical levels", unit="m", positive="down") |
---|
403 | CALL xios_set_axis_attr( "deptht", long_name="Vertical levels in meters", positive="down") |
---|
404 | CALL iom_set_axis_attr( "deptht", paxis = gdept_1d ) |
---|
405 | |
---|
406 | CALL xios_get_handle("scalar_definition", scalargroup_hdl) |
---|
407 | CALL xios_add_child(scalargroup_hdl, scalar_hdl, "grid_scalar") |
---|
408 | #endif |
---|
409 | END SUBROUTINE set_rst_context |
---|
410 | |
---|
411 | SUBROUTINE iom_swap( cdname ) |
---|
412 | !!--------------------------------------------------------------------- |
---|
413 | !! *** SUBROUTINE iom_swap *** |
---|
414 | !! |
---|
415 | !! ** Purpose : swap context between different agrif grid for xmlio_server |
---|
416 | !!--------------------------------------------------------------------- |
---|
417 | CHARACTER(len=*), INTENT(in) :: cdname |
---|
418 | #if defined key_iomput |
---|
419 | TYPE(xios_context) :: nemo_hdl |
---|
420 | |
---|
421 | IF( TRIM(Agrif_CFixed()) == '0' ) THEN |
---|
422 | CALL xios_get_handle(TRIM(cdname),nemo_hdl) |
---|
423 | ELSE |
---|
424 | CALL xios_get_handle(TRIM(Agrif_CFixed())//"_"//TRIM(cdname),nemo_hdl) |
---|
425 | ENDIF |
---|
426 | ! |
---|
427 | CALL xios_set_current_context(nemo_hdl) |
---|
428 | #endif |
---|
429 | ! |
---|
430 | END SUBROUTINE iom_swap |
---|
431 | |
---|
432 | |
---|
433 | SUBROUTINE iom_open( cdname, kiomid, ldwrt, kdom, kiolib, ldstop, ldiof ) |
---|
434 | !!--------------------------------------------------------------------- |
---|
435 | !! *** SUBROUTINE iom_open *** |
---|
436 | !! |
---|
437 | !! ** Purpose : open an input file (return 0 if not found) |
---|
438 | !!--------------------------------------------------------------------- |
---|
439 | CHARACTER(len=*), INTENT(in ) :: cdname ! File name |
---|
440 | INTEGER , INTENT( out) :: kiomid ! iom identifier of the opened file |
---|
441 | LOGICAL , INTENT(in ), OPTIONAL :: ldwrt ! open in write modeb (default = .FALSE.) |
---|
442 | INTEGER , INTENT(in ), OPTIONAL :: kdom ! Type of domain to be written (default = jpdom_local_noovlap) |
---|
443 | INTEGER , INTENT(in ), OPTIONAL :: kiolib ! library used to open the file (default = jpnf90) |
---|
444 | LOGICAL , INTENT(in ), OPTIONAL :: ldstop ! stop if open to read a non-existing file (default = .TRUE.) |
---|
445 | LOGICAL , INTENT(in ), OPTIONAL :: ldiof ! Interp On the Fly, needed for AGRIF (default = .FALSE.) |
---|
446 | |
---|
447 | CHARACTER(LEN=256) :: clname ! the name of the file based on cdname [[+clcpu]+clcpu] |
---|
448 | CHARACTER(LEN=256) :: cltmpn ! tempory name to store clname (in writting mode) |
---|
449 | CHARACTER(LEN=10) :: clsuffix ! ".nc" |
---|
450 | CHARACTER(LEN=15) :: clcpu ! the cpu number (max jpmax_digits digits) |
---|
451 | CHARACTER(LEN=256) :: clinfo ! info character |
---|
452 | LOGICAL :: llok ! check the existence |
---|
453 | LOGICAL :: llwrt ! local definition of ldwrt |
---|
454 | LOGICAL :: llnoov ! local definition to read overlap |
---|
455 | LOGICAL :: llstop ! local definition of ldstop |
---|
456 | LOGICAL :: lliof ! local definition of ldiof |
---|
457 | INTEGER :: iolib ! library do we use to open the file |
---|
458 | INTEGER :: icnt ! counter for digits in clcpu (max = jpmax_digits) |
---|
459 | INTEGER :: iln, ils ! lengths of character |
---|
460 | INTEGER :: idom ! type of domain |
---|
461 | INTEGER :: istop ! |
---|
462 | INTEGER, DIMENSION(2,5) :: idompar ! domain parameters: |
---|
463 | ! local number of points for x,y dimensions |
---|
464 | ! position of first local point for x,y dimensions |
---|
465 | ! position of last local point for x,y dimensions |
---|
466 | ! start halo size for x,y dimensions |
---|
467 | ! end halo size for x,y dimensions |
---|
468 | !--------------------------------------------------------------------- |
---|
469 | ! Initializations and control |
---|
470 | ! ============= |
---|
471 | kiomid = -1 |
---|
472 | clinfo = ' iom_open ~~~ ' |
---|
473 | istop = nstop |
---|
474 | ! if iom_open is called for the first time: initialize iom_file(:)%nfid to 0 |
---|
475 | ! (could be done when defining iom_file in f95 but not in f90) |
---|
476 | IF( Agrif_Root() ) THEN |
---|
477 | IF( iom_open_init == 0 ) THEN |
---|
478 | iom_file(:)%nfid = 0 |
---|
479 | iom_open_init = 1 |
---|
480 | ENDIF |
---|
481 | ENDIF |
---|
482 | ! do we read or write the file? |
---|
483 | IF( PRESENT(ldwrt) ) THEN ; llwrt = ldwrt |
---|
484 | ELSE ; llwrt = .FALSE. |
---|
485 | ENDIF |
---|
486 | ! do we call ctl_stop if we try to open a non-existing file in read mode? |
---|
487 | IF( PRESENT(ldstop) ) THEN ; llstop = ldstop |
---|
488 | ELSE ; llstop = .TRUE. |
---|
489 | ENDIF |
---|
490 | ! what library do we use to open the file? |
---|
491 | IF( PRESENT(kiolib) ) THEN ; iolib = kiolib |
---|
492 | ELSE ; iolib = jpnf90 |
---|
493 | ENDIF |
---|
494 | ! are we using interpolation on the fly? |
---|
495 | IF( PRESENT(ldiof) ) THEN ; lliof = ldiof |
---|
496 | ELSE ; lliof = .FALSE. |
---|
497 | ENDIF |
---|
498 | ! do we read the overlap |
---|
499 | ! ugly patch SM+JMM+RB to overwrite global definition in some cases |
---|
500 | llnoov = (jpni * jpnj ) == jpnij .AND. .NOT. lk_agrif |
---|
501 | ! create the file name by added, if needed, TRIM(Agrif_CFixed()) and TRIM(clsuffix) |
---|
502 | ! ============= |
---|
503 | clname = trim(cdname) |
---|
504 | IF ( .NOT. Agrif_Root() .AND. .NOT. lliof ) THEN |
---|
505 | iln = INDEX(clname,'/') |
---|
506 | cltmpn = clname(1:iln) |
---|
507 | clname = clname(iln+1:LEN_TRIM(clname)) |
---|
508 | clname=TRIM(cltmpn)//TRIM(Agrif_CFixed())//'_'//TRIM(clname) |
---|
509 | ENDIF |
---|
510 | ! which suffix should we use? |
---|
511 | SELECT CASE (iolib) |
---|
512 | CASE (jpnf90 ) ; clsuffix = '.nc' |
---|
513 | CASE DEFAULT ; clsuffix = '' |
---|
514 | CALL ctl_stop( TRIM(clinfo), 'accepted IO library is only jpnf90 (jpioipsl option has been removed) ' ) |
---|
515 | END SELECT |
---|
516 | ! Add the suffix if needed |
---|
517 | iln = LEN_TRIM(clname) |
---|
518 | ils = LEN_TRIM(clsuffix) |
---|
519 | IF( iln <= ils .OR. INDEX( TRIM(clname), TRIM(clsuffix), back = .TRUE. ) /= iln - ils + 1 ) & |
---|
520 | & clname = TRIM(clname)//TRIM(clsuffix) |
---|
521 | cltmpn = clname ! store this name |
---|
522 | ! try to find if the file to be opened already exist |
---|
523 | ! ============= |
---|
524 | INQUIRE( FILE = clname, EXIST = llok ) |
---|
525 | IF( .NOT.llok ) THEN |
---|
526 | ! we try to add the cpu number to the name |
---|
527 | WRITE(clcpu,*) narea-1 |
---|
528 | |
---|
529 | clcpu = TRIM(ADJUSTL(clcpu)) |
---|
530 | iln = INDEX(clname,TRIM(clsuffix), back = .TRUE.) |
---|
531 | clname = clname(1:iln-1)//'_'//TRIM(clcpu)//TRIM(clsuffix) |
---|
532 | icnt = 0 |
---|
533 | INQUIRE( FILE = clname, EXIST = llok ) |
---|
534 | ! we try different formats for the cpu number by adding 0 |
---|
535 | DO WHILE( .NOT.llok .AND. icnt < jpmax_digits ) |
---|
536 | clcpu = "0"//trim(clcpu) |
---|
537 | clname = clname(1:iln-1)//'_'//TRIM(clcpu)//TRIM(clsuffix) |
---|
538 | INQUIRE( FILE = clname, EXIST = llok ) |
---|
539 | icnt = icnt + 1 |
---|
540 | END DO |
---|
541 | ELSE |
---|
542 | lxios_sini = .TRUE. |
---|
543 | ENDIF |
---|
544 | IF( llwrt ) THEN |
---|
545 | ! check the domain definition |
---|
546 | ! JMM + SM: ugly patch before getting the new version of lib_mpp) |
---|
547 | ! idom = jpdom_local_noovlap ! default definition |
---|
548 | IF( llnoov ) THEN ; idom = jpdom_local_noovlap ! default definition |
---|
549 | ELSE ; idom = jpdom_local_full ! default definition |
---|
550 | ENDIF |
---|
551 | IF( PRESENT(kdom) ) idom = kdom |
---|
552 | ! create the domain informations |
---|
553 | ! ============= |
---|
554 | SELECT CASE (idom) |
---|
555 | CASE (jpdom_local_full) |
---|
556 | idompar(:,1) = (/ jpi , jpj /) |
---|
557 | idompar(:,2) = (/ nimpp , njmpp /) |
---|
558 | idompar(:,3) = (/ nimpp + jpi - 1 , njmpp + jpj - 1 /) |
---|
559 | idompar(:,4) = (/ nldi - 1 , nldj - 1 /) |
---|
560 | idompar(:,5) = (/ jpi - nlei , jpj - nlej /) |
---|
561 | CASE (jpdom_local_noextra) |
---|
562 | idompar(:,1) = (/ nlci , nlcj /) |
---|
563 | idompar(:,2) = (/ nimpp , njmpp /) |
---|
564 | idompar(:,3) = (/ nimpp + nlci - 1, njmpp + nlcj - 1 /) |
---|
565 | idompar(:,4) = (/ nldi - 1 , nldj - 1 /) |
---|
566 | idompar(:,5) = (/ nlci - nlei , nlcj - nlej /) |
---|
567 | CASE (jpdom_local_noovlap) |
---|
568 | idompar(:,1) = (/ nlei - nldi + 1, nlej - nldj + 1 /) |
---|
569 | idompar(:,2) = (/ nimpp + nldi - 1, njmpp + nldj - 1 /) |
---|
570 | idompar(:,3) = (/ nimpp + nlei - 1, njmpp + nlej - 1 /) |
---|
571 | idompar(:,4) = (/ 0 , 0 /) |
---|
572 | idompar(:,5) = (/ 0 , 0 /) |
---|
573 | CASE DEFAULT |
---|
574 | CALL ctl_stop( TRIM(clinfo), 'wrong value of kdom, only jpdom_local* cases are accepted' ) |
---|
575 | END SELECT |
---|
576 | ENDIF |
---|
577 | ! Open the NetCDF file |
---|
578 | ! ============= |
---|
579 | ! do we have some free file identifier? |
---|
580 | IF( MINVAL(iom_file(:)%nfid) /= 0 ) & |
---|
581 | & CALL ctl_stop( TRIM(clinfo), 'No more free file identifier', 'increase jpmax_files in iom_def' ) |
---|
582 | ! if no file was found... |
---|
583 | IF( .NOT. llok ) THEN |
---|
584 | IF( .NOT. llwrt ) THEN ! we are in read mode |
---|
585 | IF( llstop ) THEN ; CALL ctl_stop( TRIM(clinfo), 'File '//TRIM(cltmpn)//'* not found' ) |
---|
586 | ELSE ; istop = nstop + 1 ! make sure that istop /= nstop so we don't open the file |
---|
587 | ENDIF |
---|
588 | ELSE ! we are in write mode so we |
---|
589 | clname = cltmpn ! get back the file name without the cpu number |
---|
590 | ENDIF |
---|
591 | ELSE |
---|
592 | IF( llwrt .AND. .NOT. ln_clobber ) THEN ! we stop as we want to write in a new file |
---|
593 | CALL ctl_stop( TRIM(clinfo), 'We want to write in a new file but '//TRIM(clname)//' already exists...' ) |
---|
594 | istop = nstop + 1 ! make sure that istop /= nstop so we don't open the file |
---|
595 | ELSEIF( llwrt ) THEN ! the file exists and we are in write mode with permission to |
---|
596 | clname = cltmpn ! overwrite so get back the file name without the cpu number |
---|
597 | ENDIF |
---|
598 | ENDIF |
---|
599 | IF( istop == nstop ) THEN ! no error within this routine |
---|
600 | SELECT CASE (iolib) |
---|
601 | CASE (jpnf90 ) ; CALL iom_nf90_open( clname, kiomid, llwrt, llok, idompar ) |
---|
602 | CASE DEFAULT |
---|
603 | CALL ctl_stop( TRIM(clinfo)//' accepted IO library is only jpnf90 (jpioipsl option has been removed) ' ) |
---|
604 | END SELECT |
---|
605 | ENDIF |
---|
606 | ! |
---|
607 | END SUBROUTINE iom_open |
---|
608 | |
---|
609 | |
---|
610 | SUBROUTINE iom_close( kiomid ) |
---|
611 | !!-------------------------------------------------------------------- |
---|
612 | !! *** SUBROUTINE iom_close *** |
---|
613 | !! |
---|
614 | !! ** Purpose : close an input file, or all files opened by iom |
---|
615 | !!-------------------------------------------------------------------- |
---|
616 | INTEGER, INTENT(inout), OPTIONAL :: kiomid ! iom identifier of the file to be closed |
---|
617 | ! ! return 0 when file is properly closed |
---|
618 | ! ! No argument: all files opened by iom are closed |
---|
619 | |
---|
620 | INTEGER :: jf ! dummy loop indices |
---|
621 | INTEGER :: i_s, i_e ! temporary integer |
---|
622 | CHARACTER(LEN=100) :: clinfo ! info character |
---|
623 | !--------------------------------------------------------------------- |
---|
624 | ! |
---|
625 | clinfo = ' iom_close ~~~ ' |
---|
626 | IF( PRESENT(kiomid) ) THEN |
---|
627 | i_s = kiomid |
---|
628 | i_e = kiomid |
---|
629 | ELSE |
---|
630 | i_s = 1 |
---|
631 | i_e = jpmax_files |
---|
632 | ENDIF |
---|
633 | |
---|
634 | IF( i_s > 0 ) THEN |
---|
635 | DO jf = i_s, i_e |
---|
636 | IF( iom_file(jf)%nfid > 0 ) THEN |
---|
637 | SELECT CASE (iom_file(jf)%iolib) |
---|
638 | CASE (jpnf90 ) ; CALL iom_nf90_close( jf ) |
---|
639 | CASE DEFAULT |
---|
640 | CALL ctl_stop( TRIM(clinfo)//' accepted IO library is only jpnf90 (jpioipsl option has been removed)' ) |
---|
641 | END SELECT |
---|
642 | iom_file(jf)%nfid = 0 ! free the id |
---|
643 | IF( PRESENT(kiomid) ) kiomid = 0 ! return 0 as id to specify that the file was closed |
---|
644 | IF(lwp) WRITE(numout,*) TRIM(clinfo)//' close file: '//TRIM(iom_file(jf)%name)//' ok' |
---|
645 | ELSEIF( PRESENT(kiomid) ) THEN |
---|
646 | WRITE(ctmp1,*) '--->', kiomid |
---|
647 | CALL ctl_stop( TRIM(clinfo)//' Invalid file identifier', ctmp1 ) |
---|
648 | ENDIF |
---|
649 | END DO |
---|
650 | ENDIF |
---|
651 | ! |
---|
652 | END SUBROUTINE iom_close |
---|
653 | |
---|
654 | |
---|
655 | FUNCTION iom_varid ( kiomid, cdvar, kdimsz, kndims, ldstop ) |
---|
656 | !!----------------------------------------------------------------------- |
---|
657 | !! *** FUNCTION iom_varid *** |
---|
658 | !! |
---|
659 | !! ** Purpose : get the id of a variable in a file (return 0 if not found) |
---|
660 | !!----------------------------------------------------------------------- |
---|
661 | INTEGER , INTENT(in ) :: kiomid ! file Identifier |
---|
662 | CHARACTER(len=*) , INTENT(in ) :: cdvar ! name of the variable |
---|
663 | INTEGER, DIMENSION(:), INTENT( out), OPTIONAL :: kdimsz ! size of the dimensions |
---|
664 | INTEGER, INTENT( out), OPTIONAL :: kndims ! size of the dimensions |
---|
665 | LOGICAL , INTENT(in ), OPTIONAL :: ldstop ! stop if looking for non-existing variable (default = .TRUE.) |
---|
666 | ! |
---|
667 | INTEGER :: iom_varid, iiv, i_nvd |
---|
668 | LOGICAL :: ll_fnd |
---|
669 | CHARACTER(LEN=100) :: clinfo ! info character |
---|
670 | LOGICAL :: llstop ! local definition of ldstop |
---|
671 | !!----------------------------------------------------------------------- |
---|
672 | iom_varid = 0 ! default definition |
---|
673 | ! do we call ctl_stop if we look for non-existing variable? |
---|
674 | IF( PRESENT(ldstop) ) THEN ; llstop = ldstop |
---|
675 | ELSE ; llstop = .TRUE. |
---|
676 | ENDIF |
---|
677 | ! |
---|
678 | IF( kiomid > 0 ) THEN |
---|
679 | clinfo = 'iom_varid, file: '//trim(iom_file(kiomid)%name)//', var: '//trim(cdvar) |
---|
680 | IF( iom_file(kiomid)%nfid == 0 ) THEN |
---|
681 | CALL ctl_stop( trim(clinfo), 'the file is not open' ) |
---|
682 | ELSE |
---|
683 | ll_fnd = .FALSE. |
---|
684 | iiv = 0 |
---|
685 | ! |
---|
686 | DO WHILE ( .NOT.ll_fnd .AND. iiv < iom_file(kiomid)%nvars ) |
---|
687 | iiv = iiv + 1 |
---|
688 | ll_fnd = ( TRIM(cdvar) == TRIM(iom_file(kiomid)%cn_var(iiv)) ) |
---|
689 | END DO |
---|
690 | ! |
---|
691 | IF( .NOT.ll_fnd ) THEN |
---|
692 | iiv = iiv + 1 |
---|
693 | IF( iiv <= jpmax_vars ) THEN |
---|
694 | SELECT CASE (iom_file(kiomid)%iolib) |
---|
695 | CASE (jpnf90 ) ; iom_varid = iom_nf90_varid ( kiomid, cdvar, iiv, kdimsz, kndims ) |
---|
696 | CASE DEFAULT |
---|
697 | CALL ctl_stop( TRIM(clinfo)//' accepted IO library is only jpnf90 (jpioipsl option has been removed)' ) |
---|
698 | END SELECT |
---|
699 | ELSE |
---|
700 | CALL ctl_stop( trim(clinfo), 'Too many variables in the file '//iom_file(kiomid)%name, & |
---|
701 | & 'increase the parameter jpmax_vars') |
---|
702 | ENDIF |
---|
703 | IF( llstop .AND. iom_varid == -1 ) CALL ctl_stop( TRIM(clinfo)//' not found' ) |
---|
704 | ELSE |
---|
705 | iom_varid = iiv |
---|
706 | IF( PRESENT(kdimsz) ) THEN |
---|
707 | i_nvd = iom_file(kiomid)%ndims(iiv) |
---|
708 | IF( i_nvd == size(kdimsz) ) THEN |
---|
709 | kdimsz(:) = iom_file(kiomid)%dimsz(1:i_nvd,iiv) |
---|
710 | ELSE |
---|
711 | WRITE(ctmp1,*) i_nvd, size(kdimsz) |
---|
712 | CALL ctl_stop( trim(clinfo), 'error in kdimsz size'//trim(ctmp1) ) |
---|
713 | ENDIF |
---|
714 | ENDIF |
---|
715 | IF( PRESENT(kndims) ) kndims = iom_file(kiomid)%ndims(iiv) |
---|
716 | ENDIF |
---|
717 | ENDIF |
---|
718 | ENDIF |
---|
719 | ! |
---|
720 | END FUNCTION iom_varid |
---|
721 | |
---|
722 | |
---|
723 | !!---------------------------------------------------------------------- |
---|
724 | !! INTERFACE iom_get |
---|
725 | !!---------------------------------------------------------------------- |
---|
726 | SUBROUTINE iom_g0d( kiomid, cdvar, pvar, ktime, ldxios ) |
---|
727 | INTEGER , INTENT(in ) :: kiomid ! Identifier of the file |
---|
728 | CHARACTER(len=*), INTENT(in ) :: cdvar ! Name of the variable |
---|
729 | REAL(wp) , INTENT( out) :: pvar ! read field |
---|
730 | INTEGER , INTENT(in ), OPTIONAL :: ktime ! record number |
---|
731 | LOGICAL , INTENT(in ), OPTIONAL :: ldxios ! use xios to read restart |
---|
732 | ! |
---|
733 | INTEGER :: idvar ! variable id |
---|
734 | INTEGER :: idmspc ! number of spatial dimensions |
---|
735 | INTEGER , DIMENSION(1) :: itime ! record number |
---|
736 | CHARACTER(LEN=100) :: clinfo ! info character |
---|
737 | CHARACTER(LEN=100) :: clname ! file name |
---|
738 | CHARACTER(LEN=1) :: cldmspc ! |
---|
739 | LOGICAL :: llxios |
---|
740 | ! |
---|
741 | llxios = .FALSE. |
---|
742 | IF( PRESENT(ldxios) ) llxios = ldxios |
---|
743 | |
---|
744 | IF(.NOT.llxios) THEN ! read data using default library |
---|
745 | itime = 1 |
---|
746 | IF( PRESENT(ktime) ) itime = ktime |
---|
747 | ! |
---|
748 | clname = iom_file(kiomid)%name |
---|
749 | clinfo = ' iom_g0d, file: '//trim(clname)//', var: '//trim(cdvar) |
---|
750 | ! |
---|
751 | IF( kiomid > 0 ) THEN |
---|
752 | idvar = iom_varid( kiomid, cdvar ) |
---|
753 | IF( iom_file(kiomid)%nfid > 0 .AND. idvar > 0 ) THEN |
---|
754 | idmspc = iom_file ( kiomid )%ndims( idvar ) |
---|
755 | IF( iom_file(kiomid)%luld(idvar) ) idmspc = idmspc - 1 |
---|
756 | WRITE(cldmspc , fmt='(i1)') idmspc |
---|
757 | IF( idmspc > 0 ) CALL ctl_stop( TRIM(clinfo), 'When reading to a 0D array, we do not accept data', & |
---|
758 | & 'with 1 or more spatial dimensions: '//cldmspc//' were found.' , & |
---|
759 | & 'Use ncwa -a to suppress the unnecessary dimensions' ) |
---|
760 | SELECT CASE (iom_file(kiomid)%iolib) |
---|
761 | CASE (jpnf90 ) ; CALL iom_nf90_get( kiomid, idvar, pvar, itime ) |
---|
762 | CASE DEFAULT |
---|
763 | CALL ctl_stop( 'iom_g0d: accepted IO library is only jpnf90 (jpioipsl option has been removed)' ) |
---|
764 | END SELECT |
---|
765 | ENDIF |
---|
766 | ENDIF |
---|
767 | ELSE |
---|
768 | IF(lwp) WRITE(numout,*) 'XIOS RST READ (0D): ', trim(cdvar) |
---|
769 | CALL iom_swap( TRIM(crxios_context) ) |
---|
770 | CALL xios_recv_field( trim(cdvar), pvar) |
---|
771 | CALL iom_swap( TRIM(cxios_context) ) |
---|
772 | ENDIF |
---|
773 | END SUBROUTINE iom_g0d |
---|
774 | |
---|
775 | SUBROUTINE iom_g1d( kiomid, kdom, cdvar, pvar, ktime, kstart, kcount, ldxios ) |
---|
776 | INTEGER , INTENT(in ) :: kiomid ! Identifier of the file |
---|
777 | INTEGER , INTENT(in ) :: kdom ! Type of domain to be read |
---|
778 | CHARACTER(len=*), INTENT(in ) :: cdvar ! Name of the variable |
---|
779 | REAL(wp) , INTENT( out), DIMENSION(:) :: pvar ! read field |
---|
780 | INTEGER , INTENT(in ) , OPTIONAL :: ktime ! record number |
---|
781 | INTEGER , INTENT(in ), DIMENSION(1), OPTIONAL :: kstart ! start axis position of the reading |
---|
782 | INTEGER , INTENT(in ), DIMENSION(1), OPTIONAL :: kcount ! number of points in each axis |
---|
783 | LOGICAL , INTENT(in ), OPTIONAL :: ldxios ! read data using XIOS |
---|
784 | ! |
---|
785 | IF( kiomid > 0 ) THEN |
---|
786 | IF( iom_file(kiomid)%nfid > 0 ) CALL iom_get_123d( kiomid, kdom , cdvar , pv_r1d=pvar, & |
---|
787 | & ktime=ktime, kstart=kstart, kcount=kcount, & |
---|
788 | & ldxios=ldxios ) |
---|
789 | ENDIF |
---|
790 | END SUBROUTINE iom_g1d |
---|
791 | |
---|
792 | SUBROUTINE iom_g2d( kiomid, kdom, cdvar, pvar, ktime, kstart, kcount, lrowattr, ldxios) |
---|
793 | INTEGER , INTENT(in ) :: kiomid ! Identifier of the file |
---|
794 | INTEGER , INTENT(in ) :: kdom ! Type of domain to be read |
---|
795 | CHARACTER(len=*), INTENT(in ) :: cdvar ! Name of the variable |
---|
796 | REAL(wp) , INTENT( out), DIMENSION(:,:) :: pvar ! read field |
---|
797 | INTEGER , INTENT(in ) , OPTIONAL :: ktime ! record number |
---|
798 | INTEGER , INTENT(in ), DIMENSION(2) , OPTIONAL :: kstart ! start axis position of the reading |
---|
799 | INTEGER , INTENT(in ), DIMENSION(2) , OPTIONAL :: kcount ! number of points in each axis |
---|
800 | LOGICAL , INTENT(in ) , OPTIONAL :: lrowattr ! logical flag telling iom_get to |
---|
801 | ! look for and use a file attribute |
---|
802 | ! called open_ocean_jstart to set the start |
---|
803 | ! value for the 2nd dimension (netcdf only) |
---|
804 | LOGICAL , INTENT(in ), OPTIONAL :: ldxios ! read data using XIOS |
---|
805 | ! |
---|
806 | IF( kiomid > 0 ) THEN |
---|
807 | IF( iom_file(kiomid)%nfid > 0 ) CALL iom_get_123d( kiomid, kdom , cdvar , pv_r2d=pvar, & |
---|
808 | & ktime=ktime, kstart=kstart, kcount=kcount, & |
---|
809 | & lrowattr=lrowattr, ldxios=ldxios) |
---|
810 | ENDIF |
---|
811 | END SUBROUTINE iom_g2d |
---|
812 | |
---|
813 | SUBROUTINE iom_g3d( kiomid, kdom, cdvar, pvar, ktime, kstart, kcount, lrowattr, ldxios ) |
---|
814 | INTEGER , INTENT(in ) :: kiomid ! Identifier of the file |
---|
815 | INTEGER , INTENT(in ) :: kdom ! Type of domain to be read |
---|
816 | CHARACTER(len=*), INTENT(in ) :: cdvar ! Name of the variable |
---|
817 | REAL(wp) , INTENT( out), DIMENSION(:,:,:) :: pvar ! read field |
---|
818 | INTEGER , INTENT(in ) , OPTIONAL :: ktime ! record number |
---|
819 | INTEGER , INTENT(in ), DIMENSION(3) , OPTIONAL :: kstart ! start axis position of the reading |
---|
820 | INTEGER , INTENT(in ), DIMENSION(3) , OPTIONAL :: kcount ! number of points in each axis |
---|
821 | LOGICAL , INTENT(in ) , OPTIONAL :: lrowattr ! logical flag telling iom_get to |
---|
822 | ! look for and use a file attribute |
---|
823 | ! called open_ocean_jstart to set the start |
---|
824 | ! value for the 2nd dimension (netcdf only) |
---|
825 | LOGICAL , INTENT(in ), OPTIONAL :: ldxios ! read data using XIOS |
---|
826 | ! |
---|
827 | IF( kiomid > 0 ) THEN |
---|
828 | IF( iom_file(kiomid)%nfid > 0 ) CALL iom_get_123d( kiomid, kdom , cdvar , pv_r3d=pvar, & |
---|
829 | & ktime=ktime, kstart=kstart, kcount=kcount, & |
---|
830 | & lrowattr=lrowattr, ldxios=ldxios ) |
---|
831 | ENDIF |
---|
832 | END SUBROUTINE iom_g3d |
---|
833 | !!---------------------------------------------------------------------- |
---|
834 | |
---|
835 | SUBROUTINE iom_get_123d( kiomid, kdom , cdvar , & |
---|
836 | & pv_r1d, pv_r2d, pv_r3d, & |
---|
837 | & ktime , kstart, kcount, & |
---|
838 | & lrowattr, ldxios ) |
---|
839 | !!----------------------------------------------------------------------- |
---|
840 | !! *** ROUTINE iom_get_123d *** |
---|
841 | !! |
---|
842 | !! ** Purpose : read a 1D/2D/3D variable |
---|
843 | !! |
---|
844 | !! ** Method : read ONE record at each CALL |
---|
845 | !!----------------------------------------------------------------------- |
---|
846 | INTEGER , INTENT(in ) :: kiomid ! Identifier of the file |
---|
847 | INTEGER , INTENT(in ) :: kdom ! Type of domain to be read |
---|
848 | CHARACTER(len=*) , INTENT(in ) :: cdvar ! Name of the variable |
---|
849 | REAL(wp), DIMENSION(:) , INTENT( out), OPTIONAL :: pv_r1d ! read field (1D case) |
---|
850 | REAL(wp), DIMENSION(:,:) , INTENT( out), OPTIONAL :: pv_r2d ! read field (2D case) |
---|
851 | REAL(wp), DIMENSION(:,:,:) , INTENT( out), OPTIONAL :: pv_r3d ! read field (3D case) |
---|
852 | INTEGER , INTENT(in ), OPTIONAL :: ktime ! record number |
---|
853 | INTEGER , DIMENSION(:) , INTENT(in ), OPTIONAL :: kstart ! start position of the reading in each axis |
---|
854 | INTEGER , DIMENSION(:) , INTENT(in ), OPTIONAL :: kcount ! number of points to be read in each axis |
---|
855 | LOGICAL , INTENT(in ), OPTIONAL :: lrowattr ! logical flag telling iom_get to |
---|
856 | ! look for and use a file attribute |
---|
857 | ! called open_ocean_jstart to set the start |
---|
858 | ! value for the 2nd dimension (netcdf only) |
---|
859 | LOGICAL , INTENT(in ), OPTIONAL :: ldxios ! use XIOS to read restart |
---|
860 | ! |
---|
861 | LOGICAL :: llxios ! local definition for XIOS read |
---|
862 | LOGICAL :: llnoov ! local definition to read overlap |
---|
863 | LOGICAL :: luse_jattr ! local definition to read open_ocean_jstart file attribute |
---|
864 | INTEGER :: jstartrow ! start point for 2nd dimension optionally set by file attribute |
---|
865 | INTEGER :: jl ! loop on number of dimension |
---|
866 | INTEGER :: idom ! type of domain |
---|
867 | INTEGER :: idvar ! id of the variable |
---|
868 | INTEGER :: inbdim ! number of dimensions of the variable |
---|
869 | INTEGER :: idmspc ! number of spatial dimensions |
---|
870 | INTEGER :: itime ! record number |
---|
871 | INTEGER :: istop ! temporary value of nstop |
---|
872 | INTEGER :: ix1, ix2, iy1, iy2 ! subdomain indexes |
---|
873 | INTEGER :: ji, jj ! loop counters |
---|
874 | INTEGER :: irankpv ! |
---|
875 | INTEGER :: ind1, ind2 ! substring index |
---|
876 | INTEGER, DIMENSION(jpmax_dims) :: istart ! starting point to read for each axis |
---|
877 | INTEGER, DIMENSION(jpmax_dims) :: icnt ! number of value to read along each axis |
---|
878 | INTEGER, DIMENSION(jpmax_dims) :: idimsz ! size of the dimensions of the variable |
---|
879 | INTEGER, DIMENSION(jpmax_dims) :: ishape ! size of the dimensions of the variable |
---|
880 | REAL(wp) :: zscf, zofs ! sacle_factor and add_offset |
---|
881 | INTEGER :: itmp ! temporary integer |
---|
882 | CHARACTER(LEN=256) :: clinfo ! info character |
---|
883 | CHARACTER(LEN=256) :: clname ! file name |
---|
884 | CHARACTER(LEN=1) :: clrankpv, cldmspc ! |
---|
885 | LOGICAL :: ll_depth_spec ! T => if kstart, kcount present then *only* use values for 3rd spatial dimension. |
---|
886 | !--------------------------------------------------------------------- |
---|
887 | ! |
---|
888 | REAL(wp) :: gma, gmi |
---|
889 | llxios = .FALSE. |
---|
890 | if(PRESENT(ldxios)) llxios = ldxios |
---|
891 | idvar = iom_varid( kiomid, cdvar ) |
---|
892 | idom = kdom |
---|
893 | |
---|
894 | IF(.NOT.llxios) THEN |
---|
895 | clname = iom_file(kiomid)%name ! esier to read |
---|
896 | clinfo = ' iom_get_123d, file: '//trim(clname)//', var: '//trim(cdvar) |
---|
897 | ! local definition of the domain ? |
---|
898 | ! do we read the overlap |
---|
899 | ! ugly patch SM+JMM+RB to overwrite global definition in some cases |
---|
900 | llnoov = (jpni * jpnj ) == jpnij .AND. .NOT. lk_agrif |
---|
901 | ! check kcount and kstart optionals parameters... |
---|
902 | IF( PRESENT(kcount) .AND. (.NOT. PRESENT(kstart)) ) CALL ctl_stop(trim(clinfo), 'kcount present needs kstart present') |
---|
903 | IF( PRESENT(kstart) .AND. (.NOT. PRESENT(kcount)) ) CALL ctl_stop(trim(clinfo), 'kstart present needs kcount present') |
---|
904 | IF( PRESENT(kstart) .AND. idom /= jpdom_unknown .AND. idom /= jpdom_autoglo_xy ) & |
---|
905 | & CALL ctl_stop(trim(clinfo), 'kstart present needs kdom = jpdom_unknown or kdom = jpdom_autoglo_xy') |
---|
906 | |
---|
907 | luse_jattr = .false. |
---|
908 | IF( PRESENT(lrowattr) ) THEN |
---|
909 | IF( lrowattr .AND. idom /= jpdom_data ) CALL ctl_stop(trim(clinfo), 'lrowattr present and true needs kdom = jpdom_data') |
---|
910 | IF( lrowattr .AND. idom == jpdom_data ) luse_jattr = .true. |
---|
911 | ENDIF |
---|
912 | IF( luse_jattr ) THEN |
---|
913 | SELECT CASE (iom_file(kiomid)%iolib) |
---|
914 | CASE (jpnf90 ) |
---|
915 | ! Ok |
---|
916 | CASE DEFAULT |
---|
917 | CALL ctl_stop( TRIM(clinfo)//' accepted IO library is only jpnf90 (jpioipsl option has been removed)' ) |
---|
918 | END SELECT |
---|
919 | ENDIF |
---|
920 | |
---|
921 | ! Search for the variable in the data base (eventually actualize data) |
---|
922 | istop = nstop |
---|
923 | ! |
---|
924 | IF( idvar > 0 ) THEN |
---|
925 | ! to write iom_file(kiomid)%dimsz in a shorter way ! |
---|
926 | idimsz(:) = iom_file(kiomid)%dimsz(:, idvar) |
---|
927 | inbdim = iom_file(kiomid)%ndims(idvar) ! number of dimensions in the file |
---|
928 | idmspc = inbdim ! number of spatial dimensions in the file |
---|
929 | IF( iom_file(kiomid)%luld(idvar) ) idmspc = inbdim - 1 |
---|
930 | IF( idmspc > 3 ) CALL ctl_stop(trim(clinfo), 'the file has more than 3 spatial dimensions this case is not coded...') |
---|
931 | ! |
---|
932 | ! update idom definition... |
---|
933 | ! Identify the domain in case of jpdom_auto(glo/dta) definition |
---|
934 | IF( idom == jpdom_autoglo_xy ) THEN |
---|
935 | ll_depth_spec = .TRUE. |
---|
936 | idom = jpdom_autoglo |
---|
937 | ELSE |
---|
938 | ll_depth_spec = .FALSE. |
---|
939 | ENDIF |
---|
940 | IF( idom == jpdom_autoglo .OR. idom == jpdom_autodta ) THEN |
---|
941 | IF( idom == jpdom_autoglo ) THEN ; idom = jpdom_global |
---|
942 | ELSE ; idom = jpdom_data |
---|
943 | ENDIF |
---|
944 | ind1 = INDEX( clname, '_', back = .TRUE. ) + 1 |
---|
945 | ind2 = INDEX( clname, '.', back = .TRUE. ) - 1 |
---|
946 | IF( ind2 > ind1 ) THEN ; IF( VERIFY( clname(ind1:ind2), '0123456789' ) == 0 ) idom = jpdom_local ; ENDIF |
---|
947 | ENDIF |
---|
948 | ! Identify the domain in case of jpdom_local definition |
---|
949 | IF( idom == jpdom_local ) THEN |
---|
950 | IF( idimsz(1) == jpi .AND. idimsz(2) == jpj ) THEN ; idom = jpdom_local_full |
---|
951 | ELSEIF( idimsz(1) == nlci .AND. idimsz(2) == nlcj ) THEN ; idom = jpdom_local_noextra |
---|
952 | ELSEIF( idimsz(1) == (nlei - nldi + 1) .AND. idimsz(2) == (nlej - nldj + 1) ) THEN ; idom = jpdom_local_noovlap |
---|
953 | ELSE ; CALL ctl_stop( trim(clinfo), 'impossible to identify the local domain' ) |
---|
954 | ENDIF |
---|
955 | ENDIF |
---|
956 | ! |
---|
957 | ! check the consistency between input array and data rank in the file |
---|
958 | ! |
---|
959 | ! initializations |
---|
960 | itime = 1 |
---|
961 | IF( PRESENT(ktime) ) itime = ktime |
---|
962 | |
---|
963 | irankpv = 1 * COUNT( (/PRESENT(pv_r1d)/) ) + 2 * COUNT( (/PRESENT(pv_r2d)/) ) + 3 * COUNT( (/PRESENT(pv_r3d)/) ) |
---|
964 | WRITE(clrankpv, fmt='(i1)') irankpv |
---|
965 | WRITE(cldmspc , fmt='(i1)') idmspc |
---|
966 | ! |
---|
967 | IF( idmspc < irankpv ) THEN |
---|
968 | CALL ctl_stop( TRIM(clinfo), 'The file has only '//cldmspc//' spatial dimension', & |
---|
969 | & 'it is impossible to read a '//clrankpv//'D array from this file...' ) |
---|
970 | ELSEIF( idmspc == irankpv ) THEN |
---|
971 | IF( PRESENT(pv_r1d) .AND. idom /= jpdom_unknown ) & |
---|
972 | & CALL ctl_stop( TRIM(clinfo), 'case not coded...You must use jpdom_unknown' ) |
---|
973 | ELSEIF( idmspc > irankpv ) THEN |
---|
974 | IF( PRESENT(pv_r2d) .AND. itime == 1 .AND. idimsz(3) == 1 .AND. idmspc == 3 ) THEN |
---|
975 | CALL ctl_warn( trim(clinfo), '2D array but 3 spatial dimensions for the data...' , & |
---|
976 | & 'As the size of the z dimension is 1 and as we try to read the first record, ', & |
---|
977 | & 'we accept this case, even if there is a possible mix-up between z and time dimension' ) |
---|
978 | idmspc = idmspc - 1 |
---|
979 | ELSE |
---|
980 | CALL ctl_stop( TRIM(clinfo), 'To keep iom lisibility, when reading a '//clrankpv//'D array,' , & |
---|
981 | & 'we do not accept data with '//cldmspc//' spatial dimensions', & |
---|
982 | & 'Use ncwa -a to suppress the unnecessary dimensions' ) |
---|
983 | ENDIF |
---|
984 | ENDIF |
---|
985 | |
---|
986 | ! |
---|
987 | ! definition of istart and icnt |
---|
988 | ! |
---|
989 | icnt (:) = 1 |
---|
990 | istart(:) = 1 |
---|
991 | istart(idmspc+1) = itime |
---|
992 | |
---|
993 | IF( PRESENT(kstart) .AND. .NOT. ll_depth_spec ) THEN |
---|
994 | istart(1:idmspc) = kstart(1:idmspc) ; icnt(1:idmspc) = kcount(1:idmspc) |
---|
995 | ELSE |
---|
996 | IF(idom == jpdom_unknown ) THEN |
---|
997 | icnt(1:idmspc) = idimsz(1:idmspc) |
---|
998 | ELSE |
---|
999 | IF( .NOT. PRESENT(pv_r1d) ) THEN ! not a 1D array |
---|
1000 | IF( idom == jpdom_data ) THEN |
---|
1001 | jstartrow = 1 |
---|
1002 | IF( luse_jattr ) THEN |
---|
1003 | CALL iom_getatt(kiomid, 'open_ocean_jstart', jstartrow ) ! -999 is returned if the attribute is not found |
---|
1004 | jstartrow = MAX(1,jstartrow) |
---|
1005 | ENDIF |
---|
1006 | istart(1:2) = (/ mig(1), mjg(1) + jstartrow - 1 /) ! icnt(1:2) done below |
---|
1007 | ELSEIF( idom == jpdom_global ) THEN ; istart(1:2) = (/ nimpp , njmpp /) ! icnt(1:2) done below |
---|
1008 | ENDIF |
---|
1009 | ! we do not read the overlap -> we start to read at nldi, nldj |
---|
1010 | ! JMM + SM: ugly patch before getting the new version of lib_mpp) |
---|
1011 | ! IF( idom /= jpdom_local_noovlap ) istart(1:2) = istart(1:2) + (/ nldi - 1, nldj - 1 /) |
---|
1012 | IF( llnoov .AND. idom /= jpdom_local_noovlap ) istart(1:2) = istart(1:2) + (/ nldi - 1, nldj - 1 /) |
---|
1013 | ! we do not read the overlap and the extra-halos -> from nldi to nlei and from nldj to nlej |
---|
1014 | ! JMM + SM: ugly patch before getting the new version of lib_mpp) |
---|
1015 | ! icnt(1:2) = (/ nlei - nldi + 1, nlej - nldj + 1 /) |
---|
1016 | IF( llnoov ) THEN ; icnt(1:2) = (/ nlei - nldi + 1, nlej - nldj + 1 /) |
---|
1017 | ELSE ; icnt(1:2) = (/ nlci , nlcj /) |
---|
1018 | ENDIF |
---|
1019 | IF( PRESENT(pv_r3d) ) THEN |
---|
1020 | IF( idom == jpdom_data ) THEN ; icnt(3) = jpkglo |
---|
1021 | ELSE IF( ll_depth_spec .AND. PRESENT(kstart) ) THEN ; istart(3) = kstart(3); icnt(3) = kcount(3) |
---|
1022 | ELSE ; icnt(3) = jpk |
---|
1023 | ENDIF |
---|
1024 | ENDIF |
---|
1025 | ENDIF |
---|
1026 | ENDIF |
---|
1027 | ENDIF |
---|
1028 | |
---|
1029 | ! check that istart and icnt can be used with this file |
---|
1030 | !- |
---|
1031 | DO jl = 1, jpmax_dims |
---|
1032 | itmp = istart(jl)+icnt(jl)-1 |
---|
1033 | IF( itmp > idimsz(jl) .AND. idimsz(jl) /= 0 ) THEN |
---|
1034 | WRITE( ctmp1, FMT="('(istart(', i1, ') + icnt(', i1, ') - 1) = ', i5)" ) jl, jl, itmp |
---|
1035 | WRITE( ctmp2, FMT="(' is larger than idimsz(', i1,') = ', i5)" ) jl, idimsz(jl) |
---|
1036 | CALL ctl_stop( trim(clinfo), 'start and count too big regarding to the size of the data, ', ctmp1, ctmp2 ) |
---|
1037 | ENDIF |
---|
1038 | END DO |
---|
1039 | |
---|
1040 | ! check that icnt matches the input array |
---|
1041 | !- |
---|
1042 | IF( idom == jpdom_unknown ) THEN |
---|
1043 | IF( irankpv == 1 ) ishape(1:1) = SHAPE(pv_r1d) |
---|
1044 | IF( irankpv == 2 ) ishape(1:2) = SHAPE(pv_r2d) |
---|
1045 | IF( irankpv == 3 ) ishape(1:3) = SHAPE(pv_r3d) |
---|
1046 | ctmp1 = 'd' |
---|
1047 | ELSE |
---|
1048 | IF( irankpv == 2 ) THEN |
---|
1049 | ! JMM + SM: ugly patch before getting the new version of lib_mpp) |
---|
1050 | ! ishape(1:2) = SHAPE(pv_r2d(nldi:nlei,nldj:nlej )) ; ctmp1 = 'd(nldi:nlei,nldj:nlej)' |
---|
1051 | IF( llnoov ) THEN ; ishape(1:2)=SHAPE(pv_r2d(nldi:nlei,nldj:nlej )) ; ctmp1='d(nldi:nlei,nldj:nlej)' |
---|
1052 | ELSE ; ishape(1:2)=SHAPE(pv_r2d(1 :nlci,1 :nlcj )) ; ctmp1='d(1:nlci,1:nlcj)' |
---|
1053 | ENDIF |
---|
1054 | ENDIF |
---|
1055 | IF( irankpv == 3 ) THEN |
---|
1056 | ! JMM + SM: ugly patch before getting the new version of lib_mpp) |
---|
1057 | ! ishape(1:3) = SHAPE(pv_r3d(nldi:nlei,nldj:nlej,:)) ; ctmp1 = 'd(nldi:nlei,nldj:nlej,:)' |
---|
1058 | IF( llnoov ) THEN ; ishape(1:3)=SHAPE(pv_r3d(nldi:nlei,nldj:nlej,:)) ; ctmp1='d(nldi:nlei,nldj:nlej,:)' |
---|
1059 | ELSE ; ishape(1:3)=SHAPE(pv_r3d(1 :nlci,1 :nlcj,:)) ; ctmp1='d(1:nlci,1:nlcj,:)' |
---|
1060 | ENDIF |
---|
1061 | ENDIF |
---|
1062 | ENDIF |
---|
1063 | |
---|
1064 | DO jl = 1, irankpv |
---|
1065 | WRITE( ctmp2, FMT="(', ', i1,'): ', i5,' /= icnt(', i1,'):', i5)" ) jl, ishape(jl), jl, icnt(jl) |
---|
1066 | IF( ishape(jl) /= icnt(jl) ) CALL ctl_stop( TRIM(clinfo), 'size(pv_r'//clrankpv//TRIM(ctmp1)//TRIM(ctmp2) ) |
---|
1067 | END DO |
---|
1068 | |
---|
1069 | ENDIF |
---|
1070 | |
---|
1071 | ! read the data |
---|
1072 | !- |
---|
1073 | IF( idvar > 0 .AND. istop == nstop ) THEN ! no additional errors until this point... |
---|
1074 | ! |
---|
1075 | ! find the right index of the array to be read |
---|
1076 | ! JMM + SM: ugly patch before getting the new version of lib_mpp) |
---|
1077 | ! IF( idom /= jpdom_unknown ) THEN ; ix1 = nldi ; ix2 = nlei ; iy1 = nldj ; iy2 = nlej |
---|
1078 | ! ELSE ; ix1 = 1 ; ix2 = icnt(1) ; iy1 = 1 ; iy2 = icnt(2) |
---|
1079 | ! ENDIF |
---|
1080 | IF( llnoov ) THEN |
---|
1081 | IF( idom /= jpdom_unknown ) THEN ; ix1 = nldi ; ix2 = nlei ; iy1 = nldj ; iy2 = nlej |
---|
1082 | ELSE ; ix1 = 1 ; ix2 = icnt(1) ; iy1 = 1 ; iy2 = icnt(2) |
---|
1083 | ENDIF |
---|
1084 | ELSE |
---|
1085 | IF( idom /= jpdom_unknown ) THEN ; ix1 = 1 ; ix2 = nlci ; iy1 = 1 ; iy2 = nlcj |
---|
1086 | ELSE ; ix1 = 1 ; ix2 = icnt(1) ; iy1 = 1 ; iy2 = icnt(2) |
---|
1087 | ENDIF |
---|
1088 | ENDIF |
---|
1089 | |
---|
1090 | SELECT CASE (iom_file(kiomid)%iolib) |
---|
1091 | CASE (jpnf90 ) ; CALL iom_nf90_get( kiomid, idvar, inbdim, istart, icnt, ix1, ix2, iy1, iy2, & |
---|
1092 | & pv_r1d, pv_r2d, pv_r3d ) |
---|
1093 | CASE DEFAULT |
---|
1094 | CALL ctl_stop( TRIM(clinfo)//' accepted IO library is only jpnf90 (jpioipsl option has been removed)' ) |
---|
1095 | END SELECT |
---|
1096 | |
---|
1097 | IF( istop == nstop ) THEN ! no additional errors until this point... |
---|
1098 | IF(lwp) WRITE(numout,"(10x,' read ',a,' (rec: ',i6,') in ',a,' ok')") TRIM(cdvar), itime, TRIM(iom_file(kiomid)%name) |
---|
1099 | |
---|
1100 | !--- overlap areas and extra hallows (mpp) |
---|
1101 | IF( PRESENT(pv_r2d) .AND. idom /= jpdom_unknown ) THEN |
---|
1102 | CALL lbc_lnk( pv_r2d,'Z',-999.,'no0' ) |
---|
1103 | ELSEIF( PRESENT(pv_r3d) .AND. idom /= jpdom_unknown ) THEN |
---|
1104 | ! this if could be simplified with the new lbc_lnk that works with any size of the 3rd dimension |
---|
1105 | IF( icnt(3) == jpk ) THEN |
---|
1106 | CALL lbc_lnk( pv_r3d,'Z',-999.,'no0' ) |
---|
1107 | ELSE ! put some arbitrary value (a call to lbc_lnk will be done later...) |
---|
1108 | DO jj = nlcj+1, jpj ; pv_r3d(1:nlci, jj, :) = pv_r3d(1:nlci, nlej, :) ; END DO |
---|
1109 | DO ji = nlci+1, jpi ; pv_r3d(ji , : , :) = pv_r3d(nlei , : , :) ; END DO |
---|
1110 | ENDIF |
---|
1111 | ENDIF |
---|
1112 | ! |
---|
1113 | ELSE |
---|
1114 | ! return if istop == nstop is false |
---|
1115 | RETURN |
---|
1116 | ENDIF |
---|
1117 | ELSE |
---|
1118 | ! return if statment idvar > 0 .AND. istop == nstop is false |
---|
1119 | RETURN |
---|
1120 | ENDIF |
---|
1121 | ! |
---|
1122 | ELSE ! read using XIOS. Only if KEY_IOMPUT is defined |
---|
1123 | #if defined key_iomput |
---|
1124 | !would be good to be able to check which context is active and swap only if current is not restart |
---|
1125 | CALL iom_swap( TRIM(crxios_context) ) |
---|
1126 | IF( PRESENT(pv_r3d) ) THEN |
---|
1127 | if(lwp) write(numout,*) 'XIOS RST READ (3D): ',trim(cdvar) |
---|
1128 | CALL xios_recv_field( trim(cdvar), pv_r3d) |
---|
1129 | IF(idom /= jpdom_unknown ) then |
---|
1130 | CALL lbc_lnk( pv_r3d,'Z',-999.,'no0' ) |
---|
1131 | ENDIF |
---|
1132 | ELSEIF( PRESENT(pv_r2d) ) THEN |
---|
1133 | if(lwp) write(numout,*) 'XIOS RST READ (2D): ', trim(cdvar) |
---|
1134 | CALL xios_recv_field( trim(cdvar), pv_r2d) |
---|
1135 | IF(idom /= jpdom_unknown ) THEN |
---|
1136 | CALL lbc_lnk(pv_r2d,'Z',-999.,'no0') |
---|
1137 | ENDIF |
---|
1138 | ELSEIF( PRESENT(pv_r1d) ) THEN |
---|
1139 | if(lwp) write(numout,*) 'XIOS RST READ (1D): ', trim(cdvar) |
---|
1140 | CALL xios_recv_field( trim(cdvar), pv_r1d) |
---|
1141 | ENDIF |
---|
1142 | CALL iom_swap( TRIM(cxios_context) ) |
---|
1143 | #else |
---|
1144 | istop = istop + 1 |
---|
1145 | clinfo = 'Can not use XIOS in iom_get_123d, file: '//trim(clname)//', var:'//trim(cdvar) |
---|
1146 | #endif |
---|
1147 | ENDIF |
---|
1148 | !some final adjustments |
---|
1149 | ! C1D case : always call lbc_lnk to replicate the central value over the whole 3X3 domain |
---|
1150 | IF( lk_c1d .AND. PRESENT(pv_r2d) ) CALL lbc_lnk( pv_r2d,'Z',1. ) |
---|
1151 | IF( lk_c1d .AND. PRESENT(pv_r3d) ) CALL lbc_lnk( pv_r3d,'Z',1. ) |
---|
1152 | |
---|
1153 | !--- Apply scale_factor and offset |
---|
1154 | zscf = iom_file(kiomid)%scf(idvar) ! scale factor |
---|
1155 | zofs = iom_file(kiomid)%ofs(idvar) ! offset |
---|
1156 | IF( PRESENT(pv_r1d) ) THEN |
---|
1157 | IF( zscf /= 1. ) pv_r1d(:) = pv_r1d(:) * zscf |
---|
1158 | IF( zofs /= 0. ) pv_r1d(:) = pv_r1d(:) + zofs |
---|
1159 | ELSEIF( PRESENT(pv_r2d) ) THEN |
---|
1160 | IF( zscf /= 1.) pv_r2d(:,:) = pv_r2d(:,:) * zscf |
---|
1161 | IF( zofs /= 0.) pv_r2d(:,:) = pv_r2d(:,:) + zofs |
---|
1162 | ELSEIF( PRESENT(pv_r3d) ) THEN |
---|
1163 | IF( zscf /= 1.) pv_r3d(:,:,:) = pv_r3d(:,:,:) * zscf |
---|
1164 | IF( zofs /= 0.) pv_r3d(:,:,:) = pv_r3d(:,:,:) + zofs |
---|
1165 | ENDIF |
---|
1166 | END SUBROUTINE iom_get_123d |
---|
1167 | |
---|
1168 | |
---|
1169 | SUBROUTINE iom_gettime( kiomid, ptime, cdvar, kntime, cdunits, cdcalendar ) |
---|
1170 | !!-------------------------------------------------------------------- |
---|
1171 | !! *** SUBROUTINE iom_gettime *** |
---|
1172 | !! |
---|
1173 | !! ** Purpose : read the time axis cdvar in the file |
---|
1174 | !!-------------------------------------------------------------------- |
---|
1175 | INTEGER , INTENT(in ) :: kiomid ! file Identifier |
---|
1176 | REAL(wp), DIMENSION(:) , INTENT( out) :: ptime ! the time axis |
---|
1177 | CHARACTER(len=*), OPTIONAL , INTENT(in ) :: cdvar ! time axis name |
---|
1178 | INTEGER , OPTIONAL , INTENT( out) :: kntime ! number of times in file |
---|
1179 | CHARACTER(len=*), OPTIONAL , INTENT( out) :: cdunits ! units attribute of time coordinate |
---|
1180 | CHARACTER(len=*), OPTIONAL , INTENT( out) :: cdcalendar ! calendar attribute of |
---|
1181 | ! |
---|
1182 | INTEGER, DIMENSION(1) :: kdimsz |
---|
1183 | INTEGER :: idvar ! id of the variable |
---|
1184 | CHARACTER(LEN=32) :: tname ! local name of time coordinate |
---|
1185 | CHARACTER(LEN=100) :: clinfo ! info character |
---|
1186 | !--------------------------------------------------------------------- |
---|
1187 | ! |
---|
1188 | IF ( PRESENT(cdvar) ) THEN |
---|
1189 | tname = cdvar |
---|
1190 | ELSE |
---|
1191 | tname = iom_file(kiomid)%uldname |
---|
1192 | ENDIF |
---|
1193 | IF( kiomid > 0 ) THEN |
---|
1194 | clinfo = 'iom_gettime, file: '//trim(iom_file(kiomid)%name)//', var: '//trim(tname) |
---|
1195 | IF ( PRESENT(kntime) ) THEN |
---|
1196 | idvar = iom_varid( kiomid, tname, kdimsz = kdimsz ) |
---|
1197 | kntime = kdimsz(1) |
---|
1198 | ELSE |
---|
1199 | idvar = iom_varid( kiomid, tname ) |
---|
1200 | ENDIF |
---|
1201 | ! |
---|
1202 | ptime(:) = 0. ! default definition |
---|
1203 | IF( idvar > 0 ) THEN |
---|
1204 | IF( iom_file(kiomid)%ndims(idvar) == 1 ) THEN |
---|
1205 | IF( iom_file(kiomid)%luld(idvar) ) THEN |
---|
1206 | IF( iom_file(kiomid)%dimsz(1,idvar) <= size(ptime) ) THEN |
---|
1207 | SELECT CASE (iom_file(kiomid)%iolib) |
---|
1208 | CASE (jpnf90 ) ; CALL iom_nf90_gettime( kiomid, idvar, ptime, cdunits, cdcalendar ) |
---|
1209 | CASE DEFAULT |
---|
1210 | CALL ctl_stop( TRIM(clinfo)//' accepted IO library is only jpnf90 (jpioipsl option has been removed)' ) |
---|
1211 | END SELECT |
---|
1212 | ELSE |
---|
1213 | WRITE(ctmp1,*) 'error with the size of ptime ',size(ptime),iom_file(kiomid)%dimsz(1,idvar) |
---|
1214 | CALL ctl_stop( trim(clinfo), trim(ctmp1) ) |
---|
1215 | ENDIF |
---|
1216 | ELSE |
---|
1217 | CALL ctl_stop( trim(clinfo), 'variable dimension is not unlimited... use iom_get' ) |
---|
1218 | ENDIF |
---|
1219 | ELSE |
---|
1220 | CALL ctl_stop( trim(clinfo), 'the variable has more than 1 dimension' ) |
---|
1221 | ENDIF |
---|
1222 | ELSE |
---|
1223 | CALL ctl_stop( trim(clinfo), 'variable not found in '//iom_file(kiomid)%name ) |
---|
1224 | ENDIF |
---|
1225 | ENDIF |
---|
1226 | ! |
---|
1227 | END SUBROUTINE iom_gettime |
---|
1228 | |
---|
1229 | |
---|
1230 | !!---------------------------------------------------------------------- |
---|
1231 | !! INTERFACE iom_getatt |
---|
1232 | !!---------------------------------------------------------------------- |
---|
1233 | SUBROUTINE iom_g0d_iatt( kiomid, cdatt, pvar, cdvar ) |
---|
1234 | INTEGER , INTENT(in ) :: kiomid ! Identifier of the file |
---|
1235 | CHARACTER(len=*), INTENT(in ) :: cdatt ! Name of the attribute |
---|
1236 | INTEGER , INTENT( out) :: pvar ! read field |
---|
1237 | CHARACTER(len=*), INTENT(in ), OPTIONAL :: cdvar ! Name of the variable |
---|
1238 | ! |
---|
1239 | IF( kiomid > 0 ) THEN |
---|
1240 | IF( iom_file(kiomid)%nfid > 0 ) THEN |
---|
1241 | SELECT CASE (iom_file(kiomid)%iolib) |
---|
1242 | CASE (jpnf90 ) ; IF( PRESENT(cdvar) ) THEN |
---|
1243 | CALL iom_nf90_getatt( kiomid, cdatt, pvar, cdvar=cdvar ) |
---|
1244 | ELSE |
---|
1245 | CALL iom_nf90_getatt( kiomid, cdatt, pvar ) |
---|
1246 | ENDIF |
---|
1247 | CASE DEFAULT |
---|
1248 | CALL ctl_stop( 'iom_g0d_iatt: accepted IO library is only jpnf90' ) |
---|
1249 | END SELECT |
---|
1250 | ENDIF |
---|
1251 | ENDIF |
---|
1252 | END SUBROUTINE iom_g0d_iatt |
---|
1253 | |
---|
1254 | SUBROUTINE iom_g0d_ratt( kiomid, cdatt, pvar, cdvar ) |
---|
1255 | INTEGER , INTENT(in ) :: kiomid ! Identifier of the file |
---|
1256 | CHARACTER(len=*), INTENT(in ) :: cdatt ! Name of the attribute |
---|
1257 | REAL(wp) , INTENT( out) :: pvar ! written field |
---|
1258 | CHARACTER(len=*), INTENT(in ), OPTIONAL :: cdvar ! Name of the variable |
---|
1259 | ! |
---|
1260 | IF( kiomid > 0 ) THEN |
---|
1261 | IF( iom_file(kiomid)%nfid > 0 ) THEN |
---|
1262 | SELECT CASE (iom_file(kiomid)%iolib) |
---|
1263 | CASE (jpnf90 ) ; IF( PRESENT(cdvar) ) THEN |
---|
1264 | CALL iom_nf90_getatt( kiomid, cdatt, pvar, cdvar=cdvar ) |
---|
1265 | ELSE |
---|
1266 | CALL iom_nf90_getatt( kiomid, cdatt, pvar ) |
---|
1267 | ENDIF |
---|
1268 | CASE DEFAULT |
---|
1269 | CALL ctl_stop( 'iom_g0d_ratt: accepted IO library is only jpnf90' ) |
---|
1270 | END SELECT |
---|
1271 | ENDIF |
---|
1272 | ENDIF |
---|
1273 | END SUBROUTINE iom_g0d_ratt |
---|
1274 | |
---|
1275 | SUBROUTINE iom_g0d_catt( kiomid, cdatt, pvar, cdvar ) |
---|
1276 | INTEGER , INTENT(in ) :: kiomid ! Identifier of the file |
---|
1277 | CHARACTER(len=*), INTENT(in ) :: cdatt ! Name of the attribute |
---|
1278 | CHARACTER(len=*), INTENT( out) :: pvar ! written field |
---|
1279 | CHARACTER(len=*), INTENT(in ), OPTIONAL :: cdvar ! Name of the variable |
---|
1280 | ! |
---|
1281 | IF( kiomid > 0 ) THEN |
---|
1282 | IF( iom_file(kiomid)%nfid > 0 ) THEN |
---|
1283 | SELECT CASE (iom_file(kiomid)%iolib) |
---|
1284 | CASE (jpnf90 ) ; IF( PRESENT(cdvar) ) THEN |
---|
1285 | CALL iom_nf90_getatt( kiomid, cdatt, pvar, cdvar=cdvar ) |
---|
1286 | ELSE |
---|
1287 | CALL iom_nf90_getatt( kiomid, cdatt, pvar ) |
---|
1288 | ENDIF |
---|
1289 | CASE DEFAULT |
---|
1290 | CALL ctl_stop( 'iom_g0d_ratt: accepted IO library is only jpnf90' ) |
---|
1291 | END SELECT |
---|
1292 | ENDIF |
---|
1293 | ENDIF |
---|
1294 | END SUBROUTINE iom_g0d_catt |
---|
1295 | |
---|
1296 | !!---------------------------------------------------------------------- |
---|
1297 | !! INTERFACE iom_putatt |
---|
1298 | !!---------------------------------------------------------------------- |
---|
1299 | SUBROUTINE iom_p0d_iatt( kiomid, cdatt, pvar, cdvar ) |
---|
1300 | INTEGER , INTENT(in ) :: kiomid ! Identifier of the file |
---|
1301 | CHARACTER(len=*), INTENT(in ) :: cdatt ! Name of the attribute |
---|
1302 | INTEGER , INTENT(in ) :: pvar ! write field |
---|
1303 | CHARACTER(len=*), INTENT(in ), OPTIONAL :: cdvar ! Name of the variable |
---|
1304 | ! |
---|
1305 | IF( kiomid > 0 ) THEN |
---|
1306 | IF( iom_file(kiomid)%nfid > 0 ) THEN |
---|
1307 | SELECT CASE (iom_file(kiomid)%iolib) |
---|
1308 | CASE (jpnf90 ) ; IF( PRESENT(cdvar) ) THEN |
---|
1309 | CALL iom_nf90_putatt( kiomid, cdatt, pvar, cdvar=cdvar ) |
---|
1310 | ELSE |
---|
1311 | CALL iom_nf90_putatt( kiomid, cdatt, pvar ) |
---|
1312 | ENDIF |
---|
1313 | CASE DEFAULT |
---|
1314 | CALL ctl_stop( 'iom_p0d_iatt: accepted IO library is only jpnf90' ) |
---|
1315 | END SELECT |
---|
1316 | ENDIF |
---|
1317 | ENDIF |
---|
1318 | END SUBROUTINE iom_p0d_iatt |
---|
1319 | |
---|
1320 | SUBROUTINE iom_p0d_ratt( kiomid, cdatt, pvar, cdvar ) |
---|
1321 | INTEGER , INTENT(in ) :: kiomid ! Identifier of the file |
---|
1322 | CHARACTER(len=*), INTENT(in ) :: cdatt ! Name of the attribute |
---|
1323 | REAL(wp) , INTENT(in ) :: pvar ! write field |
---|
1324 | CHARACTER(len=*), INTENT(in ), OPTIONAL :: cdvar ! Name of the variable |
---|
1325 | ! |
---|
1326 | IF( kiomid > 0 ) THEN |
---|
1327 | IF( iom_file(kiomid)%nfid > 0 ) THEN |
---|
1328 | SELECT CASE (iom_file(kiomid)%iolib) |
---|
1329 | CASE (jpnf90 ) ; IF( PRESENT(cdvar) ) THEN |
---|
1330 | CALL iom_nf90_putatt( kiomid, cdatt, pvar, cdvar=cdvar ) |
---|
1331 | ELSE |
---|
1332 | CALL iom_nf90_putatt( kiomid, cdatt, pvar ) |
---|
1333 | ENDIF |
---|
1334 | CASE DEFAULT |
---|
1335 | CALL ctl_stop( 'iom_p0d_ratt: accepted IO library is only jpnf90' ) |
---|
1336 | END SELECT |
---|
1337 | ENDIF |
---|
1338 | ENDIF |
---|
1339 | END SUBROUTINE iom_p0d_ratt |
---|
1340 | |
---|
1341 | SUBROUTINE iom_p0d_catt( kiomid, cdatt, pvar, cdvar ) |
---|
1342 | INTEGER , INTENT(in ) :: kiomid ! Identifier of the file |
---|
1343 | CHARACTER(len=*), INTENT(in ) :: cdatt ! Name of the attribute |
---|
1344 | CHARACTER(len=*), INTENT(in ) :: pvar ! write field |
---|
1345 | CHARACTER(len=*), INTENT(in ), OPTIONAL :: cdvar ! Name of the variable |
---|
1346 | ! |
---|
1347 | IF( kiomid > 0 ) THEN |
---|
1348 | IF( iom_file(kiomid)%nfid > 0 ) THEN |
---|
1349 | SELECT CASE (iom_file(kiomid)%iolib) |
---|
1350 | CASE (jpnf90 ) ; IF( PRESENT(cdvar) ) THEN |
---|
1351 | CALL iom_nf90_putatt( kiomid, cdatt, pvar, cdvar=cdvar ) |
---|
1352 | ELSE |
---|
1353 | CALL iom_nf90_putatt( kiomid, cdatt, pvar ) |
---|
1354 | ENDIF |
---|
1355 | CASE DEFAULT |
---|
1356 | CALL ctl_stop( 'iom_p0d_ratt: accepted IO library is only jpnf90' ) |
---|
1357 | END SELECT |
---|
1358 | ENDIF |
---|
1359 | ENDIF |
---|
1360 | END SUBROUTINE iom_p0d_catt |
---|
1361 | |
---|
1362 | !!---------------------------------------------------------------------- |
---|
1363 | !! INTERFACE iom_rstput |
---|
1364 | !!---------------------------------------------------------------------- |
---|
1365 | SUBROUTINE iom_rp0d( kt, kwrite, kiomid, cdvar, pvar, ktype ) |
---|
1366 | INTEGER , INTENT(in) :: kt ! ocean time-step |
---|
1367 | INTEGER , INTENT(in) :: kwrite ! writing time-step |
---|
1368 | INTEGER , INTENT(in) :: kiomid ! Identifier of the file |
---|
1369 | CHARACTER(len=*), INTENT(in) :: cdvar ! time axis name |
---|
1370 | REAL(wp) , INTENT(in) :: pvar ! written field |
---|
1371 | INTEGER , INTENT(in), OPTIONAL :: ktype ! variable external type |
---|
1372 | INTEGER :: ivid ! variable id |
---|
1373 | IF( kiomid > 0 ) THEN |
---|
1374 | IF( iom_file(kiomid)%nfid > 0 ) THEN |
---|
1375 | ivid = iom_varid( kiomid, cdvar, ldstop = .FALSE. ) |
---|
1376 | SELECT CASE (iom_file(kiomid)%iolib) |
---|
1377 | CASE (jpnf90 ) ; CALL iom_nf90_rstput( kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r0d = pvar ) |
---|
1378 | CASE DEFAULT |
---|
1379 | CALL ctl_stop( 'iom_rp0d: accepted IO library is only jpnf90 (jpioipsl option has been removed)' ) |
---|
1380 | END SELECT |
---|
1381 | ENDIF |
---|
1382 | ENDIF |
---|
1383 | END SUBROUTINE iom_rp0d |
---|
1384 | |
---|
1385 | SUBROUTINE iom_rp1d( kt, kwrite, kiomid, cdvar, pvar, ktype ) |
---|
1386 | INTEGER , INTENT(in) :: kt ! ocean time-step |
---|
1387 | INTEGER , INTENT(in) :: kwrite ! writing time-step |
---|
1388 | INTEGER , INTENT(in) :: kiomid ! Identifier of the file |
---|
1389 | CHARACTER(len=*), INTENT(in) :: cdvar ! time axis name |
---|
1390 | REAL(wp) , INTENT(in), DIMENSION( :) :: pvar ! written field |
---|
1391 | INTEGER , INTENT(in), OPTIONAL :: ktype ! variable external type |
---|
1392 | INTEGER :: ivid ! variable id |
---|
1393 | IF( kiomid > 0 ) THEN |
---|
1394 | IF( iom_file(kiomid)%nfid > 0 ) THEN |
---|
1395 | ivid = iom_varid( kiomid, cdvar, ldstop = .FALSE. ) |
---|
1396 | SELECT CASE (iom_file(kiomid)%iolib) |
---|
1397 | CASE (jpnf90 ) ; CALL iom_nf90_rstput( kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r1d = pvar ) |
---|
1398 | CASE DEFAULT |
---|
1399 | CALL ctl_stop( 'iom_rp1d: accepted IO library is only jpnf90 (jpioipsl option has been removed)' ) |
---|
1400 | END SELECT |
---|
1401 | ENDIF |
---|
1402 | ENDIF |
---|
1403 | END SUBROUTINE iom_rp1d |
---|
1404 | |
---|
1405 | SUBROUTINE iom_rp2d( kt, kwrite, kiomid, cdvar, pvar, ktype ) |
---|
1406 | INTEGER , INTENT(in) :: kt ! ocean time-step |
---|
1407 | INTEGER , INTENT(in) :: kwrite ! writing time-step |
---|
1408 | INTEGER , INTENT(in) :: kiomid ! Identifier of the file |
---|
1409 | CHARACTER(len=*), INTENT(in) :: cdvar ! time axis name |
---|
1410 | REAL(wp) , INTENT(in), DIMENSION(:, : ) :: pvar ! written field |
---|
1411 | INTEGER , INTENT(in), OPTIONAL :: ktype ! variable external type |
---|
1412 | INTEGER :: ivid ! variable id |
---|
1413 | IF( kiomid > 0 ) THEN |
---|
1414 | IF( iom_file(kiomid)%nfid > 0 ) THEN |
---|
1415 | ivid = iom_varid( kiomid, cdvar, ldstop = .FALSE. ) |
---|
1416 | SELECT CASE (iom_file(kiomid)%iolib) |
---|
1417 | CASE (jpnf90 ) ; CALL iom_nf90_rstput( kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r2d = pvar ) |
---|
1418 | CASE DEFAULT |
---|
1419 | CALL ctl_stop( 'iom_rp2d: accepted IO library is only jpnf90 (jpioipsl option has been removed)' ) |
---|
1420 | END SELECT |
---|
1421 | ENDIF |
---|
1422 | ENDIF |
---|
1423 | END SUBROUTINE iom_rp2d |
---|
1424 | |
---|
1425 | SUBROUTINE iom_rp3d( kt, kwrite, kiomid, cdvar, pvar, ktype ) |
---|
1426 | INTEGER , INTENT(in) :: kt ! ocean time-step |
---|
1427 | INTEGER , INTENT(in) :: kwrite ! writing time-step |
---|
1428 | INTEGER , INTENT(in) :: kiomid ! Identifier of the file |
---|
1429 | CHARACTER(len=*), INTENT(in) :: cdvar ! time axis name |
---|
1430 | REAL(wp) , INTENT(in), DIMENSION(:,:,:) :: pvar ! written field |
---|
1431 | INTEGER , INTENT(in), OPTIONAL :: ktype ! variable external type |
---|
1432 | INTEGER :: ivid ! variable id |
---|
1433 | IF( kiomid > 0 ) THEN |
---|
1434 | IF( iom_file(kiomid)%nfid > 0 ) THEN |
---|
1435 | ivid = iom_varid( kiomid, cdvar, ldstop = .FALSE. ) |
---|
1436 | SELECT CASE (iom_file(kiomid)%iolib) |
---|
1437 | CASE (jpnf90 ) ; CALL iom_nf90_rstput( kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r3d = pvar ) |
---|
1438 | CASE DEFAULT |
---|
1439 | CALL ctl_stop( 'iom_rp3d: accepted IO library is only jpnf90 (jpioipsl option has been removed)' ) |
---|
1440 | END SELECT |
---|
1441 | ENDIF |
---|
1442 | ENDIF |
---|
1443 | END SUBROUTINE iom_rp3d |
---|
1444 | |
---|
1445 | |
---|
1446 | !!---------------------------------------------------------------------- |
---|
1447 | !! INTERFACE iom_put |
---|
1448 | !!---------------------------------------------------------------------- |
---|
1449 | SUBROUTINE iom_p0d( cdname, pfield0d ) |
---|
1450 | CHARACTER(LEN=*), INTENT(in) :: cdname |
---|
1451 | REAL(wp) , INTENT(in) :: pfield0d |
---|
1452 | REAL(wp) , DIMENSION(jpi,jpj) :: zz ! masson |
---|
1453 | #if defined key_iomput |
---|
1454 | zz(:,:)=pfield0d |
---|
1455 | CALL xios_send_field(cdname, zz) |
---|
1456 | !CALL xios_send_field(cdname, (/pfield0d/)) |
---|
1457 | #else |
---|
1458 | IF( .FALSE. ) WRITE(numout,*) cdname, pfield0d ! useless test to avoid compilation warnings |
---|
1459 | #endif |
---|
1460 | END SUBROUTINE iom_p0d |
---|
1461 | |
---|
1462 | SUBROUTINE iom_p1d( cdname, pfield1d ) |
---|
1463 | CHARACTER(LEN=*) , INTENT(in) :: cdname |
---|
1464 | REAL(wp), DIMENSION(:), INTENT(in) :: pfield1d |
---|
1465 | #if defined key_iomput |
---|
1466 | CALL xios_send_field( cdname, RESHAPE( (/pfield1d/), (/1,1,SIZE(pfield1d)/) ) ) |
---|
1467 | #else |
---|
1468 | IF( .FALSE. ) WRITE(numout,*) cdname, pfield1d ! useless test to avoid compilation warnings |
---|
1469 | #endif |
---|
1470 | END SUBROUTINE iom_p1d |
---|
1471 | |
---|
1472 | SUBROUTINE iom_p2d( cdname, pfield2d ) |
---|
1473 | CHARACTER(LEN=*) , INTENT(in) :: cdname |
---|
1474 | REAL(wp), DIMENSION(:,:), INTENT(in) :: pfield2d |
---|
1475 | #if defined key_iomput |
---|
1476 | CALL xios_send_field(cdname, pfield2d) |
---|
1477 | #else |
---|
1478 | IF( .FALSE. ) WRITE(numout,*) cdname, pfield2d ! useless test to avoid compilation warnings |
---|
1479 | #endif |
---|
1480 | END SUBROUTINE iom_p2d |
---|
1481 | |
---|
1482 | SUBROUTINE iom_p3d( cdname, pfield3d ) |
---|
1483 | CHARACTER(LEN=*) , INTENT(in) :: cdname |
---|
1484 | REAL(wp), DIMENSION(:,:,:), INTENT(in) :: pfield3d |
---|
1485 | #if defined key_iomput |
---|
1486 | CALL xios_send_field(cdname, pfield3d) |
---|
1487 | #else |
---|
1488 | IF( .FALSE. ) WRITE(numout,*) cdname, pfield3d ! useless test to avoid compilation warnings |
---|
1489 | #endif |
---|
1490 | END SUBROUTINE iom_p3d |
---|
1491 | !!---------------------------------------------------------------------- |
---|
1492 | |
---|
1493 | #if defined key_iomput |
---|
1494 | |
---|
1495 | SUBROUTINE iom_set_domain_attr( cdid, ni_glo, nj_glo, ibegin, jbegin, ni, nj, zoom_ibegin, zoom_jbegin, zoom_ni, zoom_nj, & |
---|
1496 | & data_dim, data_ibegin, data_ni, data_jbegin, data_nj, lonvalue, latvalue, mask, & |
---|
1497 | & nvertex, bounds_lon, bounds_lat, area ) |
---|
1498 | CHARACTER(LEN=*) , INTENT(in) :: cdid |
---|
1499 | INTEGER , OPTIONAL, INTENT(in) :: ni_glo, nj_glo, ibegin, jbegin, ni, nj |
---|
1500 | INTEGER , OPTIONAL, INTENT(in) :: data_dim, data_ibegin, data_ni, data_jbegin, data_nj |
---|
1501 | INTEGER , OPTIONAL, INTENT(in) :: zoom_ibegin, zoom_jbegin, zoom_ni, zoom_nj, nvertex |
---|
1502 | REAL(wp), DIMENSION(:) , OPTIONAL, INTENT(in) :: lonvalue, latvalue |
---|
1503 | REAL(wp), DIMENSION(:,:) , OPTIONAL, INTENT(in) :: bounds_lon, bounds_lat, area |
---|
1504 | LOGICAL, DIMENSION(:) , OPTIONAL, INTENT(in) :: mask |
---|
1505 | |
---|
1506 | |
---|
1507 | IF ( xios_is_valid_domain (cdid) ) THEN |
---|
1508 | CALL xios_set_domain_attr ( cdid, ni_glo=ni_glo, nj_glo=nj_glo, ibegin=ibegin, jbegin=jbegin, ni=ni, nj=nj, & |
---|
1509 | & data_dim=data_dim, data_ibegin=data_ibegin, data_ni=data_ni, data_jbegin=data_jbegin, data_nj=data_nj , & |
---|
1510 | & lonvalue_1D=lonvalue, latvalue_1D=latvalue, mask_1D=mask, nvertex=nvertex, bounds_lon_1D=bounds_lon, & |
---|
1511 | & bounds_lat_1D=bounds_lat, area=area, type='curvilinear') |
---|
1512 | ENDIF |
---|
1513 | IF ( xios_is_valid_domaingroup(cdid) ) THEN |
---|
1514 | CALL xios_set_domaingroup_attr( cdid, ni_glo=ni_glo, nj_glo=nj_glo, ibegin=ibegin, jbegin=jbegin, ni=ni, nj=nj, & |
---|
1515 | & data_dim=data_dim, data_ibegin=data_ibegin, data_ni=data_ni, data_jbegin=data_jbegin, data_nj=data_nj , & |
---|
1516 | & lonvalue_1D=lonvalue, latvalue_1D=latvalue, mask_1D=mask, nvertex=nvertex, bounds_lon_1D=bounds_lon, & |
---|
1517 | & bounds_lat_1D=bounds_lat, area=area, type='curvilinear' ) |
---|
1518 | ENDIF |
---|
1519 | |
---|
1520 | CALL xios_solve_inheritance() |
---|
1521 | |
---|
1522 | END SUBROUTINE iom_set_domain_attr |
---|
1523 | |
---|
1524 | |
---|
1525 | SUBROUTINE iom_set_zoom_domain_attr( cdid, ibegin, jbegin, ni, nj) |
---|
1526 | CHARACTER(LEN=*) , INTENT(in) :: cdid |
---|
1527 | INTEGER , OPTIONAL, INTENT(in) :: ibegin, jbegin, ni, nj |
---|
1528 | |
---|
1529 | IF ( xios_is_valid_zoom_domain (cdid) ) THEN |
---|
1530 | CALL xios_set_zoom_domain_attr ( cdid, ibegin=ibegin, jbegin=jbegin, ni=ni, & |
---|
1531 | & nj=nj) |
---|
1532 | ENDIF |
---|
1533 | END SUBROUTINE iom_set_zoom_domain_attr |
---|
1534 | |
---|
1535 | |
---|
1536 | SUBROUTINE iom_set_axis_attr( cdid, paxis, bounds ) |
---|
1537 | CHARACTER(LEN=*) , INTENT(in) :: cdid |
---|
1538 | REAL(wp), DIMENSION(:) , OPTIONAL, INTENT(in) :: paxis |
---|
1539 | REAL(wp), DIMENSION(:,:), OPTIONAL, INTENT(in) :: bounds |
---|
1540 | |
---|
1541 | IF ( PRESENT(paxis) ) THEN |
---|
1542 | IF ( xios_is_valid_axis (cdid) ) CALL xios_set_axis_attr ( cdid, n_glo=SIZE(paxis), value=paxis ) |
---|
1543 | IF ( xios_is_valid_axisgroup(cdid) ) CALL xios_set_axisgroup_attr( cdid, n_glo=SIZE(paxis), value=paxis ) |
---|
1544 | ENDIF |
---|
1545 | IF ( xios_is_valid_axis (cdid) ) CALL xios_set_axis_attr ( cdid, bounds=bounds ) |
---|
1546 | IF ( xios_is_valid_axisgroup(cdid) ) CALL xios_set_axisgroup_attr( cdid, bounds=bounds ) |
---|
1547 | CALL xios_solve_inheritance() |
---|
1548 | END SUBROUTINE iom_set_axis_attr |
---|
1549 | |
---|
1550 | |
---|
1551 | SUBROUTINE iom_set_field_attr( cdid, freq_op, freq_offset ) |
---|
1552 | CHARACTER(LEN=*) , INTENT(in) :: cdid |
---|
1553 | TYPE(xios_duration),OPTIONAL , INTENT(in) :: freq_op |
---|
1554 | TYPE(xios_duration),OPTIONAL , INTENT(in) :: freq_offset |
---|
1555 | IF ( xios_is_valid_field (cdid) ) CALL xios_set_field_attr & |
---|
1556 | & ( cdid, freq_op=freq_op, freq_offset=freq_offset ) |
---|
1557 | IF ( xios_is_valid_fieldgroup(cdid) ) CALL xios_set_fieldgroup_attr & |
---|
1558 | & ( cdid, freq_op=freq_op, freq_offset=freq_offset ) |
---|
1559 | CALL xios_solve_inheritance() |
---|
1560 | END SUBROUTINE iom_set_field_attr |
---|
1561 | |
---|
1562 | |
---|
1563 | SUBROUTINE iom_set_file_attr( cdid, name, name_suffix ) |
---|
1564 | CHARACTER(LEN=*) , INTENT(in) :: cdid |
---|
1565 | CHARACTER(LEN=*),OPTIONAL , INTENT(in) :: name, name_suffix |
---|
1566 | IF ( xios_is_valid_file (cdid) ) CALL xios_set_file_attr ( cdid, name=name, name_suffix=name_suffix ) |
---|
1567 | IF ( xios_is_valid_filegroup(cdid) ) CALL xios_set_filegroup_attr( cdid, name=name, name_suffix=name_suffix ) |
---|
1568 | CALL xios_solve_inheritance() |
---|
1569 | END SUBROUTINE iom_set_file_attr |
---|
1570 | |
---|
1571 | |
---|
1572 | SUBROUTINE iom_get_file_attr( cdid, name, name_suffix, output_freq ) |
---|
1573 | CHARACTER(LEN=*) , INTENT(in ) :: cdid |
---|
1574 | CHARACTER(LEN=*),OPTIONAL , INTENT(out) :: name, name_suffix |
---|
1575 | TYPE(xios_duration), OPTIONAL , INTENT(out) :: output_freq |
---|
1576 | LOGICAL :: llexist1,llexist2,llexist3 |
---|
1577 | !--------------------------------------------------------------------- |
---|
1578 | IF( PRESENT( name ) ) name = '' ! default values |
---|
1579 | IF( PRESENT( name_suffix ) ) name_suffix = '' |
---|
1580 | IF( PRESENT( output_freq ) ) output_freq = xios_duration(0,0,0,0,0,0) |
---|
1581 | IF ( xios_is_valid_file (cdid) ) THEN |
---|
1582 | CALL xios_solve_inheritance() |
---|
1583 | CALL xios_is_defined_file_attr ( cdid, name = llexist1, name_suffix = llexist2, output_freq = llexist3) |
---|
1584 | IF(llexist1) CALL xios_get_file_attr ( cdid, name = name ) |
---|
1585 | IF(llexist2) CALL xios_get_file_attr ( cdid, name_suffix = name_suffix ) |
---|
1586 | IF(llexist3) CALL xios_get_file_attr ( cdid, output_freq = output_freq ) |
---|
1587 | ENDIF |
---|
1588 | IF ( xios_is_valid_filegroup(cdid) ) THEN |
---|
1589 | CALL xios_solve_inheritance() |
---|
1590 | CALL xios_is_defined_filegroup_attr( cdid, name = llexist1, name_suffix = llexist2, output_freq = llexist3) |
---|
1591 | IF(llexist1) CALL xios_get_filegroup_attr( cdid, name = name ) |
---|
1592 | IF(llexist2) CALL xios_get_filegroup_attr( cdid, name_suffix = name_suffix ) |
---|
1593 | IF(llexist3) CALL xios_get_filegroup_attr( cdid, output_freq = output_freq ) |
---|
1594 | ENDIF |
---|
1595 | END SUBROUTINE iom_get_file_attr |
---|
1596 | |
---|
1597 | |
---|
1598 | SUBROUTINE iom_set_grid_attr( cdid, mask ) |
---|
1599 | CHARACTER(LEN=*) , INTENT(in) :: cdid |
---|
1600 | LOGICAL, DIMENSION(:,:,:), OPTIONAL, INTENT(in) :: mask |
---|
1601 | IF ( xios_is_valid_grid (cdid) ) CALL xios_set_grid_attr ( cdid, mask_3D=mask ) |
---|
1602 | IF ( xios_is_valid_gridgroup(cdid) ) CALL xios_set_gridgroup_attr( cdid, mask_3D=mask ) |
---|
1603 | CALL xios_solve_inheritance() |
---|
1604 | END SUBROUTINE iom_set_grid_attr |
---|
1605 | |
---|
1606 | SUBROUTINE iom_setkt( kt, cdname ) |
---|
1607 | INTEGER , INTENT(in) :: kt |
---|
1608 | CHARACTER(LEN=*), INTENT(in) :: cdname |
---|
1609 | ! |
---|
1610 | CALL iom_swap( cdname ) ! swap to cdname context |
---|
1611 | CALL xios_update_calendar(kt) |
---|
1612 | IF( cdname /= TRIM(cxios_context) ) CALL iom_swap( TRIM(cxios_context) ) ! return back to nemo context |
---|
1613 | ! |
---|
1614 | END SUBROUTINE iom_setkt |
---|
1615 | |
---|
1616 | SUBROUTINE iom_context_finalize( cdname ) |
---|
1617 | CHARACTER(LEN=*), INTENT(in) :: cdname |
---|
1618 | ! |
---|
1619 | IF( xios_is_valid_context(cdname) ) THEN |
---|
1620 | CALL iom_swap( cdname ) ! swap to cdname context |
---|
1621 | CALL xios_context_finalize() ! finalize the context |
---|
1622 | IF( cdname /= TRIM(cxios_context) ) CALL iom_swap( TRIM(cxios_context) ) ! return back to nemo context |
---|
1623 | ENDIF |
---|
1624 | ! |
---|
1625 | END SUBROUTINE iom_context_finalize |
---|
1626 | |
---|
1627 | |
---|
1628 | SUBROUTINE set_grid( cdgrd, plon, plat, ldxios ) |
---|
1629 | !!---------------------------------------------------------------------- |
---|
1630 | !! *** ROUTINE set_grid *** |
---|
1631 | !! |
---|
1632 | !! ** Purpose : define horizontal grids |
---|
1633 | !! |
---|
1634 | !!---------------------------------------------------------------------- |
---|
1635 | CHARACTER(LEN=1) , INTENT(in) :: cdgrd |
---|
1636 | REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: plon |
---|
1637 | REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: plat |
---|
1638 | ! |
---|
1639 | REAL(wp), DIMENSION(jpi,jpj,jpk) :: zmask |
---|
1640 | INTEGER :: ni,nj |
---|
1641 | LOGICAL, INTENT(IN) :: ldxios |
---|
1642 | |
---|
1643 | ni=nlei-nldi+1 ; nj=nlej-nldj+1 |
---|
1644 | |
---|
1645 | CALL iom_set_domain_attr("grid_"//cdgrd, ni_glo=jpiglo, nj_glo=jpjglo, ibegin=nimpp+nldi-2, jbegin=njmpp+nldj-2, ni=ni, nj=nj) |
---|
1646 | CALL iom_set_domain_attr("grid_"//cdgrd, data_dim=2, data_ibegin = 1-nldi, data_ni = jpi, data_jbegin = 1-nldj, data_nj = jpj) |
---|
1647 | CALL iom_set_domain_attr("grid_"//cdgrd, lonvalue = RESHAPE(plon(nldi:nlei, nldj:nlej),(/ ni*nj /)), & |
---|
1648 | & latvalue = RESHAPE(plat(nldi:nlei, nldj:nlej),(/ ni*nj /))) |
---|
1649 | |
---|
1650 | IF ( ln_mskland.AND.(.NOT.ldxios) ) THEN |
---|
1651 | ! mask land points, keep values on coast line -> specific mask for U, V and W points |
---|
1652 | SELECT CASE ( cdgrd ) |
---|
1653 | CASE('T') ; zmask(:,:,:) = tmask(:,:,:) |
---|
1654 | CASE('U') ; zmask(2:jpim1,:,:) = tmask(2:jpim1,:,:) + tmask(3:jpi,:,:) ; CALL lbc_lnk( zmask, 'U', 1. ) |
---|
1655 | CASE('V') ; zmask(:,2:jpjm1,:) = tmask(:,2:jpjm1,:) + tmask(:,3:jpj,:) ; CALL lbc_lnk( zmask, 'V', 1. ) |
---|
1656 | CASE('W') ; zmask(:,:,2:jpk ) = tmask(:,:,1:jpkm1) + tmask(:,:,2:jpk) ; zmask(:,:,1) = tmask(:,:,1) |
---|
1657 | END SELECT |
---|
1658 | ! |
---|
1659 | CALL iom_set_domain_attr( "grid_"//cdgrd , mask = RESHAPE(zmask(nldi:nlei,nldj:nlej,1),(/ni*nj /)) /= 0. ) |
---|
1660 | CALL iom_set_grid_attr ( "grid_"//cdgrd//"_3D", mask = RESHAPE(zmask(nldi:nlei,nldj:nlej,:),(/ni,nj,jpk/)) /= 0. ) |
---|
1661 | ENDIF |
---|
1662 | |
---|
1663 | END SUBROUTINE set_grid |
---|
1664 | |
---|
1665 | |
---|
1666 | SUBROUTINE set_grid_bounds( cdgrd, plon_cnr, plat_cnr, plon_pnt, plat_pnt ) |
---|
1667 | !!---------------------------------------------------------------------- |
---|
1668 | !! *** ROUTINE set_grid_bounds *** |
---|
1669 | !! |
---|
1670 | !! ** Purpose : define horizontal grid corners |
---|
1671 | !! |
---|
1672 | !!---------------------------------------------------------------------- |
---|
1673 | CHARACTER(LEN=1) , INTENT(in) :: cdgrd |
---|
1674 | ! |
---|
1675 | REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: plon_cnr, plat_cnr ! Lat/lon coordinates of a contiguous vertex of cell (i,j) |
---|
1676 | REAL(wp), DIMENSION(jpi,jpj), OPTIONAL, INTENT(in) :: plon_pnt, plat_pnt ! Lat/lon coordinates of the point of cell (i,j) |
---|
1677 | ! |
---|
1678 | REAL(wp), ALLOCATABLE, DIMENSION(:,:,:,:) :: z_bnds ! Lat/lon coordinates of the vertices of cell (i,j) |
---|
1679 | REAL(wp), ALLOCATABLE, DIMENSION(:,:) :: z_fld ! Working array to determine where to rotate cells |
---|
1680 | REAL(wp), ALLOCATABLE, DIMENSION(:,:) :: z_rot ! Lat/lon working array for rotation of cells |
---|
1681 | ! |
---|
1682 | INTEGER :: icnr, jcnr ! Offset such that the vertex coordinate (i+icnr,j+jcnr) |
---|
1683 | ! ! represents the bottom-left corner of cell (i,j) |
---|
1684 | INTEGER :: ji, jj, jn, ni, nj |
---|
1685 | |
---|
1686 | ALLOCATE( z_bnds(4,jpi,jpj,2), z_fld(jpi,jpj), z_rot(4,2) ) |
---|
1687 | |
---|
1688 | ! Offset of coordinate representing bottom-left corner |
---|
1689 | SELECT CASE ( TRIM(cdgrd) ) |
---|
1690 | CASE ('T', 'W', 'N') |
---|
1691 | icnr = -1 ; jcnr = -1 |
---|
1692 | CASE ('U') |
---|
1693 | icnr = 0 ; jcnr = -1 |
---|
1694 | CASE ('V') |
---|
1695 | icnr = -1 ; jcnr = 0 |
---|
1696 | END SELECT |
---|
1697 | |
---|
1698 | ni = nlei-nldi+1 ; nj = nlej-nldj+1 ! Dimensions of subdomain interior |
---|
1699 | |
---|
1700 | z_fld(:,:) = 1._wp |
---|
1701 | CALL lbc_lnk( z_fld, cdgrd, -1. ) ! Working array for location of northfold |
---|
1702 | |
---|
1703 | ! Cell vertices that can be defined |
---|
1704 | DO jj = 2, jpjm1 |
---|
1705 | DO ji = 2, jpim1 |
---|
1706 | z_bnds(1,ji,jj,1) = plat_cnr(ji+icnr, jj+jcnr ) ! Bottom-left |
---|
1707 | z_bnds(2,ji,jj,1) = plat_cnr(ji+icnr+1,jj+jcnr ) ! Bottom-right |
---|
1708 | z_bnds(3,ji,jj,1) = plat_cnr(ji+icnr+1,jj+jcnr+1) ! Top-right |
---|
1709 | z_bnds(4,ji,jj,1) = plat_cnr(ji+icnr, jj+jcnr+1) ! Top-left |
---|
1710 | z_bnds(1,ji,jj,2) = plon_cnr(ji+icnr, jj+jcnr ) ! Bottom-left |
---|
1711 | z_bnds(2,ji,jj,2) = plon_cnr(ji+icnr+1,jj+jcnr ) ! Bottom-right |
---|
1712 | z_bnds(3,ji,jj,2) = plon_cnr(ji+icnr+1,jj+jcnr+1) ! Top-right |
---|
1713 | z_bnds(4,ji,jj,2) = plon_cnr(ji+icnr, jj+jcnr+1) ! Top-left |
---|
1714 | END DO |
---|
1715 | END DO |
---|
1716 | |
---|
1717 | ! Cell vertices on boundries |
---|
1718 | DO jn = 1, 4 |
---|
1719 | CALL lbc_lnk( z_bnds(jn,:,:,1), cdgrd, 1., pval=999._wp ) |
---|
1720 | CALL lbc_lnk( z_bnds(jn,:,:,2), cdgrd, 1., pval=999._wp ) |
---|
1721 | END DO |
---|
1722 | |
---|
1723 | ! Zero-size cells at closed boundaries if cell points provided, |
---|
1724 | ! otherwise they are closed cells with unrealistic bounds |
---|
1725 | IF( PRESENT(plon_pnt) .AND. PRESENT(plat_pnt) ) THEN |
---|
1726 | IF( (nbondi == -1 .OR. nbondi == 2) .AND. .NOT. (jperio == 1 .OR. jperio == 4 .OR. jperio == 6) ) THEN |
---|
1727 | DO jn = 1, 4 ! (West or jpni = 1), closed E-W |
---|
1728 | z_bnds(jn,1,:,1) = plat_pnt(1,:) ; z_bnds(jn,1,:,2) = plon_pnt(1,:) |
---|
1729 | END DO |
---|
1730 | ENDIF |
---|
1731 | IF( (nbondi == 1 .OR. nbondi == 2) .AND. .NOT. (jperio == 1 .OR. jperio == 4 .OR. jperio == 6) ) THEN |
---|
1732 | DO jn = 1, 4 ! (East or jpni = 1), closed E-W |
---|
1733 | z_bnds(jn,nlci,:,1) = plat_pnt(nlci,:) ; z_bnds(jn,nlci,:,2) = plon_pnt(nlci,:) |
---|
1734 | END DO |
---|
1735 | ENDIF |
---|
1736 | IF( nbondj == -1 .OR. (nbondj == 2 .AND. jperio /= 2) ) THEN |
---|
1737 | DO jn = 1, 4 ! South or (jpnj = 1, not symmetric) |
---|
1738 | z_bnds(jn,:,1,1) = plat_pnt(:,1) ; z_bnds(jn,:,1,2) = plon_pnt(:,1) |
---|
1739 | END DO |
---|
1740 | ENDIF |
---|
1741 | IF( (nbondj == 1 .OR. nbondj == 2) .AND. jperio < 3 ) THEN |
---|
1742 | DO jn = 1, 4 ! (North or jpnj = 1), no north fold |
---|
1743 | z_bnds(jn,:,nlcj,1) = plat_pnt(:,nlcj) ; z_bnds(jn,:,nlcj,2) = plon_pnt(:,nlcj) |
---|
1744 | END DO |
---|
1745 | ENDIF |
---|
1746 | ENDIF |
---|
1747 | |
---|
1748 | ! Rotate cells at the north fold |
---|
1749 | IF( (nbondj == 1 .OR. nbondj == 2) .AND. jperio >= 3 ) THEN |
---|
1750 | DO jj = 1, jpj |
---|
1751 | DO ji = 1, jpi |
---|
1752 | IF( z_fld(ji,jj) == -1. ) THEN |
---|
1753 | z_rot(1,:) = z_bnds(3,ji,jj,:) ; z_rot(2,:) = z_bnds(4,ji,jj,:) |
---|
1754 | z_rot(3,:) = z_bnds(1,ji,jj,:) ; z_rot(4,:) = z_bnds(2,ji,jj,:) |
---|
1755 | z_bnds(:,ji,jj,:) = z_rot(:,:) |
---|
1756 | ENDIF |
---|
1757 | END DO |
---|
1758 | END DO |
---|
1759 | |
---|
1760 | ! Invert cells at the symmetric equator |
---|
1761 | ELSE IF( nbondj == 2 .AND. jperio == 2 ) THEN |
---|
1762 | DO ji = 1, jpi |
---|
1763 | z_rot(1:2,:) = z_bnds(3:4,ji,1,:) |
---|
1764 | z_rot(3:4,:) = z_bnds(1:2,ji,1,:) |
---|
1765 | z_bnds(:,ji,1,:) = z_rot(:,:) |
---|
1766 | END DO |
---|
1767 | ENDIF |
---|
1768 | |
---|
1769 | CALL iom_set_domain_attr("grid_"//cdgrd, bounds_lat = RESHAPE(z_bnds(:,nldi:nlei,nldj:nlej,1),(/ 4,ni*nj /)), & |
---|
1770 | bounds_lon = RESHAPE(z_bnds(:,nldi:nlei,nldj:nlej,2),(/ 4,ni*nj /)), nvertex=4 ) |
---|
1771 | |
---|
1772 | DEALLOCATE( z_bnds, z_fld, z_rot ) |
---|
1773 | |
---|
1774 | END SUBROUTINE set_grid_bounds |
---|
1775 | |
---|
1776 | |
---|
1777 | SUBROUTINE set_grid_znl( plat ) |
---|
1778 | !!---------------------------------------------------------------------- |
---|
1779 | !! *** ROUTINE set_grid_znl *** |
---|
1780 | !! |
---|
1781 | !! ** Purpose : define grids for zonal mean |
---|
1782 | !! |
---|
1783 | !!---------------------------------------------------------------------- |
---|
1784 | REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: plat |
---|
1785 | ! |
---|
1786 | REAL(wp), DIMENSION(:), ALLOCATABLE :: zlon |
---|
1787 | INTEGER :: ni,nj, ix, iy |
---|
1788 | |
---|
1789 | |
---|
1790 | ni=nlei-nldi+1 ; nj=nlej-nldj+1 ! define zonal mean domain (jpj*jpk) |
---|
1791 | ALLOCATE( zlon(ni*nj) ) ; zlon(:) = 0. |
---|
1792 | |
---|
1793 | CALL dom_ngb( -168.53, 65.03, ix, iy, 'T' ) ! i-line that passes through Bering Strait: Reference latitude (used in plots) |
---|
1794 | CALL iom_set_domain_attr("gznl", ni_glo=jpiglo, nj_glo=jpjglo, ibegin=nimpp+nldi-2, jbegin=njmpp+nldj-2, ni=ni, nj=nj) |
---|
1795 | CALL iom_set_domain_attr("gznl", data_dim=2, data_ibegin = 1-nldi, data_ni = jpi, data_jbegin = 1-nldj, data_nj = jpj) |
---|
1796 | CALL iom_set_domain_attr("gznl", lonvalue = zlon, & |
---|
1797 | & latvalue = RESHAPE(plat(nldi:nlei, nldj:nlej),(/ ni*nj /))) |
---|
1798 | CALL iom_set_zoom_domain_attr ("ptr", ibegin=ix-1, jbegin=0, ni=1, nj=jpjglo) |
---|
1799 | ! |
---|
1800 | CALL iom_update_file_name('ptr') |
---|
1801 | ! |
---|
1802 | END SUBROUTINE set_grid_znl |
---|
1803 | |
---|
1804 | SUBROUTINE set_scalar |
---|
1805 | !!---------------------------------------------------------------------- |
---|
1806 | !! *** ROUTINE set_scalar *** |
---|
1807 | !! |
---|
1808 | !! ** Purpose : define fake grids for scalar point |
---|
1809 | !! |
---|
1810 | !!---------------------------------------------------------------------- |
---|
1811 | REAL(wp), DIMENSION(1) :: zz = 1. |
---|
1812 | !!---------------------------------------------------------------------- |
---|
1813 | |
---|
1814 | CALL iom_set_domain_attr('scalarpoint', ni_glo=jpnij, nj_glo=1, ibegin=narea-1, jbegin=0, ni=1, nj=1) |
---|
1815 | CALL iom_set_domain_attr('scalarpoint', data_dim=2, data_ibegin = 1, data_ni = 1, data_jbegin = 1, data_nj = 1) |
---|
1816 | |
---|
1817 | zz=REAL(narea,wp) |
---|
1818 | CALL iom_set_domain_attr('scalarpoint', lonvalue=zz, latvalue=zz) |
---|
1819 | |
---|
1820 | END SUBROUTINE set_scalar |
---|
1821 | |
---|
1822 | |
---|
1823 | SUBROUTINE set_xmlatt |
---|
1824 | !!---------------------------------------------------------------------- |
---|
1825 | !! *** ROUTINE set_xmlatt *** |
---|
1826 | !! |
---|
1827 | !! ** Purpose : automatic definitions of some of the xml attributs... |
---|
1828 | !! |
---|
1829 | !!---------------------------------------------------------------------- |
---|
1830 | CHARACTER(len=1),DIMENSION( 3) :: clgrd ! suffix name |
---|
1831 | CHARACTER(len=256) :: clsuff ! suffix name |
---|
1832 | CHARACTER(len=1) :: cl1 ! 1 character |
---|
1833 | CHARACTER(len=2) :: cl2 ! 2 characters |
---|
1834 | CHARACTER(len=3) :: cl3 ! 3 characters |
---|
1835 | INTEGER :: ji, jg ! loop counters |
---|
1836 | INTEGER :: ix, iy ! i-,j- index |
---|
1837 | REAL(wp) ,DIMENSION(11) :: zlontao ! longitudes of tao moorings |
---|
1838 | REAL(wp) ,DIMENSION( 7) :: zlattao ! latitudes of tao moorings |
---|
1839 | REAL(wp) ,DIMENSION( 4) :: zlonrama ! longitudes of rama moorings |
---|
1840 | REAL(wp) ,DIMENSION(11) :: zlatrama ! latitudes of rama moorings |
---|
1841 | REAL(wp) ,DIMENSION( 3) :: zlonpira ! longitudes of pirata moorings |
---|
1842 | REAL(wp) ,DIMENSION( 9) :: zlatpira ! latitudes of pirata moorings |
---|
1843 | TYPE(xios_duration) :: f_op, f_of |
---|
1844 | !!---------------------------------------------------------------------- |
---|
1845 | ! |
---|
1846 | ! frequency of the call of iom_put (attribut: freq_op) |
---|
1847 | f_op%timestep = 1 ; f_of%timestep = 0 ; CALL iom_set_field_attr('field_definition', freq_op=f_op, freq_offset=f_of) |
---|
1848 | f_op%timestep = nn_fsbc ; f_of%timestep = 0 ; CALL iom_set_field_attr('SBC' , freq_op=f_op, freq_offset=f_of) |
---|
1849 | f_op%timestep = nn_fsbc ; f_of%timestep = 0 ; CALL iom_set_field_attr('SBC_scalar' , freq_op=f_op, freq_offset=f_of) |
---|
1850 | f_op%timestep = nn_dttrc ; f_of%timestep = 0 ; CALL iom_set_field_attr('ptrc_T' , freq_op=f_op, freq_offset=f_of) |
---|
1851 | f_op%timestep = nn_dttrc ; f_of%timestep = 0 ; CALL iom_set_field_attr('diad_T' , freq_op=f_op, freq_offset=f_of) |
---|
1852 | |
---|
1853 | ! output file names (attribut: name) |
---|
1854 | DO ji = 1, 9 |
---|
1855 | WRITE(cl1,'(i1)') ji |
---|
1856 | CALL iom_update_file_name('file'//cl1) |
---|
1857 | END DO |
---|
1858 | DO ji = 1, 99 |
---|
1859 | WRITE(cl2,'(i2.2)') ji |
---|
1860 | CALL iom_update_file_name('file'//cl2) |
---|
1861 | END DO |
---|
1862 | DO ji = 1, 999 |
---|
1863 | WRITE(cl3,'(i3.3)') ji |
---|
1864 | CALL iom_update_file_name('file'//cl3) |
---|
1865 | END DO |
---|
1866 | |
---|
1867 | ! Zooms... |
---|
1868 | clgrd = (/ 'T', 'U', 'W' /) |
---|
1869 | DO jg = 1, SIZE(clgrd) ! grid type |
---|
1870 | cl1 = clgrd(jg) |
---|
1871 | ! Equatorial section (attributs: jbegin, ni, name_suffix) |
---|
1872 | CALL dom_ngb( 0., 0., ix, iy, cl1 ) |
---|
1873 | CALL iom_set_zoom_domain_attr ('Eq'//cl1, jbegin=iy-1, ni=jpiglo) |
---|
1874 | CALL iom_get_file_attr ('Eq'//cl1, name_suffix = clsuff ) |
---|
1875 | CALL iom_set_file_attr ('Eq'//cl1, name_suffix = TRIM(clsuff)//'_Eq') |
---|
1876 | CALL iom_update_file_name('Eq'//cl1) |
---|
1877 | END DO |
---|
1878 | ! TAO moorings (attributs: ibegin, jbegin, name_suffix) |
---|
1879 | zlontao = (/ 137.0, 147.0, 156.0, 165.0, -180.0, -170.0, -155.0, -140.0, -125.0, -110.0, -95.0 /) |
---|
1880 | zlattao = (/ -8.0, -5.0, -2.0, 0.0, 2.0, 5.0, 8.0 /) |
---|
1881 | CALL set_mooring( zlontao, zlattao ) |
---|
1882 | ! RAMA moorings (attributs: ibegin, jbegin, name_suffix) |
---|
1883 | zlonrama = (/ 55.0, 67.0, 80.5, 90.0 /) |
---|
1884 | zlatrama = (/ -16.0, -12.0, -8.0, -4.0, -1.5, 0.0, 1.5, 4.0, 8.0, 12.0, 15.0 /) |
---|
1885 | CALL set_mooring( zlonrama, zlatrama ) |
---|
1886 | ! PIRATA moorings (attributs: ibegin, jbegin, name_suffix) |
---|
1887 | zlonpira = (/ -38.0, -23.0, -10.0 /) |
---|
1888 | zlatpira = (/ -19.0, -14.0, -8.0, 0.0, 4.0, 8.0, 12.0, 15.0, 20.0 /) |
---|
1889 | CALL set_mooring( zlonpira, zlatpira ) |
---|
1890 | |
---|
1891 | |
---|
1892 | END SUBROUTINE set_xmlatt |
---|
1893 | |
---|
1894 | |
---|
1895 | SUBROUTINE set_mooring( plon, plat) |
---|
1896 | !!---------------------------------------------------------------------- |
---|
1897 | !! *** ROUTINE set_mooring *** |
---|
1898 | !! |
---|
1899 | !! ** Purpose : automatic definitions of moorings xml attributs... |
---|
1900 | !! |
---|
1901 | !!---------------------------------------------------------------------- |
---|
1902 | REAL(wp), DIMENSION(:), INTENT(in) :: plon, plat ! longitudes/latitudes oft the mooring |
---|
1903 | ! |
---|
1904 | !!$ CHARACTER(len=1),DIMENSION(4) :: clgrd = (/ 'T', 'U', 'V', 'W' /) ! suffix name |
---|
1905 | CHARACTER(len=1),DIMENSION(1) :: clgrd = (/ 'T' /) ! suffix name |
---|
1906 | CHARACTER(len=256) :: clname ! file name |
---|
1907 | CHARACTER(len=256) :: clsuff ! suffix name |
---|
1908 | CHARACTER(len=1) :: cl1 ! 1 character |
---|
1909 | CHARACTER(len=6) :: clon,clat ! name of longitude, latitude |
---|
1910 | INTEGER :: ji, jj, jg ! loop counters |
---|
1911 | INTEGER :: ix, iy ! i-,j- index |
---|
1912 | REAL(wp) :: zlon, zlat |
---|
1913 | !!---------------------------------------------------------------------- |
---|
1914 | DO jg = 1, SIZE(clgrd) |
---|
1915 | cl1 = clgrd(jg) |
---|
1916 | DO ji = 1, SIZE(plon) |
---|
1917 | DO jj = 1, SIZE(plat) |
---|
1918 | zlon = plon(ji) |
---|
1919 | zlat = plat(jj) |
---|
1920 | ! modifications for RAMA moorings |
---|
1921 | IF( zlon == 67. .AND. zlat == 15. ) zlon = 65. |
---|
1922 | IF( zlon == 90. .AND. zlat <= -4. ) zlon = 95. |
---|
1923 | IF( zlon == 95. .AND. zlat == -4. ) zlat = -5. |
---|
1924 | ! modifications for PIRATA moorings |
---|
1925 | IF( zlon == -38. .AND. zlat == -19. ) zlon = -34. |
---|
1926 | IF( zlon == -38. .AND. zlat == -14. ) zlon = -32. |
---|
1927 | IF( zlon == -38. .AND. zlat == -8. ) zlon = -30. |
---|
1928 | IF( zlon == -38. .AND. zlat == 0. ) zlon = -35. |
---|
1929 | IF( zlon == -23. .AND. zlat == 20. ) zlat = 21. |
---|
1930 | IF( zlon == -10. .AND. zlat == -14. ) zlat = -10. |
---|
1931 | IF( zlon == -10. .AND. zlat == -8. ) zlat = -6. |
---|
1932 | IF( zlon == -10. .AND. zlat == 4. ) THEN ; zlon = 0. ; zlat = 0. ; ENDIF |
---|
1933 | CALL dom_ngb( zlon, zlat, ix, iy, cl1 ) |
---|
1934 | IF( zlon >= 0. ) THEN |
---|
1935 | IF( zlon == REAL(NINT(zlon), wp) ) THEN ; WRITE(clon, '(i3, a)') NINT( zlon), 'e' |
---|
1936 | ELSE ; WRITE(clon, '(f5.1,a)') zlon , 'e' |
---|
1937 | ENDIF |
---|
1938 | ELSE |
---|
1939 | IF( zlon == REAL(NINT(zlon), wp) ) THEN ; WRITE(clon, '(i3, a)') NINT(-zlon), 'w' |
---|
1940 | ELSE ; WRITE(clon, '(f5.1,a)') -zlon , 'w' |
---|
1941 | ENDIF |
---|
1942 | ENDIF |
---|
1943 | IF( zlat >= 0. ) THEN |
---|
1944 | IF( zlat == REAL(NINT(zlat), wp) ) THEN ; WRITE(clat, '(i2, a)') NINT( zlat), 'n' |
---|
1945 | ELSE ; WRITE(clat, '(f4.1,a)') zlat , 'n' |
---|
1946 | ENDIF |
---|
1947 | ELSE |
---|
1948 | IF( zlat == REAL(NINT(zlat), wp) ) THEN ; WRITE(clat, '(i2, a)') NINT(-zlat), 's' |
---|
1949 | ELSE ; WRITE(clat, '(f4.1,a)') -zlat , 's' |
---|
1950 | ENDIF |
---|
1951 | ENDIF |
---|
1952 | clname = TRIM(ADJUSTL(clat))//TRIM(ADJUSTL(clon)) |
---|
1953 | CALL iom_set_zoom_domain_attr (TRIM(clname)//cl1, ibegin= ix-1, jbegin= iy-1) |
---|
1954 | |
---|
1955 | CALL iom_get_file_attr (TRIM(clname)//cl1, name_suffix = clsuff ) |
---|
1956 | CALL iom_set_file_attr (TRIM(clname)//cl1, name_suffix = TRIM(clsuff)//'_'//TRIM(clname)) |
---|
1957 | CALL iom_update_file_name(TRIM(clname)//cl1) |
---|
1958 | END DO |
---|
1959 | END DO |
---|
1960 | END DO |
---|
1961 | |
---|
1962 | END SUBROUTINE set_mooring |
---|
1963 | |
---|
1964 | |
---|
1965 | SUBROUTINE iom_update_file_name( cdid ) |
---|
1966 | !!---------------------------------------------------------------------- |
---|
1967 | !! *** ROUTINE iom_update_file_name *** |
---|
1968 | !! |
---|
1969 | !! ** Purpose : |
---|
1970 | !! |
---|
1971 | !!---------------------------------------------------------------------- |
---|
1972 | CHARACTER(LEN=*) , INTENT(in) :: cdid |
---|
1973 | ! |
---|
1974 | CHARACTER(LEN=256) :: clname |
---|
1975 | CHARACTER(LEN=20) :: clfreq |
---|
1976 | CHARACTER(LEN=20) :: cldate |
---|
1977 | INTEGER :: idx |
---|
1978 | INTEGER :: jn |
---|
1979 | INTEGER :: itrlen |
---|
1980 | INTEGER :: iyear, imonth, iday, isec |
---|
1981 | REAL(wp) :: zsec |
---|
1982 | LOGICAL :: llexist |
---|
1983 | TYPE(xios_duration) :: output_freq |
---|
1984 | !!---------------------------------------------------------------------- |
---|
1985 | |
---|
1986 | DO jn = 1,2 |
---|
1987 | |
---|
1988 | output_freq = xios_duration(0,0,0,0,0,0) |
---|
1989 | IF( jn == 1 ) CALL iom_get_file_attr( cdid, name = clname, output_freq = output_freq ) |
---|
1990 | IF( jn == 2 ) CALL iom_get_file_attr( cdid, name_suffix = clname ) |
---|
1991 | |
---|
1992 | IF ( TRIM(clname) /= '' ) THEN |
---|
1993 | |
---|
1994 | idx = INDEX(clname,'@expname@') + INDEX(clname,'@EXPNAME@') |
---|
1995 | DO WHILE ( idx /= 0 ) |
---|
1996 | clname = clname(1:idx-1)//TRIM(cexper)//clname(idx+9:LEN_TRIM(clname)) |
---|
1997 | idx = INDEX(clname,'@expname@') + INDEX(clname,'@EXPNAME@') |
---|
1998 | END DO |
---|
1999 | |
---|
2000 | idx = INDEX(clname,'@freq@') + INDEX(clname,'@FREQ@') |
---|
2001 | DO WHILE ( idx /= 0 ) |
---|
2002 | IF ( output_freq%timestep /= 0) THEN |
---|
2003 | WRITE(clfreq,'(I18,A2)')INT(output_freq%timestep),'ts' |
---|
2004 | itrlen = LEN_TRIM(ADJUSTL(clfreq)) |
---|
2005 | ELSE IF ( output_freq%second /= 0 ) THEN |
---|
2006 | WRITE(clfreq,'(I19,A1)')INT(output_freq%second),'s' |
---|
2007 | itrlen = LEN_TRIM(ADJUSTL(clfreq)) |
---|
2008 | ELSE IF ( output_freq%minute /= 0 ) THEN |
---|
2009 | WRITE(clfreq,'(I18,A2)')INT(output_freq%minute),'mi' |
---|
2010 | itrlen = LEN_TRIM(ADJUSTL(clfreq)) |
---|
2011 | ELSE IF ( output_freq%hour /= 0 ) THEN |
---|
2012 | WRITE(clfreq,'(I19,A1)')INT(output_freq%hour),'h' |
---|
2013 | itrlen = LEN_TRIM(ADJUSTL(clfreq)) |
---|
2014 | ELSE IF ( output_freq%day /= 0 ) THEN |
---|
2015 | WRITE(clfreq,'(I19,A1)')INT(output_freq%day),'d' |
---|
2016 | itrlen = LEN_TRIM(ADJUSTL(clfreq)) |
---|
2017 | ELSE IF ( output_freq%month /= 0 ) THEN |
---|
2018 | WRITE(clfreq,'(I19,A1)')INT(output_freq%month),'m' |
---|
2019 | itrlen = LEN_TRIM(ADJUSTL(clfreq)) |
---|
2020 | ELSE IF ( output_freq%year /= 0 ) THEN |
---|
2021 | WRITE(clfreq,'(I19,A1)')INT(output_freq%year),'y' |
---|
2022 | itrlen = LEN_TRIM(ADJUSTL(clfreq)) |
---|
2023 | ELSE |
---|
2024 | CALL ctl_stop('error in the name of file id '//TRIM(cdid), & |
---|
2025 | & ' attribute output_freq is undefined -> cannot replace @freq@ in '//TRIM(clname) ) |
---|
2026 | ENDIF |
---|
2027 | clname = clname(1:idx-1)//TRIM(ADJUSTL(clfreq))//clname(idx+6:LEN_TRIM(clname)) |
---|
2028 | idx = INDEX(clname,'@freq@') + INDEX(clname,'@FREQ@') |
---|
2029 | END DO |
---|
2030 | |
---|
2031 | idx = INDEX(clname,'@startdate@') + INDEX(clname,'@STARTDATE@') |
---|
2032 | DO WHILE ( idx /= 0 ) |
---|
2033 | cldate = iom_sdate( fjulday - rdt / rday ) |
---|
2034 | clname = clname(1:idx-1)//TRIM(cldate)//clname(idx+11:LEN_TRIM(clname)) |
---|
2035 | idx = INDEX(clname,'@startdate@') + INDEX(clname,'@STARTDATE@') |
---|
2036 | END DO |
---|
2037 | |
---|
2038 | idx = INDEX(clname,'@startdatefull@') + INDEX(clname,'@STARTDATEFULL@') |
---|
2039 | DO WHILE ( idx /= 0 ) |
---|
2040 | cldate = iom_sdate( fjulday - rdt / rday, ldfull = .TRUE. ) |
---|
2041 | clname = clname(1:idx-1)//TRIM(cldate)//clname(idx+15:LEN_TRIM(clname)) |
---|
2042 | idx = INDEX(clname,'@startdatefull@') + INDEX(clname,'@STARTDATEFULL@') |
---|
2043 | END DO |
---|
2044 | |
---|
2045 | idx = INDEX(clname,'@enddate@') + INDEX(clname,'@ENDDATE@') |
---|
2046 | DO WHILE ( idx /= 0 ) |
---|
2047 | cldate = iom_sdate( fjulday + rdt / rday * REAL( nitend - nit000, wp ), ld24 = .TRUE. ) |
---|
2048 | clname = clname(1:idx-1)//TRIM(cldate)//clname(idx+9:LEN_TRIM(clname)) |
---|
2049 | idx = INDEX(clname,'@enddate@') + INDEX(clname,'@ENDDATE@') |
---|
2050 | END DO |
---|
2051 | |
---|
2052 | idx = INDEX(clname,'@enddatefull@') + INDEX(clname,'@ENDDATEFULL@') |
---|
2053 | DO WHILE ( idx /= 0 ) |
---|
2054 | cldate = iom_sdate( fjulday + rdt / rday * REAL( nitend - nit000, wp ), ld24 = .TRUE., ldfull = .TRUE. ) |
---|
2055 | clname = clname(1:idx-1)//TRIM(cldate)//clname(idx+13:LEN_TRIM(clname)) |
---|
2056 | idx = INDEX(clname,'@enddatefull@') + INDEX(clname,'@ENDDATEFULL@') |
---|
2057 | END DO |
---|
2058 | |
---|
2059 | IF( jn == 1 .AND. TRIM(Agrif_CFixed()) /= '0' ) clname = TRIM(Agrif_CFixed())//"_"//TRIM(clname) |
---|
2060 | IF( jn == 1 ) CALL iom_set_file_attr( cdid, name = clname ) |
---|
2061 | IF( jn == 2 ) CALL iom_set_file_attr( cdid, name_suffix = clname ) |
---|
2062 | |
---|
2063 | ENDIF |
---|
2064 | |
---|
2065 | END DO |
---|
2066 | |
---|
2067 | END SUBROUTINE iom_update_file_name |
---|
2068 | |
---|
2069 | |
---|
2070 | FUNCTION iom_sdate( pjday, ld24, ldfull ) |
---|
2071 | !!---------------------------------------------------------------------- |
---|
2072 | !! *** ROUTINE iom_sdate *** |
---|
2073 | !! |
---|
2074 | !! ** Purpose : send back the date corresponding to the given julian day |
---|
2075 | !! |
---|
2076 | !!---------------------------------------------------------------------- |
---|
2077 | REAL(wp), INTENT(in ) :: pjday ! julian day |
---|
2078 | LOGICAL , INTENT(in ), OPTIONAL :: ld24 ! true to force 24:00 instead of 00:00 |
---|
2079 | LOGICAL , INTENT(in ), OPTIONAL :: ldfull ! true to get the compleate date: yyyymmdd_hh:mm:ss |
---|
2080 | ! |
---|
2081 | CHARACTER(LEN=20) :: iom_sdate |
---|
2082 | CHARACTER(LEN=50) :: clfmt ! format used to write the date |
---|
2083 | INTEGER :: iyear, imonth, iday, ihour, iminute, isec |
---|
2084 | REAL(wp) :: zsec |
---|
2085 | LOGICAL :: ll24, llfull |
---|
2086 | ! |
---|
2087 | IF( PRESENT(ld24) ) THEN ; ll24 = ld24 |
---|
2088 | ELSE ; ll24 = .FALSE. |
---|
2089 | ENDIF |
---|
2090 | |
---|
2091 | IF( PRESENT(ldfull) ) THEN ; llfull = ldfull |
---|
2092 | ELSE ; llfull = .FALSE. |
---|
2093 | ENDIF |
---|
2094 | |
---|
2095 | CALL ju2ymds( pjday, iyear, imonth, iday, zsec ) |
---|
2096 | isec = NINT(zsec) |
---|
2097 | |
---|
2098 | IF ( ll24 .AND. isec == 0 ) THEN ! 00:00 of the next day -> move to 24:00 of the current day |
---|
2099 | CALL ju2ymds( pjday - 1., iyear, imonth, iday, zsec ) |
---|
2100 | isec = 86400 |
---|
2101 | ENDIF |
---|
2102 | |
---|
2103 | IF( iyear < 10000 ) THEN ; clfmt = "i4.4,2i2.2" ! format used to write the date |
---|
2104 | ELSE ; WRITE(clfmt, "('i',i1,',2i2.2')") INT(LOG10(REAL(iyear,wp))) + 1 |
---|
2105 | ENDIF |
---|
2106 | |
---|
2107 | !$AGRIF_DO_NOT_TREAT |
---|
2108 | ! Should be fixed in the conv |
---|
2109 | IF( llfull ) THEN |
---|
2110 | clfmt = TRIM(clfmt)//",'_',i2.2,':',i2.2,':',i2.2" |
---|
2111 | ihour = isec / 3600 |
---|
2112 | isec = MOD(isec, 3600) |
---|
2113 | iminute = isec / 60 |
---|
2114 | isec = MOD(isec, 60) |
---|
2115 | WRITE(iom_sdate, '('//TRIM(clfmt)//')') iyear, imonth, iday, ihour, iminute, isec ! date of the end of run |
---|
2116 | ELSE |
---|
2117 | WRITE(iom_sdate, '('//TRIM(clfmt)//')') iyear, imonth, iday ! date of the end of run |
---|
2118 | ENDIF |
---|
2119 | !$AGRIF_END_DO_NOT_TREAT |
---|
2120 | |
---|
2121 | END FUNCTION iom_sdate |
---|
2122 | |
---|
2123 | #else |
---|
2124 | |
---|
2125 | |
---|
2126 | SUBROUTINE iom_setkt( kt, cdname ) |
---|
2127 | INTEGER , INTENT(in):: kt |
---|
2128 | CHARACTER(LEN=*), INTENT(in) :: cdname |
---|
2129 | IF( .FALSE. ) WRITE(numout,*) kt, cdname ! useless test to avoid compilation warnings |
---|
2130 | END SUBROUTINE iom_setkt |
---|
2131 | |
---|
2132 | SUBROUTINE iom_context_finalize( cdname ) |
---|
2133 | CHARACTER(LEN=*), INTENT(in) :: cdname |
---|
2134 | IF( .FALSE. ) WRITE(numout,*) cdname ! useless test to avoid compilation warnings |
---|
2135 | END SUBROUTINE iom_context_finalize |
---|
2136 | |
---|
2137 | #endif |
---|
2138 | |
---|
2139 | LOGICAL FUNCTION iom_use( cdname ) |
---|
2140 | CHARACTER(LEN=*), INTENT(in) :: cdname |
---|
2141 | #if defined key_iomput |
---|
2142 | iom_use = xios_field_is_active( cdname ) |
---|
2143 | #else |
---|
2144 | iom_use = .FALSE. |
---|
2145 | #endif |
---|
2146 | END FUNCTION iom_use |
---|
2147 | |
---|
2148 | !!====================================================================== |
---|
2149 | END MODULE iom |
---|