1 | MODULE icerst |
---|
2 | !!====================================================================== |
---|
3 | !! *** MODULE icerst *** |
---|
4 | !! sea-ice : write/read the ice restart file |
---|
5 | !!====================================================================== |
---|
6 | !! History: 3.0 ! 2005-04 (M. Vancoppenolle) Original code |
---|
7 | !! - ! 2008-03 (C. Ethe) restart files in using IOM interface |
---|
8 | !! 4.0 ! 2011-02 (G. Madec) dynamical allocation |
---|
9 | !!---------------------------------------------------------------------- |
---|
10 | #if defined key_lim3 |
---|
11 | !!---------------------------------------------------------------------- |
---|
12 | !! 'key_lim3' ESIM sea-ice model |
---|
13 | !!---------------------------------------------------------------------- |
---|
14 | !! ice_rst_opn : open restart file |
---|
15 | !! ice_rst_write : write restart file |
---|
16 | !! ice_rst_read : read restart file |
---|
17 | !!---------------------------------------------------------------------- |
---|
18 | USE ice ! sea-ice variables |
---|
19 | USE dom_oce ! ocean domain |
---|
20 | USE sbc_oce , ONLY : nn_fsbc |
---|
21 | USE icectl |
---|
22 | ! |
---|
23 | USE in_out_manager ! I/O manager |
---|
24 | USE iom ! I/O manager library |
---|
25 | USE lib_mpp ! MPP library |
---|
26 | USE lib_fortran ! fortran utilities (glob_sum + no signed zero) |
---|
27 | USE timing ! Timing |
---|
28 | |
---|
29 | IMPLICIT NONE |
---|
30 | PRIVATE |
---|
31 | |
---|
32 | PUBLIC ice_rst_opn ! called by icestp |
---|
33 | PUBLIC ice_rst_write ! called by icestp |
---|
34 | PUBLIC ice_rst_read ! called by ice_init |
---|
35 | |
---|
36 | !!---------------------------------------------------------------------- |
---|
37 | !! NEMO/ICE 4.0 , NEMO Consortium (2017) |
---|
38 | !! $Id: icerst.F90 8411 2017-08-07 16:09:12Z clem $ |
---|
39 | !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) |
---|
40 | !!---------------------------------------------------------------------- |
---|
41 | CONTAINS |
---|
42 | |
---|
43 | SUBROUTINE ice_rst_opn( kt ) |
---|
44 | !!---------------------------------------------------------------------- |
---|
45 | !! *** ice_rst_opn *** |
---|
46 | !! |
---|
47 | !! ** purpose : open restart file |
---|
48 | !!---------------------------------------------------------------------- |
---|
49 | INTEGER, INTENT(in) :: kt ! number of iteration |
---|
50 | ! |
---|
51 | CHARACTER(len=20) :: clkt ! ocean time-step define as a character |
---|
52 | CHARACTER(len=50) :: clname ! ice output restart file name |
---|
53 | CHARACTER(len=256) :: clpath ! full path to ice output restart file |
---|
54 | !!---------------------------------------------------------------------- |
---|
55 | ! |
---|
56 | IF( kt == nit000 ) lrst_ice = .FALSE. ! default definition |
---|
57 | |
---|
58 | ! in order to get better performances with NetCDF format, we open and define the ice restart file |
---|
59 | ! one ice time step before writing the data (-> at nitrst - 2*nn_fsbc + 1), except if we write ice |
---|
60 | ! restart files every ice time step or if an ice restart file was writen at nitend - 2*nn_fsbc + 1 |
---|
61 | IF( kt == nitrst - 2*nn_fsbc + 1 .OR. nstock == nn_fsbc & |
---|
62 | & .OR. ( kt == nitend - nn_fsbc + 1 .AND. .NOT. lrst_ice ) ) THEN |
---|
63 | IF( nitrst <= nitend .AND. nitrst > 0 ) THEN |
---|
64 | ! beware of the format used to write kt (default is i8.8, that should be large enough...) |
---|
65 | IF( nitrst > 99999999 ) THEN ; WRITE(clkt, * ) nitrst |
---|
66 | ELSE ; WRITE(clkt, '(i8.8)') nitrst |
---|
67 | ENDIF |
---|
68 | ! create the file |
---|
69 | clname = TRIM(cexper)//"_"//TRIM(ADJUSTL(clkt))//"_"//TRIM(cn_icerst_out) |
---|
70 | clpath = TRIM(cn_icerst_outdir) |
---|
71 | IF( clpath(LEN_TRIM(clpath):) /= '/' ) clpath = TRIM(clpath)//'/' |
---|
72 | IF(lwp) THEN |
---|
73 | WRITE(numout,*) |
---|
74 | SELECT CASE ( jprstlib ) |
---|
75 | CASE DEFAULT |
---|
76 | WRITE(numout,*) ' open ice restart NetCDF file: ',TRIM(clpath)//clname |
---|
77 | END SELECT |
---|
78 | IF( kt == nitrst - 2*nn_fsbc + 1 ) THEN |
---|
79 | WRITE(numout,*) ' kt = nitrst - 2*nn_fsbc + 1 = ', kt,' date= ', ndastp |
---|
80 | ELSE |
---|
81 | WRITE(numout,*) ' kt = ' , kt,' date= ', ndastp |
---|
82 | ENDIF |
---|
83 | ENDIF |
---|
84 | ! |
---|
85 | CALL iom_open( TRIM(clpath)//TRIM(clname), numriw, ldwrt = .TRUE., kiolib = jprstlib ) |
---|
86 | lrst_ice = .TRUE. |
---|
87 | ENDIF |
---|
88 | ENDIF |
---|
89 | ! |
---|
90 | IF( ln_icectl ) CALL ice_prt( kt, iiceprt, jiceprt, 1, ' - Beginning the time step - ' ) ! control print |
---|
91 | END SUBROUTINE ice_rst_opn |
---|
92 | |
---|
93 | |
---|
94 | SUBROUTINE ice_rst_write( kt ) |
---|
95 | !!---------------------------------------------------------------------- |
---|
96 | !! *** ice_rst_write *** |
---|
97 | !! |
---|
98 | !! ** purpose : write restart file |
---|
99 | !!---------------------------------------------------------------------- |
---|
100 | INTEGER, INTENT(in) :: kt ! number of iteration |
---|
101 | !! |
---|
102 | INTEGER :: jk ,jl ! dummy loop indices |
---|
103 | INTEGER :: iter |
---|
104 | CHARACTER(len=25) :: znam |
---|
105 | CHARACTER(len=2) :: zchar, zchar1 |
---|
106 | REAL(wp), DIMENSION(jpi,jpj) :: z2d |
---|
107 | !!---------------------------------------------------------------------- |
---|
108 | |
---|
109 | IF( nn_timing == 1 ) CALL timing_start('ice_rst') |
---|
110 | |
---|
111 | iter = kt + nn_fsbc - 1 ! ice restarts are written at kt == nitrst - nn_fsbc + 1 |
---|
112 | |
---|
113 | IF( iter == nitrst ) THEN |
---|
114 | IF(lwp) WRITE(numout,*) |
---|
115 | IF(lwp) WRITE(numout,*) 'ice_rst_write : write ice restart file kt =', kt |
---|
116 | IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~~' |
---|
117 | ENDIF |
---|
118 | |
---|
119 | ! Write in numriw (if iter == nitrst) |
---|
120 | ! ------------------ |
---|
121 | ! ! calendar control |
---|
122 | CALL iom_rstput( iter, nitrst, numriw, 'nn_fsbc', REAL( nn_fsbc, wp ) ) ! time-step |
---|
123 | CALL iom_rstput( iter, nitrst, numriw, 'kt_ice' , REAL( iter , wp ) ) ! date |
---|
124 | |
---|
125 | !!gm It is possible and easy to define a 3D domain size (jpi,jpj,jpl) or use a SIZE( tab, DIM=3) in iom_rtput ) |
---|
126 | !!gm ===>>> just a simple iom_rstput( iter, nitrst, numriw, 'v_i', v_i ) etc... |
---|
127 | !!gm "just" ask Sebatien |
---|
128 | |
---|
129 | ! Prognostic variables |
---|
130 | DO jl = 1, jpl |
---|
131 | WRITE(zchar,'(I2.2)') jl |
---|
132 | znam = 'v_i'//'_htc'//zchar |
---|
133 | z2d(:,:) = v_i(:,:,jl) |
---|
134 | CALL iom_rstput( iter, nitrst, numriw, znam , z2d ) ! v_i |
---|
135 | znam = 'v_s'//'_htc'//zchar |
---|
136 | z2d(:,:) = v_s(:,:,jl) |
---|
137 | CALL iom_rstput( iter, nitrst, numriw, znam , z2d ) ! v_s |
---|
138 | znam = 'smv_i'//'_htc'//zchar |
---|
139 | z2d(:,:) = smv_i(:,:,jl) |
---|
140 | CALL iom_rstput( iter, nitrst, numriw, znam , z2d ) ! smv_i |
---|
141 | znam = 'oa_i'//'_htc'//zchar |
---|
142 | z2d(:,:) = oa_i(:,:,jl) |
---|
143 | CALL iom_rstput( iter, nitrst, numriw, znam , z2d ) ! oa_i |
---|
144 | znam = 'a_i'//'_htc'//zchar |
---|
145 | z2d(:,:) = a_i(:,:,jl) |
---|
146 | CALL iom_rstput( iter, nitrst, numriw, znam , z2d ) ! a_i |
---|
147 | znam = 't_su'//'_htc'//zchar |
---|
148 | z2d(:,:) = t_su(:,:,jl) |
---|
149 | CALL iom_rstput( iter, nitrst, numriw, znam , z2d ) ! t_su |
---|
150 | END DO |
---|
151 | |
---|
152 | ! MV MP 2016 |
---|
153 | IF ( nn_pnd_scheme > 0 ) THEN |
---|
154 | DO jl = 1, jpl |
---|
155 | WRITE(zchar,'(I2.2)') jl |
---|
156 | znam = 'a_ip'//'_htc'//zchar |
---|
157 | z2d(:,:) = a_ip(:,:,jl) |
---|
158 | CALL iom_rstput( iter, nitrst, numriw, znam , z2d ) ! a_ip |
---|
159 | znam = 'v_ip'//'_htc'//zchar |
---|
160 | z2d(:,:) = v_ip(:,:,jl) |
---|
161 | CALL iom_rstput( iter, nitrst, numriw, znam , z2d ) ! v_ip |
---|
162 | END DO |
---|
163 | ENDIF |
---|
164 | ! END MV MP 2016 |
---|
165 | |
---|
166 | DO jl = 1, jpl |
---|
167 | WRITE(zchar,'(I2.2)') jl |
---|
168 | znam = 'tempt_sl1'//'_htc'//zchar |
---|
169 | z2d(:,:) = e_s(:,:,1,jl) |
---|
170 | CALL iom_rstput( iter, nitrst, numriw, znam , z2d ) ! e_s |
---|
171 | DO jk = 1, nlay_i |
---|
172 | WRITE(zchar1,'(I2.2)') jk |
---|
173 | znam = 'tempt'//'_il'//zchar1//'_htc'//zchar |
---|
174 | z2d(:,:) = e_i(:,:,jk,jl) |
---|
175 | CALL iom_rstput( iter, nitrst, numriw, znam , z2d ) ! e_i |
---|
176 | END DO |
---|
177 | END DO |
---|
178 | |
---|
179 | CALL iom_rstput( iter, nitrst, numriw, 'u_ice', u_ice ) ! u_ice |
---|
180 | CALL iom_rstput( iter, nitrst, numriw, 'v_ice', v_ice ) ! v_ice |
---|
181 | |
---|
182 | ! close restart file |
---|
183 | ! ------------------ |
---|
184 | IF( iter == nitrst ) THEN |
---|
185 | CALL iom_close( numriw ) |
---|
186 | lrst_ice = .FALSE. |
---|
187 | ENDIF |
---|
188 | ! |
---|
189 | IF( nn_timing == 1 ) CALL timing_stop('ice_rst') |
---|
190 | ! |
---|
191 | END SUBROUTINE ice_rst_write |
---|
192 | |
---|
193 | |
---|
194 | SUBROUTINE ice_rst_read |
---|
195 | !!---------------------------------------------------------------------- |
---|
196 | !! *** ice_rst_read *** |
---|
197 | !! |
---|
198 | !! ** purpose : read restart file |
---|
199 | !!---------------------------------------------------------------------- |
---|
200 | INTEGER :: jk, jl |
---|
201 | REAL(wp) :: zfice, ziter |
---|
202 | REAL(wp), DIMENSION(jpi,jpj) :: z2d |
---|
203 | CHARACTER(len=25) :: znam |
---|
204 | CHARACTER(len=2) :: zchar, zchar1 |
---|
205 | INTEGER :: jlibalt = jprstlib |
---|
206 | LOGICAL :: llok |
---|
207 | !!---------------------------------------------------------------------- |
---|
208 | |
---|
209 | IF( nn_timing == 1 ) CALL timing_start('ice_rst') |
---|
210 | |
---|
211 | IF(lwp) THEN |
---|
212 | WRITE(numout,*) |
---|
213 | WRITE(numout,*) 'ice_rst_read: read ice NetCDF restart file' |
---|
214 | WRITE(numout,*) '~~~~~~~~~~~~' |
---|
215 | ENDIF |
---|
216 | |
---|
217 | CALL iom_open ( TRIM(cn_icerst_indir)//'/'//cn_icerst_in, numrir, kiolib = jprstlib ) |
---|
218 | |
---|
219 | CALL iom_get( numrir, 'nn_fsbc', zfice ) |
---|
220 | CALL iom_get( numrir, 'kt_ice' , ziter ) |
---|
221 | IF(lwp) WRITE(numout,*) ' read ice restart file at time step : ', ziter |
---|
222 | IF(lwp) WRITE(numout,*) ' in any case we force it to nit000 - 1 : ', nit000 - 1 |
---|
223 | |
---|
224 | ! Control of date |
---|
225 | IF( ( nit000 - NINT(ziter) ) /= 1 .AND. ABS( nrstdt ) == 1 ) & |
---|
226 | & CALL ctl_stop( 'ice_rst_read ===>>>> : problem with nit000 in ice restart', & |
---|
227 | & ' verify the file or rerun with the value 0 for the', & |
---|
228 | & ' control of time parameter nrstdt' ) |
---|
229 | IF( NINT(zfice) /= nn_fsbc .AND. ABS( nrstdt ) == 1 ) & |
---|
230 | & CALL ctl_stop( 'ice_rst_read ===>>>> : problem with nn_fsbc in ice restart', & |
---|
231 | & ' verify the file or rerun with the value 0 for the', & |
---|
232 | & ' control of time parameter nrstdt' ) |
---|
233 | |
---|
234 | ! Prognostic variables |
---|
235 | DO jl = 1, jpl |
---|
236 | WRITE(zchar,'(I2.2)') jl |
---|
237 | znam = 'v_i'//'_htc'//zchar |
---|
238 | CALL iom_get( numrir, jpdom_autoglo, znam , z2d ) |
---|
239 | v_i(:,:,jl) = z2d(:,:) |
---|
240 | znam = 'v_s'//'_htc'//zchar |
---|
241 | CALL iom_get( numrir, jpdom_autoglo, znam , z2d ) |
---|
242 | v_s(:,:,jl) = z2d(:,:) |
---|
243 | znam = 'smv_i'//'_htc'//zchar |
---|
244 | CALL iom_get( numrir, jpdom_autoglo, znam , z2d ) |
---|
245 | smv_i(:,:,jl) = z2d(:,:) |
---|
246 | znam = 'oa_i'//'_htc'//zchar |
---|
247 | CALL iom_get( numrir, jpdom_autoglo, znam , z2d ) |
---|
248 | oa_i(:,:,jl) = z2d(:,:) |
---|
249 | znam = 'a_i'//'_htc'//zchar |
---|
250 | CALL iom_get( numrir, jpdom_autoglo, znam , z2d ) |
---|
251 | a_i(:,:,jl) = z2d(:,:) |
---|
252 | znam = 't_su'//'_htc'//zchar |
---|
253 | CALL iom_get( numrir, jpdom_autoglo, znam , z2d ) |
---|
254 | t_su(:,:,jl) = z2d(:,:) |
---|
255 | END DO |
---|
256 | |
---|
257 | ! MV MP 2016 |
---|
258 | IF ( nn_pnd_scheme > 0 ) THEN |
---|
259 | DO jl = 1, jpl |
---|
260 | WRITE(zchar,'(I2.2)') jl |
---|
261 | znam = 'a_ip'//'_htc'//zchar |
---|
262 | CALL iom_get( numrir, jpdom_autoglo, znam , z2d ) |
---|
263 | a_ip(:,:,jl) = z2d(:,:) |
---|
264 | znam = 'v_ip'//'_htc'//zchar |
---|
265 | CALL iom_get( numrir, jpdom_autoglo, znam , z2d ) |
---|
266 | v_ip(:,:,jl) = z2d(:,:) |
---|
267 | END DO |
---|
268 | ENDIF |
---|
269 | ! END MV MP 2016 |
---|
270 | |
---|
271 | DO jl = 1, jpl |
---|
272 | WRITE(zchar,'(I2.2)') jl |
---|
273 | znam = 'tempt_sl1'//'_htc'//zchar |
---|
274 | CALL iom_get( numrir, jpdom_autoglo, znam , z2d ) |
---|
275 | e_s(:,:,1,jl) = z2d(:,:) |
---|
276 | DO jk = 1, nlay_i |
---|
277 | WRITE(zchar1,'(I2.2)') jk |
---|
278 | znam = 'tempt'//'_il'//zchar1//'_htc'//zchar |
---|
279 | CALL iom_get( numrir, jpdom_autoglo, znam , z2d ) |
---|
280 | e_i(:,:,jk,jl) = z2d(:,:) |
---|
281 | END DO |
---|
282 | END DO |
---|
283 | |
---|
284 | CALL iom_get( numrir, jpdom_autoglo, 'u_ice', u_ice ) |
---|
285 | CALL iom_get( numrir, jpdom_autoglo, 'v_ice', v_ice ) |
---|
286 | |
---|
287 | IF( nn_timing == 1 ) CALL timing_stop('ice_rst') |
---|
288 | |
---|
289 | END SUBROUTINE ice_rst_read |
---|
290 | |
---|
291 | #else |
---|
292 | !!---------------------------------------------------------------------- |
---|
293 | !! Default option : Empty module NO ESIM sea-ice model |
---|
294 | !!---------------------------------------------------------------------- |
---|
295 | #endif |
---|
296 | |
---|
297 | !!====================================================================== |
---|
298 | END MODULE icerst |
---|