1 | MODULE iom |
---|
2 | !!===================================================================== |
---|
3 | !! *** MODULE iom *** |
---|
4 | !! Input/Output manager : Library to read input files |
---|
5 | !!==================================================================== |
---|
6 | !! History : 9.0 ! 05 12 (J. Belier) Original code |
---|
7 | !! 9.0 ! 06 02 (S. Masson) Adaptation to NEMO |
---|
8 | !!-------------------------------------------------------------------- |
---|
9 | !!gm caution add !DIR nec: improved performance to be checked as well as no result changes |
---|
10 | |
---|
11 | !!-------------------------------------------------------------------- |
---|
12 | !! iom_open : open a file read only |
---|
13 | !! iom_close : close a file or all files opened by iom |
---|
14 | !! iom_get : read a field (interfaced to several routines) |
---|
15 | !! iom_gettime : read the time axis cdvar in the file |
---|
16 | !! iom_varid : get the id of a variable in a file |
---|
17 | !! iom_rstput : write a field in a restart file (interfaced to several routines) |
---|
18 | !!-------------------------------------------------------------------- |
---|
19 | USE in_out_manager ! I/O manager |
---|
20 | USE dom_oce ! ocean space and time domain |
---|
21 | USE iom_def ! iom variables definitions |
---|
22 | USE iom_ioipsl ! NetCDF format with IOIPSL library |
---|
23 | USE iom_nf90 ! NetCDF format with native NetCDF library |
---|
24 | USE iom_rstdimg ! restarts access direct format "dimg" style... |
---|
25 | |
---|
26 | IMPLICIT NONE |
---|
27 | PUBLIC ! must be public to be able to access iom_def through iom |
---|
28 | |
---|
29 | PUBLIC iom_open, iom_close, iom_varid, iom_get, iom_gettime, iom_rstput |
---|
30 | |
---|
31 | INTERFACE iom_get |
---|
32 | MODULE PROCEDURE iom_g0d, iom_g1d, iom_g2d, iom_g3d |
---|
33 | END INTERFACE |
---|
34 | INTERFACE iom_rstput |
---|
35 | MODULE PROCEDURE iom_rp0d, iom_rp1d, iom_rp2d, iom_rp3d |
---|
36 | END INTERFACE |
---|
37 | |
---|
38 | !!---------------------------------------------------------------------- |
---|
39 | !! OPA 9.0 , LOCEAN-IPSL (2006) |
---|
40 | !! $Header$ |
---|
41 | !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt) |
---|
42 | !!---------------------------------------------------------------------- |
---|
43 | |
---|
44 | CONTAINS |
---|
45 | |
---|
46 | SUBROUTINE iom_open( cdname, kiomid, ldwrt, kdom, kiolib ) |
---|
47 | !!--------------------------------------------------------------------- |
---|
48 | !! *** SUBROUTINE iom_open *** |
---|
49 | !! |
---|
50 | !! ** Purpose : open an input file (return 0 if not found) |
---|
51 | !!--------------------------------------------------------------------- |
---|
52 | CHARACTER(len=*), INTENT(in ) :: cdname ! File name |
---|
53 | INTEGER , INTENT( out) :: kiomid ! iom identifier of the opened file |
---|
54 | LOGICAL , INTENT(in ), OPTIONAL :: ldwrt ! open in write modeb (default = .FALSE.) |
---|
55 | INTEGER , INTENT(in ), OPTIONAL :: kdom ! Type of domain to be written (default = jpdom_local_noovlap) |
---|
56 | INTEGER , INTENT(in ), OPTIONAL :: kiolib ! library used to open the file (default = jpnf90) |
---|
57 | |
---|
58 | CHARACTER(LEN=100) :: clname ! the name of the file based on cdname [[+clcpu]+clcpu] |
---|
59 | CHARACTER(LEN=100) :: cltmpn ! tempory name to store clname (in writting mode) |
---|
60 | CHARACTER(LEN=10) :: clsuffix ! ".nc" or ".dimg" |
---|
61 | CHARACTER(LEN=15) :: clcpu ! the cpu number (max jpmax_digits digits) |
---|
62 | CHARACTER(LEN=100) :: clinfo ! info character |
---|
63 | LOGICAL :: llok ! check the existence |
---|
64 | LOGICAL :: llwrt ! |
---|
65 | INTEGER :: iolib ! library do we use to open the file |
---|
66 | INTEGER :: icnt ! counter for digits in clcpu (max = jpmax_digits) |
---|
67 | INTEGER :: iln, ils ! lengths of character |
---|
68 | INTEGER :: idom ! type of domain |
---|
69 | INTEGER :: istop ! |
---|
70 | INTEGER, DIMENSION(2,5) :: idompar ! domain parameters: |
---|
71 | ! local number of points for x,y dimensions |
---|
72 | ! position of first local point for x,y dimensions |
---|
73 | ! position of last local point for x,y dimensions |
---|
74 | ! start halo size for x,y dimensions |
---|
75 | ! end halo size for x,y dimensions |
---|
76 | !--------------------------------------------------------------------- |
---|
77 | ! Initializations and control |
---|
78 | ! ============= |
---|
79 | clinfo = ' iom_open ~~~ ' |
---|
80 | istop = nstop |
---|
81 | ! if iom_open is called for the first time: initialize iom_file(:)%nfid to 0 |
---|
82 | ! (could be done when defining iom_file in f95 but not in f90) |
---|
83 | IF( iom_init == 0 ) THEN |
---|
84 | iom_file(:)%nfid = 0 |
---|
85 | iom_init = 1 |
---|
86 | ENDIF |
---|
87 | ! do we read or write the file? |
---|
88 | IF( PRESENT(ldwrt) ) THEN ; llwrt = ldwrt |
---|
89 | ELSE ; llwrt = .FALSE. |
---|
90 | ENDIF |
---|
91 | ! what library do we use to open the file? |
---|
92 | IF( PRESENT(kiolib) ) THEN ; iolib = kiolib |
---|
93 | ELSE ; iolib = jpnf90 |
---|
94 | ENDIF |
---|
95 | ! create the file name by added, if needed, TRIM(Agrif_CFixed()) and TRIM(clsuffix) |
---|
96 | ! ============= |
---|
97 | clname = trim(cdname) |
---|
98 | #if defined key_agrif |
---|
99 | if ( .NOT. Agrif_Root() ) clname = TRIM(Agrif_CFixed())//'_'//TRIM(clname) |
---|
100 | #endif |
---|
101 | ! which suffix should we use? |
---|
102 | SELECT CASE (iolib) |
---|
103 | CASE (jpioipsl ) ; clsuffix = '.nc' |
---|
104 | CASE (jpnf90 ) ; clsuffix = '.nc' |
---|
105 | CASE (jprstdimg) ; clsuffix = '.dimg' |
---|
106 | CASE DEFAULT ; clsuffix = '' |
---|
107 | CALL ctl_stop( TRIM(clinfo), 'accepted IO library are only jpioipsl, jpnf90 and jprstdimg' ) |
---|
108 | END SELECT |
---|
109 | ! Add the suffix if needed |
---|
110 | iln = LEN_TRIM(clname) |
---|
111 | ils = LEN_TRIM(clsuffix) |
---|
112 | IF( iln <= ils) clname = clname(1:iln)//TRIM(clsuffix) |
---|
113 | IF( clname(iln-ils+1:iln) /= TRIM(clsuffix) ) clname = clname(1:iln)//TRIM(clsuffix) |
---|
114 | cltmpn = clname ! store this name |
---|
115 | ! try to find if the file to be opened already exist |
---|
116 | ! ============= |
---|
117 | INQUIRE( FILE = clname, EXIST = llok ) |
---|
118 | IF( .NOT.llok ) THEN |
---|
119 | ! we try to add the cpu number to the name |
---|
120 | WRITE(clcpu,*) narea-1 |
---|
121 | clcpu = TRIM(ADJUSTL(clcpu)) |
---|
122 | iln = INDEX(clname,TRIM(clsuffix)) |
---|
123 | clname = clname(1:iln-1)//'_'//TRIM(clcpu)//TRIM(clsuffix) |
---|
124 | icnt = 0 |
---|
125 | INQUIRE( FILE = clname, EXIST = llok ) |
---|
126 | ! we try different formats for the cpu number by adding 0 |
---|
127 | DO WHILE( .NOT.llok .AND. icnt < jpmax_digits ) |
---|
128 | clcpu = "0"//trim(clcpu) |
---|
129 | clname = clname(1:iln-1)//'_'//TRIM(clcpu)//TRIM(clsuffix) |
---|
130 | INQUIRE( FILE = clname, EXIST = llok ) |
---|
131 | icnt = icnt + 1 |
---|
132 | END DO |
---|
133 | ENDIF |
---|
134 | ! check the domain definition |
---|
135 | idom = jpdom_local_noovlap ! default definition |
---|
136 | IF( PRESENT(kdom) ) idom = kdom |
---|
137 | ! create the domain informations |
---|
138 | ! ============= |
---|
139 | SELECT CASE (idom) |
---|
140 | CASE (jpdom_local_full) |
---|
141 | idompar(:,1) = (/ jpi , jpj /) |
---|
142 | idompar(:,2) = (/ nimpp , njmpp /) |
---|
143 | idompar(:,3) = (/ nimpp + jpi - 1 , njmpp + jpj - 1 /) |
---|
144 | idompar(:,4) = (/ nldi - 1 , nldj - 1 /) |
---|
145 | idompar(:,5) = (/ jpi - nlei , jpj - nlej /) |
---|
146 | CASE (jpdom_local_noextra) |
---|
147 | idompar(:,1) = (/ nlci , nlcj /) |
---|
148 | idompar(:,2) = (/ nimpp , njmpp /) |
---|
149 | idompar(:,3) = (/ nimpp + nlci - 1, njmpp + nlcj - 1 /) |
---|
150 | idompar(:,4) = (/ nldi - 1 , nldj - 1 /) |
---|
151 | idompar(:,5) = (/ nlci - nlei , nlcj - nlej /) |
---|
152 | CASE (jpdom_local_noovlap) |
---|
153 | idompar(:,1) = (/ nlei - nldi + 1 , nlej - nldj + 1 /) |
---|
154 | idompar(:,2) = (/ nimpp + nldi - 1, njmpp + nldj - 1 /) |
---|
155 | idompar(:,3) = (/ nimpp + nlei - 1, njmpp + nlej - 1 /) |
---|
156 | idompar(:,4) = (/ 0 , 0 /) |
---|
157 | idompar(:,5) = (/ 0 , 0 /) |
---|
158 | CASE DEFAULT |
---|
159 | CALL ctl_stop( TRIM(clinfo), 'wrong value of kdom, only jpdom_local* cases are accepted' ) |
---|
160 | END SELECT |
---|
161 | ! Open the NetCDF or RSTDIMG file |
---|
162 | ! ============= |
---|
163 | ! do we have some free file identifier? |
---|
164 | IF( MINVAL(iom_file(:)%nfid) /= 0 ) & |
---|
165 | & CALL ctl_stop( TRIM(clinfo), 'No more free file identifier', 'increase jpmax_files in iom_def' ) |
---|
166 | IF( istop == nstop ) THEN ! no error within this routine |
---|
167 | IF( .NOT. llok ) clname = cltmpn ! get back the file name without the cpu number |
---|
168 | SELECT CASE (iolib) |
---|
169 | CASE (jpioipsl ) ; CALL iom_ioipsl_open( clname, kiomid, llwrt, llok, idompar ) |
---|
170 | CASE (jpnf90 ) ; CALL iom_nf90_open( clname, kiomid, llwrt, llok, idompar ) |
---|
171 | CASE (jprstdimg) ; CALL iom_rstdimg_open( clname, kiomid, llwrt, llok, idompar ) |
---|
172 | CASE DEFAULT |
---|
173 | CALL ctl_stop( TRIM(clinfo)//' accepted IO library are only jpioipsl, jpnf90 and jprstdimg' ) |
---|
174 | END SELECT |
---|
175 | ENDIF |
---|
176 | ! |
---|
177 | END SUBROUTINE iom_open |
---|
178 | |
---|
179 | |
---|
180 | SUBROUTINE iom_close( kiomid ) |
---|
181 | !!-------------------------------------------------------------------- |
---|
182 | !! *** SUBROUTINE iom_close *** |
---|
183 | !! |
---|
184 | !! ** Purpose : close an input file, or all files opened by iom |
---|
185 | !!-------------------------------------------------------------------- |
---|
186 | INTEGER, INTENT(in), OPTIONAL :: kiomid ! iom identifier of the file to be closed |
---|
187 | ! ! No argument : all the files opened by iom are closed |
---|
188 | |
---|
189 | INTEGER :: jf ! dummy loop indices |
---|
190 | INTEGER :: i_s, i_e ! temporary integer |
---|
191 | CHARACTER(LEN=100) :: clinfo ! info character |
---|
192 | !--------------------------------------------------------------------- |
---|
193 | ! |
---|
194 | clinfo = ' iom_close ~~~ ' |
---|
195 | IF( PRESENT(kiomid) ) THEN |
---|
196 | i_s = kiomid |
---|
197 | i_e = kiomid |
---|
198 | ELSE |
---|
199 | i_s = 1 |
---|
200 | i_e = jpmax_files |
---|
201 | ENDIF |
---|
202 | |
---|
203 | IF( i_s > 0 ) THEN |
---|
204 | DO jf = i_s, i_e |
---|
205 | IF( iom_file(jf)%nfid > 0 ) THEN |
---|
206 | SELECT CASE (iom_file(jf)%iolib) |
---|
207 | CASE (jpioipsl ) ; CALL iom_ioipsl_close( jf ) |
---|
208 | CASE (jpnf90 ) ; CALL iom_nf90_close( jf ) |
---|
209 | CASE (jprstdimg) ; CALL iom_rstdimg_close( jf ) |
---|
210 | CASE DEFAULT |
---|
211 | CALL ctl_stop( TRIM(clinfo)//' accepted IO library are only jpioipsl, jpnf90 and jprstdimg' ) |
---|
212 | END SELECT |
---|
213 | iom_file(jf)%nfid = 0 ! free the id |
---|
214 | IF(lwp) WRITE(numout,*) TRIM(clinfo)//' close file: '//TRIM(iom_file(kiomid)%name)//' ok' |
---|
215 | ELSEIF( PRESENT(kiomid) ) THEN |
---|
216 | WRITE(ctmp1,*) '--->', kiomid |
---|
217 | CALL ctl_stop( TRIM(clinfo)//' Invalid file identifier', ctmp1 ) |
---|
218 | ENDIF |
---|
219 | END DO |
---|
220 | ENDIF |
---|
221 | ! |
---|
222 | END SUBROUTINE iom_close |
---|
223 | |
---|
224 | |
---|
225 | FUNCTION iom_varid ( kiomid, cdvar, kdimsz ) |
---|
226 | !!----------------------------------------------------------------------- |
---|
227 | !! *** FUNCTION iom_varid *** |
---|
228 | !! |
---|
229 | !! ** Purpose : get the id of a variable in a file (return 0 if not found) |
---|
230 | !!----------------------------------------------------------------------- |
---|
231 | INTEGER , INTENT(in ) :: kiomid ! file Identifier |
---|
232 | CHARACTER(len=*) , INTENT(in ) :: cdvar ! name of the variable |
---|
233 | INTEGER, DIMENSION(:), INTENT( out), OPTIONAL :: kdimsz ! size of the dimensions |
---|
234 | ! |
---|
235 | INTEGER :: iom_varid, iiv, i_nvd |
---|
236 | LOGICAL :: ll_fnd |
---|
237 | CHARACTER(LEN=100) :: clinfo ! info character |
---|
238 | !!----------------------------------------------------------------------- |
---|
239 | clinfo = 'iom_varid, file: '//trim(iom_file(kiomid)%name)//', var: '//trim(cdvar) |
---|
240 | iom_varid = 0 ! default definition |
---|
241 | ! |
---|
242 | IF( kiomid > 0 ) THEN |
---|
243 | IF( iom_file(kiomid)%nfid == 0 ) THEN |
---|
244 | CALL ctl_stop( trim(clinfo), 'the file is not open' ) |
---|
245 | ELSE |
---|
246 | ll_fnd = .FALSE. |
---|
247 | iiv = 0 |
---|
248 | ! |
---|
249 | DO WHILE ( .NOT.ll_fnd .AND. iiv < iom_file(kiomid)%nvars ) |
---|
250 | iiv = iiv + 1 |
---|
251 | ll_fnd = ( TRIM(cdvar) == TRIM(iom_file(kiomid)%cn_var(iiv)) ) |
---|
252 | END DO |
---|
253 | ! |
---|
254 | IF( .NOT.ll_fnd ) THEN |
---|
255 | iiv = iiv + 1 |
---|
256 | IF( iiv <= jpmax_vars ) THEN |
---|
257 | SELECT CASE (iom_file(kiomid)%iolib) |
---|
258 | CASE (jpioipsl ) ; iom_varid = iom_ioipsl_varid( kiomid, cdvar, iiv, kdimsz ) |
---|
259 | CASE (jpnf90 ) ; iom_varid = iom_nf90_varid( kiomid, cdvar, iiv, kdimsz ) |
---|
260 | CASE (jprstdimg) ; iom_varid = 0 ! all variables are listed in iom_file |
---|
261 | CASE DEFAULT |
---|
262 | CALL ctl_stop( TRIM(clinfo)//' accepted IO library are only jpioipsl, jpnf90 and jprstdimg' ) |
---|
263 | END SELECT |
---|
264 | ELSE |
---|
265 | CALL ctl_stop( trim(clinfo), 'Too many variables in the file '//iom_file(kiomid)%name, & |
---|
266 | & 'increase the parameter jpmax_vars') |
---|
267 | ENDIF |
---|
268 | ELSE |
---|
269 | iom_varid = iiv |
---|
270 | IF( PRESENT(kdimsz) ) THEN |
---|
271 | i_nvd = iom_file(kiomid)%ndims(iiv) |
---|
272 | IF( i_nvd == size(kdimsz) ) THEN |
---|
273 | kdimsz(:) = iom_file(kiomid)%dimsz(1:i_nvd,iiv) |
---|
274 | ELSE |
---|
275 | WRITE(ctmp1,*) i_nvd, size(kdimsz) |
---|
276 | CALL ctl_stop( trim(clinfo), 'error in kdimsz size'//trim(ctmp1) ) |
---|
277 | ENDIF |
---|
278 | ENDIF |
---|
279 | ENDIF |
---|
280 | ENDIF |
---|
281 | ENDIF |
---|
282 | ! |
---|
283 | END FUNCTION iom_varid |
---|
284 | |
---|
285 | |
---|
286 | !!---------------------------------------------------------------------- |
---|
287 | !! INTERFACE iom_get |
---|
288 | !!---------------------------------------------------------------------- |
---|
289 | SUBROUTINE iom_g0d( kiomid, cdvar, pvar ) |
---|
290 | INTEGER , INTENT(in ) :: kiomid ! Identifier of the file |
---|
291 | CHARACTER(len=*), INTENT(in ) :: cdvar ! Name of the variable |
---|
292 | REAL(wp) , INTENT( out) :: pvar ! read field |
---|
293 | ! |
---|
294 | INTEGER :: idvar ! variable id |
---|
295 | ! |
---|
296 | idvar = iom_varid( kiomid, cdvar ) |
---|
297 | IF( iom_file(kiomid)%nfid > 0 .AND. idvar > 0 ) THEN |
---|
298 | SELECT CASE (iom_file(kiomid)%iolib) |
---|
299 | CASE (jpioipsl ) ; CALL iom_ioipsl_get( kiomid, idvar, pvar ) |
---|
300 | CASE (jpnf90 ) ; CALL iom_nf90_get( kiomid, idvar, pvar ) |
---|
301 | CASE (jprstdimg) ; CALL iom_rstdimg_get( kiomid, idvar, pvar ) |
---|
302 | CASE DEFAULT |
---|
303 | CALL ctl_stop( 'iom_g0d: accepted IO library are only jpioipsl, jpnf90 and jprstdimg' ) |
---|
304 | END SELECT |
---|
305 | END IF |
---|
306 | END SUBROUTINE iom_g0d |
---|
307 | |
---|
308 | SUBROUTINE iom_g1d( kiomid, kdom, cdvar, pvar, ktime, kstart, kcount ) |
---|
309 | INTEGER , INTENT(in ) :: kiomid ! Identifier of the file |
---|
310 | INTEGER , INTENT(in ) :: kdom ! Type of domain to be read |
---|
311 | CHARACTER(len=*), INTENT(in ) :: cdvar ! Name of the variable |
---|
312 | REAL(wp) , INTENT( out), DIMENSION(:) :: pvar ! read field |
---|
313 | INTEGER , INTENT(in ) , OPTIONAL :: ktime ! record number |
---|
314 | INTEGER , INTENT(in ), DIMENSION(1), OPTIONAL :: kstart ! start axis position of the reading |
---|
315 | INTEGER , INTENT(in ), DIMENSION(1), OPTIONAL :: kcount ! number of points in each axis |
---|
316 | ! |
---|
317 | IF( iom_file(kiomid)%nfid > 0 ) CALL iom_get_123d( kiomid, kdom , cdvar , pv_r1d=pvar, & |
---|
318 | & ktime=ktime, kstart=kstart, kcount=kcount ) |
---|
319 | END SUBROUTINE iom_g1d |
---|
320 | |
---|
321 | SUBROUTINE iom_g2d( kiomid, kdom, cdvar, pvar, ktime, kstart, kcount ) |
---|
322 | INTEGER , INTENT(in ) :: kiomid ! Identifier of the file |
---|
323 | INTEGER , INTENT(in ) :: kdom ! Type of domain to be read |
---|
324 | CHARACTER(len=*), INTENT(in ) :: cdvar ! Name of the variable |
---|
325 | REAL(wp) , INTENT( out), DIMENSION(:,:) :: pvar ! read field |
---|
326 | INTEGER , INTENT(in ) , OPTIONAL :: ktime ! record number |
---|
327 | INTEGER , INTENT(in ), DIMENSION(2) , OPTIONAL :: kstart ! start axis position of the reading |
---|
328 | INTEGER , INTENT(in ), DIMENSION(2) , OPTIONAL :: kcount ! number of points in each axis |
---|
329 | ! |
---|
330 | IF( iom_file(kiomid)%nfid > 0 ) CALL iom_get_123d( kiomid, kdom , cdvar , pv_r2d=pvar, & |
---|
331 | & ktime=ktime, kstart=kstart, kcount=kcount ) |
---|
332 | END SUBROUTINE iom_g2d |
---|
333 | |
---|
334 | SUBROUTINE iom_g3d( kiomid, kdom, cdvar, pvar, ktime, kstart, kcount ) |
---|
335 | INTEGER , INTENT(in ) :: kiomid ! Identifier of the file |
---|
336 | INTEGER , INTENT(in ) :: kdom ! Type of domain to be read |
---|
337 | CHARACTER(len=*), INTENT(in ) :: cdvar ! Name of the variable |
---|
338 | REAL(wp) , INTENT( out), DIMENSION(:,:,:) :: pvar ! read field |
---|
339 | INTEGER , INTENT(in ) , OPTIONAL :: ktime ! record number |
---|
340 | INTEGER , INTENT(in ), DIMENSION(3) , OPTIONAL :: kstart ! start axis position of the reading |
---|
341 | INTEGER , INTENT(in ), DIMENSION(3) , OPTIONAL :: kcount ! number of points in each axis |
---|
342 | ! |
---|
343 | IF( iom_file(kiomid)%nfid > 0 ) CALL iom_get_123d( kiomid, kdom , cdvar , pv_r3d=pvar, & |
---|
344 | & ktime=ktime, kstart=kstart, kcount=kcount ) |
---|
345 | END SUBROUTINE iom_g3d |
---|
346 | !!---------------------------------------------------------------------- |
---|
347 | |
---|
348 | SUBROUTINE iom_get_123d( kiomid, kdom , cdvar , & |
---|
349 | & pv_r1d, pv_r2d, pv_r3d, & |
---|
350 | & ktime , kstart, kcount ) |
---|
351 | !!----------------------------------------------------------------------- |
---|
352 | !! *** ROUTINE iom_get_123d *** |
---|
353 | !! |
---|
354 | !! ** Purpose : read a 1D/2D/3D variable |
---|
355 | !! |
---|
356 | !! ** Method : read ONE record at each CALL |
---|
357 | !!----------------------------------------------------------------------- |
---|
358 | INTEGER , INTENT(in ) :: kiomid ! Identifier of the file |
---|
359 | INTEGER , INTENT(in ) :: kdom ! Type of domain to be read |
---|
360 | CHARACTER(len=*) , INTENT(in ) :: cdvar ! Name of the variable |
---|
361 | REAL(wp), DIMENSION(:) , INTENT( out), OPTIONAL :: pv_r1d ! read field (1D case) |
---|
362 | REAL(wp), DIMENSION(:,:) , INTENT( out), OPTIONAL :: pv_r2d ! read field (2D case) |
---|
363 | REAL(wp), DIMENSION(:,:,:) , INTENT( out), OPTIONAL :: pv_r3d ! read field (3D case) |
---|
364 | INTEGER , INTENT(in ), OPTIONAL :: ktime ! record number |
---|
365 | INTEGER , DIMENSION(:) , INTENT(in ), OPTIONAL :: kstart ! start position of the reading in each axis |
---|
366 | INTEGER , DIMENSION(:) , INTENT(in ), OPTIONAL :: kcount ! number of points to be read in each axis |
---|
367 | ! |
---|
368 | INTEGER :: jl ! loop on number of dimension |
---|
369 | INTEGER :: idom ! type of domain |
---|
370 | INTEGER :: idvar ! id of the variable |
---|
371 | INTEGER :: inbdim ! number of dimensions of the variable |
---|
372 | INTEGER :: idmspc ! number of spatial dimensions |
---|
373 | INTEGER :: itime ! record number |
---|
374 | INTEGER :: istop ! temporary value of nstop |
---|
375 | INTEGER, DIMENSION(jpmax_dims) :: istart ! starting point to read for each axis |
---|
376 | INTEGER, DIMENSION(jpmax_dims) :: icnt ! number of value to read along each axis |
---|
377 | INTEGER, DIMENSION(jpmax_dims) :: idimsz ! size of the dimensions of the variable |
---|
378 | REAL(wp) :: zscf, zofs ! sacle_factor and add_offset |
---|
379 | INTEGER :: itmp ! temporary integer |
---|
380 | CHARACTER(LEN=100) :: clinfo ! info character |
---|
381 | !--------------------------------------------------------------------- |
---|
382 | ! |
---|
383 | clinfo = ' iom_get_123d, file: '//trim(iom_file(kiomid)%name)//', var: '//trim(cdvar) |
---|
384 | ! local definition of the domain ? |
---|
385 | idom = kdom |
---|
386 | ! check kcount and kstart optionals parameters... |
---|
387 | IF( PRESENT(kcount) .AND. (.NOT. PRESENT(kstart)) ) & |
---|
388 | CALL ctl_stop( trim(clinfo), 'kcount present needs kstart present' ) |
---|
389 | IF( PRESENT(kstart) .AND. (.NOT. PRESENT(kcount)) ) & |
---|
390 | CALL ctl_stop( trim(clinfo), 'kstart present needs kcount present' ) |
---|
391 | IF( PRESENT(kstart) .AND. idom /= jpdom_unknown ) & |
---|
392 | CALL ctl_stop( trim(clinfo), 'kstart present needs kdom = jpdom_unknown' ) |
---|
393 | |
---|
394 | ! Search for the variable in the data base (eventually actualize data) |
---|
395 | istop = nstop |
---|
396 | idvar = iom_varid( kiomid, cdvar ) |
---|
397 | ! |
---|
398 | IF( idvar > 0 ) THEN |
---|
399 | ! to write iom_file(kiomid)%dimsz in a shorter way ! |
---|
400 | idimsz(:) = iom_file(kiomid)%dimsz(:, idvar) |
---|
401 | inbdim = iom_file(kiomid)%ndims(idvar) ! number of dimensions in the file |
---|
402 | idmspc = inbdim ! number of spatial dimensions in the file |
---|
403 | IF( iom_file(kiomid)%luld(idvar) ) idmspc = inbdim - 1 |
---|
404 | IF( idmspc > 3 ) CALL ctl_stop(trim(clinfo), & |
---|
405 | & 'the file has more than 3 spatial dimensions this case is not coded...' ) |
---|
406 | IF( idom == jpdom_local ) THEN ! Identify the domain in case of jpdom_local definition |
---|
407 | IF( idimsz(1) == jpi .AND. idimsz(2) == jpj ) THEN |
---|
408 | idom = jpdom_local_full |
---|
409 | ELSEIF( idimsz(1) == nlci .AND. idimsz(2) == nlcj ) THEN |
---|
410 | idom = jpdom_local_noextra |
---|
411 | ELSEIF( idimsz(1) == (nlei - nldi + 1) .AND. idimsz(2) == (nlej - nldj + 1) ) THEN |
---|
412 | idom = jpdom_local_noovlap |
---|
413 | ELSE |
---|
414 | CALL ctl_stop( trim(clinfo), 'impossible to identify the local domain' ) |
---|
415 | ENDIF |
---|
416 | ENDIF |
---|
417 | ! |
---|
418 | ! definition of istart and icnt |
---|
419 | ! |
---|
420 | ! initializations |
---|
421 | istart(:) = 1 |
---|
422 | icnt (:) = 1 |
---|
423 | itime = 1 |
---|
424 | IF( PRESENT(ktime) ) itime = ktime |
---|
425 | ! |
---|
426 | IF( PRESENT(pv_r1d) ) THEN |
---|
427 | IF( idmspc == 1 ) THEN |
---|
428 | ! data is 1d array (+ maybe a temporal dimension) |
---|
429 | IF( PRESENT(kstart) ) THEN |
---|
430 | istart(1:2) = (/ kstart(1), itime /) |
---|
431 | icnt(1) = kcount(1) |
---|
432 | ELSE |
---|
433 | IF( kdom == jpdom_unknown ) THEN |
---|
434 | istart(2) = itime |
---|
435 | icnt(1) = idimsz(1) |
---|
436 | ELSE |
---|
437 | CALL ctl_stop( trim(clinfo), 'case not coded...You must use jpdom_unknown' ) |
---|
438 | ENDIF |
---|
439 | ENDIF |
---|
440 | ELSE |
---|
441 | CALL ctl_stop( trim(clinfo), 'to keep iom lisibility, when reading a 1D array,', & |
---|
442 | & 'we do not accept data with more than 1 spatial dimension', & |
---|
443 | & 'Use ncwa -a to suppress the unnecessary dimensions') |
---|
444 | ENDIF |
---|
445 | ELSEIF( PRESENT(pv_r2d) ) THEN |
---|
446 | SELECT CASE (idmspc) |
---|
447 | CASE (1) |
---|
448 | CALL ctl_stop( trim(clinfo), 'the file has only 1 spatial dimension', & |
---|
449 | & 'it is impossible to read a 2d array from this file...') |
---|
450 | CASE (2) |
---|
451 | ! data is 2d array (+ maybe a temporal dimension) |
---|
452 | IF( PRESENT(kstart) ) THEN |
---|
453 | istart(1:3) = (/ kstart(1:2), itime /) |
---|
454 | icnt(1:2) = kcount(1:2) |
---|
455 | ELSE |
---|
456 | IF( kdom == jpdom_unknown ) THEN |
---|
457 | istart(3) = itime |
---|
458 | icnt(1:2) = idimsz(1:2) |
---|
459 | ELSE |
---|
460 | IF( idom == jpdom_data ) THEN |
---|
461 | istart(1:3) = (/ mig(1), mjg(1), itime /) |
---|
462 | ELSEIF( idom == jpdom_global ) THEN |
---|
463 | istart(1:3) = (/ nimpp, njmpp, itime /) |
---|
464 | ENDIF |
---|
465 | ! we do not read the overlap -> we start to read at nldi, nldj |
---|
466 | IF( idom /= jpdom_local_noovlap ) istart(1:2) = istart(1:2) + (/ nldi - 1, nldj - 1 /) |
---|
467 | ! we do not read the overlap and the extra-halos |
---|
468 | ! -> from nldi to nlei and from nldj to nlej |
---|
469 | icnt(1:2) = (/ nlei - nldi + 1, nlej - nldj + 1 /) |
---|
470 | ENDIF |
---|
471 | ENDIF |
---|
472 | CASE DEFAULT |
---|
473 | IF( itime == 1 .AND. idimsz(3) == 1 .AND. idmspc == 3 ) THEN |
---|
474 | CALL ctl_warn( trim(clinfo), '2D array but 3 spatial dimensions for the data...', & |
---|
475 | & 'As the size of the z dimension is 1 and as we try to read the first record, ', & |
---|
476 | & 'we accept this case even if there is a possible mix-up between z and time dimension' ) |
---|
477 | IF( PRESENT(kstart) ) THEN |
---|
478 | istart(1:2) = kstart(1:2) |
---|
479 | icnt(1:2) = kcount(1:2) |
---|
480 | ELSE |
---|
481 | IF( kdom == jpdom_unknown ) THEN |
---|
482 | icnt(1:2) = idimsz(1:2) |
---|
483 | ELSE |
---|
484 | IF( idom == jpdom_data ) THEN |
---|
485 | istart(1:2) = (/ mig(1), mjg(1) /) |
---|
486 | ELSEIF( idom == jpdom_global ) THEN |
---|
487 | istart(1:2) = (/ nimpp, njmpp /) |
---|
488 | ENDIF |
---|
489 | ! we do not read the overlap -> we start to read at nldi, nldj |
---|
490 | IF( idom /= jpdom_local_noovlap ) istart(1:2) = istart(1:2) + (/ nldi - 1, nldj - 1 /) |
---|
491 | ! we do not read the overlap and the extra-halos |
---|
492 | ! -> from nldi to nlei and from nldj to nlej |
---|
493 | icnt(1:2) = (/ nlei - nldi + 1, nlej - nldj + 1 /) |
---|
494 | ENDIF |
---|
495 | ENDIF |
---|
496 | ELSE |
---|
497 | CALL ctl_stop( trim(clinfo), 'to keep iom lisibility, when reading a 2D array,', & |
---|
498 | & 'we do not accept data with more than 2 spatial dimension', & |
---|
499 | & 'Use ncwa -a to suppress the unnecessary dimensions' ) |
---|
500 | ENDIF |
---|
501 | END SELECT |
---|
502 | ELSEIF( PRESENT(pv_r3d) ) THEN |
---|
503 | SELECT CASE (idmspc) |
---|
504 | CASE( 1 ) |
---|
505 | CALL ctl_stop( trim(clinfo), 'the file has only 1 spatial dimension', & |
---|
506 | & 'it is impossible to read a 3d array from this file...' ) |
---|
507 | CASE( 2 ) |
---|
508 | CALL ctl_stop( trim(clinfo), 'the file has only 2 spatial dimension', & |
---|
509 | & 'it is impossible to read a 3d array from this file...' ) |
---|
510 | CASE( 3 ) |
---|
511 | ! data is 3d array (+ maybe a temporal dimension) |
---|
512 | IF( PRESENT(kstart) ) THEN |
---|
513 | istart(1:4) = (/ kstart(1:3), itime /) |
---|
514 | icnt(1:3) = kcount(1:3) |
---|
515 | ELSE |
---|
516 | IF( kdom == jpdom_unknown ) THEN |
---|
517 | istart(4) = itime |
---|
518 | icnt(1:3) = idimsz(1:3) |
---|
519 | ELSE |
---|
520 | IF( idom == jpdom_data ) THEN |
---|
521 | istart(1:4) = (/ mig(1), mjg(1), 1, itime /) |
---|
522 | ELSEIF( idom == jpdom_global ) THEN |
---|
523 | istart(1:4) = (/ nimpp, njmpp, 1, itime /) |
---|
524 | ENDIF |
---|
525 | ! we do not read the overlap -> we start to read at nldi, nldj |
---|
526 | IF( idom /= jpdom_local_noovlap ) istart(1:2) = istart(1:2) + (/ nldi - 1, nldj - 1 /) |
---|
527 | ! we do not read the overlap and the extra-halos |
---|
528 | ! -> from nldi to nlei and from nldj to nlej |
---|
529 | icnt(1:2) = (/ nlei - nldi + 1, nlej - nldj + 1 /) |
---|
530 | IF( idom == jpdom_data ) THEN |
---|
531 | icnt(3) = jpkdta |
---|
532 | ELSE |
---|
533 | icnt(3) = jpk |
---|
534 | ENDIF |
---|
535 | ENDIF |
---|
536 | ENDIF |
---|
537 | CASE DEFAULT |
---|
538 | CALL ctl_stop( trim(clinfo), 'to keep iom lisibility, when reading a 3D array,', & |
---|
539 | & 'we do not accept data with more than 3 spatial dimension', & |
---|
540 | & 'Use ncwa -a to suppress the unnecessary dimensions' ) |
---|
541 | END SELECT |
---|
542 | ENDIF |
---|
543 | |
---|
544 | ! check that istart and icnt can be used with this file |
---|
545 | !- |
---|
546 | DO jl = 1, jpmax_dims |
---|
547 | itmp = istart(jl)+icnt(jl)-1 |
---|
548 | IF( (itmp) > idimsz(jl) .AND. idimsz(jl) /= 0 ) THEN |
---|
549 | WRITE(ctmp1,*) '(istart(',jl,') + icnt(',jl,') - 1) = ', itmp |
---|
550 | WRITE(ctmp2,*) ' is larger than idimsz(',jl,'): ', idimsz(jl) |
---|
551 | CALL ctl_stop( trim(clinfo), 'start and count too big regarding to the size of the data, ', ctmp1, ctmp2 ) |
---|
552 | ENDIF |
---|
553 | END DO |
---|
554 | |
---|
555 | ! check that icnt matches the input array |
---|
556 | !- |
---|
557 | IF( PRESENT(pv_r1d) ) THEN |
---|
558 | itmp = size(pv_r1d) |
---|
559 | WRITE(ctmp1,*) 'size(pv_r1d): ', itmp, ' /= icnt(1): ', icnt(1) |
---|
560 | IF( itmp /= icnt(1) ) CALL ctl_stop( trim(clinfo), ctmp1 ) |
---|
561 | ELSEIF( PRESENT(pv_r2d) ) THEN |
---|
562 | DO jl = 1, 2 |
---|
563 | IF( idom == jpdom_unknown ) THEN |
---|
564 | itmp = size(pv_r2d, jl) |
---|
565 | WRITE(ctmp1,*) 'size(pv_r2d, ',jl,'): ',itmp,' /= icnt(',jl,'): ',icnt(jl) |
---|
566 | ELSE |
---|
567 | itmp = size(pv_r2d(nldi:nlei,nldj:nlej), jl) |
---|
568 | WRITE(ctmp1,*) 'size(pv_r2d(nldi:nlei,nldj:nlej), ',jl,'): ',itmp,' /= icnt(',jl,'): ',icnt(jl) |
---|
569 | ENDIF |
---|
570 | IF( itmp /= icnt(jl) ) CALL ctl_stop( trim(clinfo), ctmp1 ) |
---|
571 | END DO |
---|
572 | ELSEIF( PRESENT(pv_r3d) ) THEN |
---|
573 | DO jl = 1, 3 |
---|
574 | IF( idom == jpdom_unknown ) THEN |
---|
575 | itmp = size(pv_r3d, jl) |
---|
576 | WRITE(ctmp1,*) 'size(pv_r3d, ',jl,'): ',itmp,' /= icnt(',jl,'):', icnt(jl) |
---|
577 | ELSE |
---|
578 | itmp = size(pv_r3d(nldi:nlei,nldj:nlej,:), jl) |
---|
579 | WRITE(ctmp1,*) 'size(pv_r3d(nldi:nlei,nldj:nlej), ',jl,'): ',itmp,' /= icnt(',jl,'): ',icnt(jl) |
---|
580 | ENDIF |
---|
581 | IF( itmp /= icnt(jl) ) CALL ctl_stop( trim(clinfo), ctmp1 ) |
---|
582 | END DO |
---|
583 | ENDIF |
---|
584 | ENDIF |
---|
585 | |
---|
586 | ! read the data |
---|
587 | !- |
---|
588 | IF( istop == nstop) THEN ! no additional errors until this point... |
---|
589 | ! |
---|
590 | SELECT CASE (iom_file(kiomid)%iolib) |
---|
591 | CASE (jpioipsl ) ; CALL iom_ioipsl_get( kiomid, idom, idvar, inbdim, istart, icnt, pv_r1d, pv_r2d, pv_r3d ) |
---|
592 | CASE (jpnf90 ) ; CALL iom_nf90_get( kiomid, idom, idvar, inbdim, istart, icnt, pv_r1d, pv_r2d, pv_r3d ) |
---|
593 | CASE (jprstdimg) ; CALL iom_rstdimg_get( kiomid, idom, idvar, istart, icnt, pv_r1d, pv_r2d, pv_r3d ) |
---|
594 | CASE DEFAULT |
---|
595 | CALL ctl_stop( TRIM(clinfo)//' accepted IO library are only jpioipsl, jpnf90 and jprstdimg' ) |
---|
596 | END SELECT |
---|
597 | IF( istop == nstop .AND. lwp ) & |
---|
598 | WRITE(numout,*) ' read '//trim(cdvar)//' in '//trim(iom_file(kiomid)%name)//' ok' |
---|
599 | !--- Apply scale_factor and offset |
---|
600 | zscf = iom_file(kiomid)%scf(idvar) ! scale factor |
---|
601 | zofs = iom_file(kiomid)%ofs(idvar) ! offset |
---|
602 | IF( PRESENT(pv_r1d) ) THEN |
---|
603 | IF( zscf /= 1. ) pv_r1d(:) = pv_r1d(:) * zscf |
---|
604 | IF( zofs /= 0. ) pv_r1d(:) = pv_r1d(:) + zofs |
---|
605 | ELSEIF( PRESENT(pv_r2d) ) THEN |
---|
606 | !CDIR COLLAPSE |
---|
607 | IF( zscf /= 1.) pv_r2d(:,:) = pv_r2d(:,:) * zscf |
---|
608 | !CDIR COLLAPSE |
---|
609 | IF( zofs /= 0.) pv_r2d(:,:) = pv_r2d(:,:) + zofs |
---|
610 | ELSEIF( PRESENT(pv_r3d) ) THEN |
---|
611 | !CDIR COLLAPSE |
---|
612 | IF( zscf /= 1.) pv_r3d(:,:,:) = pv_r3d(:,:,:) * zscf |
---|
613 | !CDIR COLLAPSE |
---|
614 | IF( zofs /= 0.) pv_r3d(:,:,:) = pv_r3d(:,:,:) + zofs |
---|
615 | ENDIF |
---|
616 | ! |
---|
617 | ENDIF |
---|
618 | ! |
---|
619 | END SUBROUTINE iom_get_123d |
---|
620 | |
---|
621 | |
---|
622 | SUBROUTINE iom_gettime( kiomid, cdvar, ptime ) |
---|
623 | !!-------------------------------------------------------------------- |
---|
624 | !! *** SUBROUTINE iom_gettime *** |
---|
625 | !! |
---|
626 | !! ** Purpose : read the time axis cdvar in the file |
---|
627 | !!-------------------------------------------------------------------- |
---|
628 | INTEGER , INTENT(in ) :: kiomid ! file Identifier |
---|
629 | CHARACTER(len=*) , INTENT(in ) :: cdvar ! time axis name |
---|
630 | REAL(wp), DIMENSION(:), INTENT( out) :: ptime ! the time axis |
---|
631 | ! |
---|
632 | INTEGER :: idvar ! id of the variable |
---|
633 | CHARACTER(LEN=100) :: clinfo ! info character |
---|
634 | !--------------------------------------------------------------------- |
---|
635 | ! |
---|
636 | clinfo = 'iom_gettime, file: '//trim(iom_file(kiomid)%name)//', var: '//trim(cdvar) |
---|
637 | idvar = iom_varid( kiomid, cdvar ) |
---|
638 | ! |
---|
639 | ptime(:) = 0. ! default definition |
---|
640 | IF( idvar > 0 ) THEN |
---|
641 | IF( iom_file(kiomid)%ndims(idvar) == 1 ) THEN |
---|
642 | IF( iom_file(kiomid)%luld(idvar) ) THEN |
---|
643 | IF( iom_file(kiomid)%dimsz(1,idvar) == size(ptime) ) THEN |
---|
644 | SELECT CASE (iom_file(kiomid)%iolib) |
---|
645 | CASE (jpioipsl ) ; CALL iom_ioipsl_gettime( kiomid, idvar, ptime ) |
---|
646 | CASE (jpnf90 ) ; CALL iom_nf90_gettime( kiomid, idvar, ptime ) |
---|
647 | CASE (jprstdimg) ; CALL ctl_stop( TRIM(clinfo)//' case IO library == jprstdimg not coded...' ) |
---|
648 | CASE DEFAULT |
---|
649 | CALL ctl_stop( TRIM(clinfo)//' accepted IO library are only jpioipsl, jpnf90 and jprstdimg' ) |
---|
650 | END SELECT |
---|
651 | ELSE |
---|
652 | WRITE(ctmp1,*) 'error with the size of ptime ',size(ptime),iom_file(kiomid)%dimsz(1,idvar) |
---|
653 | CALL ctl_stop( trim(clinfo), trim(ctmp1) ) |
---|
654 | ENDIF |
---|
655 | ELSE |
---|
656 | CALL ctl_stop( trim(clinfo), 'variable dimension is not unlimited... use iom_get' ) |
---|
657 | ENDIF |
---|
658 | ELSE |
---|
659 | CALL ctl_stop( trim(clinfo), 'the variable has more than 1 dimension' ) |
---|
660 | ENDIF |
---|
661 | ELSE |
---|
662 | CALL ctl_stop( trim(clinfo), 'variable not found in '//iom_file(kiomid)%name ) |
---|
663 | ENDIF |
---|
664 | ! |
---|
665 | END SUBROUTINE iom_gettime |
---|
666 | |
---|
667 | |
---|
668 | !!---------------------------------------------------------------------- |
---|
669 | !! INTERFACE iom_rstput |
---|
670 | !!---------------------------------------------------------------------- |
---|
671 | SUBROUTINE iom_rp0d( kt, kwrite, kiomid, cdvar, pvar, ktype ) |
---|
672 | INTEGER , INTENT(in) :: kt ! ocean time-step |
---|
673 | INTEGER , INTENT(in) :: kwrite ! writing time-step |
---|
674 | INTEGER , INTENT(in) :: kiomid ! Identifier of the file |
---|
675 | CHARACTER(len=*), INTENT(in) :: cdvar ! time axis name |
---|
676 | REAL(wp) , INTENT(in) :: pvar ! written field |
---|
677 | INTEGER , INTENT(in), OPTIONAL :: ktype ! variable external type |
---|
678 | INTEGER :: ivid ! variable id |
---|
679 | IF( iom_file(kiomid)%nfid > 0 ) THEN |
---|
680 | ivid = iom_varid(kiomid, cdvar) |
---|
681 | SELECT CASE (iom_file(kiomid)%iolib) |
---|
682 | CASE (jpioipsl ) ; CALL iom_ioipsl_rstput( kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r0d = pvar ) |
---|
683 | CASE (jpnf90 ) ; CALL iom_nf90_rstput( kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r0d = pvar ) |
---|
684 | CASE (jprstdimg) ; IF( kt == kwrite ) CALL iom_rstdimg_rstput( kiomid, cdvar, ivid, pvar ) |
---|
685 | CASE DEFAULT |
---|
686 | CALL ctl_stop( 'iom_rp0d: accepted IO library are only jpioipsl, jpnf90 and jprstdimg' ) |
---|
687 | END SELECT |
---|
688 | END IF |
---|
689 | END SUBROUTINE iom_rp0d |
---|
690 | |
---|
691 | SUBROUTINE iom_rp1d( kt, kwrite, kiomid, cdvar, pvar, ktype ) |
---|
692 | INTEGER , INTENT(in) :: kt ! ocean time-step |
---|
693 | INTEGER , INTENT(in) :: kwrite ! writing time-step |
---|
694 | INTEGER , INTENT(in) :: kiomid ! Identifier of the file |
---|
695 | CHARACTER(len=*), INTENT(in) :: cdvar ! time axis name |
---|
696 | REAL(wp) , INTENT(in), DIMENSION( jpk) :: pvar ! written field |
---|
697 | INTEGER , INTENT(in), OPTIONAL :: ktype ! variable external type |
---|
698 | INTEGER :: ivid ! variable id |
---|
699 | IF( iom_file(kiomid)%nfid > 0 ) THEN |
---|
700 | ivid = iom_varid(kiomid, cdvar) |
---|
701 | SELECT CASE (iom_file(kiomid)%iolib) |
---|
702 | CASE (jpioipsl ) ; CALL iom_ioipsl_rstput( kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r1d = pvar ) |
---|
703 | CASE (jpnf90 ) ; CALL iom_nf90_rstput( kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r1d = pvar ) |
---|
704 | CASE (jprstdimg) ; IF( kt == kwrite ) CALL iom_rstdimg_rstput( kiomid, cdvar, ivid, pv_r1d = pvar ) |
---|
705 | CASE DEFAULT |
---|
706 | CALL ctl_stop( 'iom_rp1d: accepted IO library are only jpioipsl, jpnf90 and jprstdimg' ) |
---|
707 | END SELECT |
---|
708 | END IF |
---|
709 | END SUBROUTINE iom_rp1d |
---|
710 | |
---|
711 | SUBROUTINE iom_rp2d( kt, kwrite, kiomid, cdvar, pvar, ktype ) |
---|
712 | INTEGER , INTENT(in) :: kt ! ocean time-step |
---|
713 | INTEGER , INTENT(in) :: kwrite ! writing time-step |
---|
714 | INTEGER , INTENT(in) :: kiomid ! Identifier of the file |
---|
715 | CHARACTER(len=*), INTENT(in) :: cdvar ! time axis name |
---|
716 | REAL(wp) , INTENT(in), DIMENSION(jpi,jpj ) :: pvar ! written field |
---|
717 | INTEGER , INTENT(in), OPTIONAL :: ktype ! variable external type |
---|
718 | INTEGER :: ivid ! variable id |
---|
719 | IF( iom_file(kiomid)%nfid > 0 ) THEN |
---|
720 | ivid = iom_varid(kiomid, cdvar) |
---|
721 | SELECT CASE (iom_file(kiomid)%iolib) |
---|
722 | CASE (jpioipsl ) ; CALL iom_ioipsl_rstput( kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r2d = pvar ) |
---|
723 | CASE (jpnf90 ) ; CALL iom_nf90_rstput( kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r2d = pvar ) |
---|
724 | CASE (jprstdimg) ; IF( kt == kwrite ) CALL iom_rstdimg_rstput( kiomid, cdvar, ivid, pv_r2d = pvar ) |
---|
725 | CASE DEFAULT |
---|
726 | CALL ctl_stop( 'iom_rp2d: accepted IO library are only jpioipsl, jpnf90 and jprstdimg' ) |
---|
727 | END SELECT |
---|
728 | END IF |
---|
729 | END SUBROUTINE iom_rp2d |
---|
730 | |
---|
731 | SUBROUTINE iom_rp3d( kt, kwrite, kiomid, cdvar, pvar, ktype ) |
---|
732 | INTEGER , INTENT(in) :: kt ! ocean time-step |
---|
733 | INTEGER , INTENT(in) :: kwrite ! writing time-step |
---|
734 | INTEGER , INTENT(in) :: kiomid ! Identifier of the file |
---|
735 | CHARACTER(len=*), INTENT(in) :: cdvar ! time axis name |
---|
736 | REAL(wp) , INTENT(in), DIMENSION(jpi,jpj,jpk) :: pvar ! written field |
---|
737 | INTEGER , INTENT(in), OPTIONAL :: ktype ! variable external type |
---|
738 | INTEGER :: ivid ! variable id |
---|
739 | IF( iom_file(kiomid)%nfid > 0 ) THEN |
---|
740 | ivid = iom_varid(kiomid, cdvar) |
---|
741 | SELECT CASE (iom_file(kiomid)%iolib) |
---|
742 | CASE (jpioipsl ) ; CALL iom_ioipsl_rstput( kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r3d = pvar ) |
---|
743 | CASE (jpnf90 ) ; CALL iom_nf90_rstput( kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r3d = pvar ) |
---|
744 | CASE (jprstdimg) ; IF( kt == kwrite ) CALL iom_rstdimg_rstput( kiomid, cdvar, ivid, pv_r3d = pvar ) |
---|
745 | CASE DEFAULT |
---|
746 | CALL ctl_stop( 'iom_rp3d: accepted IO library are only jpioipsl and jprstdimg' ) |
---|
747 | END SELECT |
---|
748 | END IF |
---|
749 | END SUBROUTINE iom_rp3d |
---|
750 | !!---------------------------------------------------------------------- |
---|
751 | |
---|
752 | |
---|
753 | !!====================================================================== |
---|
754 | END MODULE iom |
---|