New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
limrst.F90 in trunk/NEMOGCM/NEMO/LIM_SRC_3 – NEMO

source: trunk/NEMOGCM/NEMO/LIM_SRC_3/limrst.F90 @ 7698

Last change on this file since 7698 was 7698, checked in by mocavero, 7 years ago

update trunk with OpenMP parallelization

  • Property svn:keywords set to Id
File size: 31.2 KB
Line 
1MODULE limrst
2   !!======================================================================
3   !!                     ***  MODULE  limrst  ***
4   !! Ice restart :  write the ice restart file
5   !!======================================================================
6   !! History:   -   ! 2005-04 (M. Vancoppenolle) Original code
7   !!           3.0  ! 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' :                                   LIM sea-ice model
13   !!----------------------------------------------------------------------
14   !!   lim_rst_opn   : open ice restart file
15   !!   lim_rst_write : write of the restart file
16   !!   lim_rst_read  : read  the restart file
17   !!----------------------------------------------------------------------
18   USE ice            ! sea-ice variables
19   USE oce     , ONLY :  snwice_mass, snwice_mass_b
20   USE dom_oce        ! ocean domain
21   USE sbc_oce        ! Surface boundary condition: ocean fields
22   USE sbc_ice        ! Surface boundary condition: ice fields
23   USE in_out_manager ! I/O manager
24   USE iom            ! I/O library
25   USE lib_mpp        ! MPP library
26   USE wrk_nemo       ! work arrays
27   USE lib_fortran    ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined) 
28   USE limctl
29
30   IMPLICIT NONE
31   PRIVATE
32
33   PUBLIC   lim_rst_opn    ! routine called by icestep.F90
34   PUBLIC   lim_rst_write  ! routine called by icestep.F90
35   PUBLIC   lim_rst_read   ! routine called by sbc_lim_init
36
37   LOGICAL, PUBLIC ::   lrst_ice         !: logical to control the ice restart write
38   INTEGER, PUBLIC ::   numrir, numriw   !: logical unit for ice restart (read and write)
39
40   !!----------------------------------------------------------------------
41   !! NEMO/LIM3 4.0 , UCL - NEMO Consortium (2011)
42   !! $Id$
43   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
44   !!----------------------------------------------------------------------
45CONTAINS
46
47   SUBROUTINE lim_rst_opn( kt )
48      !!----------------------------------------------------------------------
49      !!                    ***  lim_rst_opn  ***
50      !!
51      !! ** purpose  :   output of sea-ice variable in a netcdf file
52      !!----------------------------------------------------------------------
53      INTEGER, INTENT(in) ::   kt       ! number of iteration
54      !
55      CHARACTER(len=20)   ::   clkt     ! ocean time-step define as a character
56      CHARACTER(len=50)   ::   clname   ! ice output restart file name
57      CHARACTER(len=256)  ::   clpath   ! full path to ice output restart file
58      !!----------------------------------------------------------------------
59      !
60      IF( kt == nit000 )   lrst_ice = .FALSE.   ! default definition
61
62      ! in order to get better performances with NetCDF format, we open and define the ice restart file
63      ! one ice time step before writing the data (-> at nitrst - 2*nn_fsbc + 1), except if we write ice
64      ! restart files every ice time step or if an ice restart file was writen at nitend - 2*nn_fsbc + 1
65      IF( kt == nitrst - 2*nn_fsbc + 1 .OR. nstock == nn_fsbc    &
66         &                             .OR. ( kt == nitend - nn_fsbc + 1 .AND. .NOT. lrst_ice ) ) THEN
67         IF( nitrst <= nitend .AND. nitrst > 0 ) THEN
68            ! beware of the format used to write kt (default is i8.8, that should be large enough...)
69            IF( nitrst > 99999999 ) THEN   ;   WRITE(clkt, *       ) nitrst
70            ELSE                           ;   WRITE(clkt, '(i8.8)') nitrst
71            ENDIF
72            ! create the file
73            clname = TRIM(cexper)//"_"//TRIM(ADJUSTL(clkt))//"_"//TRIM(cn_icerst_out)
74            clpath = TRIM(cn_icerst_outdir) 
75            IF( clpath(LEN_TRIM(clpath):) /= '/' ) clpath = TRIM(clpath)//'/'
76            IF(lwp) THEN
77               WRITE(numout,*)
78               SELECT CASE ( jprstlib )
79               CASE DEFAULT
80                  WRITE(numout,*) '             open ice restart NetCDF file: ',TRIM(clpath)//clname
81               END SELECT
82               IF( kt == nitrst - 2*nn_fsbc + 1 ) THEN   
83                  WRITE(numout,*)         '             kt = nitrst - 2*nn_fsbc + 1 = ', kt,' date= ', ndastp
84               ELSE   ;   WRITE(numout,*) '             kt = '                         , kt,' date= ', ndastp
85               ENDIF
86            ENDIF
87            !
88            CALL iom_open( TRIM(clpath)//TRIM(clname), numriw, ldwrt = .TRUE., kiolib = jprstlib )
89            lrst_ice = .TRUE.
90         ENDIF
91      ENDIF
92      !
93      IF( ln_limctl )   CALL lim_prt( kt, iiceprt, jiceprt, 1, ' - Beginning the time step - ' )   ! control print
94   END SUBROUTINE lim_rst_opn
95
96
97   SUBROUTINE lim_rst_write( kt )
98      !!----------------------------------------------------------------------
99      !!                    ***  lim_rst_write  ***
100      !!
101      !! ** purpose  :   output of sea-ice variable in a netcdf file
102      !!----------------------------------------------------------------------
103      INTEGER, INTENT(in) ::   kt     ! number of iteration
104      !!
105      INTEGER ::   ji, jj, jk ,jl   ! dummy loop indices
106      INTEGER ::   iter
107      CHARACTER(len=25) ::   znam
108      CHARACTER(len=2)  ::   zchar, zchar1
109      REAL(wp), POINTER, DIMENSION(:,:) :: z2d
110      !!----------------------------------------------------------------------
111
112      CALL wrk_alloc( jpi, jpj, z2d )
113
114      iter = kt + nn_fsbc - 1   ! ice restarts are written at kt == nitrst - nn_fsbc + 1
115
116      IF( iter == nitrst ) THEN
117         IF(lwp) WRITE(numout,*)
118         IF(lwp) WRITE(numout,*) 'lim_rst_write : write ice restart file  kt =', kt
119         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~~'         
120      ENDIF
121
122      ! Write in numriw (if iter == nitrst)
123      ! ------------------
124      !                                                                        ! calendar control
125      CALL iom_rstput( iter, nitrst, numriw, 'nn_fsbc', REAL( nn_fsbc, wp ) )      ! time-step
126      CALL iom_rstput( iter, nitrst, numriw, 'kt_ice' , REAL( iter   , wp ) )      ! date
127
128      ! Prognostic variables
129      DO jl = 1, jpl 
130         WRITE(zchar,'(I2.2)') jl
131         znam = 'v_i'//'_htc'//zchar
132!$OMP PARALLEL DO schedule(static) private(jj,ji)
133         DO jj = 1, jpj
134            DO ji = 1, jpi
135               z2d(ji,jj) = v_i(ji,jj,jl)
136            END DO
137         END DO
138         CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
139         znam = 'v_s'//'_htc'//zchar
140!$OMP PARALLEL DO schedule(static) private(jj,ji)
141         DO jj = 1, jpj
142            DO ji = 1, jpi
143               z2d(ji,jj) = v_s(ji,jj,jl)
144            END DO
145         END DO
146         CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
147         znam = 'smv_i'//'_htc'//zchar
148!$OMP PARALLEL DO schedule(static) private(jj,ji)
149         DO jj = 1, jpj
150            DO ji = 1, jpi
151               z2d(ji,jj) = smv_i(ji,jj,jl)
152            END DO
153         END DO
154         CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
155         znam = 'oa_i'//'_htc'//zchar
156!$OMP PARALLEL DO schedule(static) private(jj,ji)
157         DO jj = 1, jpj
158            DO ji = 1, jpi
159               z2d(ji,jj) = oa_i(ji,jj,jl)
160            END DO
161         END DO
162         CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
163         znam = 'a_i'//'_htc'//zchar
164!$OMP PARALLEL DO schedule(static) private(jj,ji)
165         DO jj = 1, jpj
166            DO ji = 1, jpi
167               z2d(ji,jj) = a_i(ji,jj,jl)
168            END DO
169         END DO
170         CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
171         znam = 't_su'//'_htc'//zchar
172!$OMP PARALLEL DO schedule(static) private(jj,ji)
173         DO jj = 1, jpj
174            DO ji = 1, jpi
175               z2d(ji,jj) = t_su(ji,jj,jl)
176            END DO
177         END DO
178         CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
179      END DO
180
181      DO jl = 1, jpl 
182         WRITE(zchar,'(I2.2)') jl
183         znam = 'tempt_sl1'//'_htc'//zchar
184!$OMP PARALLEL DO schedule(static) private(jj,ji)
185         DO jj = 1, jpj
186            DO ji = 1, jpi
187               z2d(ji,jj) = e_s(ji,jj,1,jl)
188            END DO
189         END DO
190         CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
191      END DO
192
193      DO jl = 1, jpl 
194         WRITE(zchar,'(I2.2)') jl
195         DO jk = 1, nlay_i 
196            WRITE(zchar1,'(I2.2)') jk
197            znam = 'tempt'//'_il'//zchar1//'_htc'//zchar
198!$OMP PARALLEL DO schedule(static) private(jj,ji)
199            DO jj = 1, jpj
200               DO ji = 1, jpi
201                  z2d(ji,jj) = e_i(ji,jj,jk,jl)
202            END DO
203         END DO
204            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
205         END DO
206      END DO
207
208      CALL iom_rstput( iter, nitrst, numriw, 'u_ice'        , u_ice      )
209      CALL iom_rstput( iter, nitrst, numriw, 'v_ice'        , v_ice      )
210      CALL iom_rstput( iter, nitrst, numriw, 'stress1_i'    , stress1_i  )
211      CALL iom_rstput( iter, nitrst, numriw, 'stress2_i'    , stress2_i  )
212      CALL iom_rstput( iter, nitrst, numriw, 'stress12_i'   , stress12_i )
213      CALL iom_rstput( iter, nitrst, numriw, 'snwice_mass'  , snwice_mass )
214      CALL iom_rstput( iter, nitrst, numriw, 'snwice_mass_b', snwice_mass_b )
215
216      ! In case Prather scheme is used for advection, write second order moments
217      ! ------------------------------------------------------------------------
218      IF( nn_limadv == -1 ) THEN
219         
220         DO jl = 1, jpl 
221            WRITE(zchar,'(I2.2)') jl
222            znam = 'sxice'//'_htc'//zchar
223!$OMP PARALLEL DO schedule(static) private(jj,ji)
224            DO jj = 1, jpj
225               DO ji = 1, jpi
226                  z2d(ji,jj) = sxice(ji,jj,jl)
227               END DO
228            END DO
229            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
230            znam = 'syice'//'_htc'//zchar
231!$OMP PARALLEL DO schedule(static) private(jj,ji)
232            DO jj = 1, jpj
233               DO ji = 1, jpi
234                  z2d(ji,jj) = syice(ji,jj,jl)
235               END DO
236            END DO
237            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
238            znam = 'sxxice'//'_htc'//zchar
239!$OMP PARALLEL DO schedule(static) private(jj,ji)
240            DO jj = 1, jpj
241               DO ji = 1, jpi
242                  z2d(ji,jj) = sxxice(ji,jj,jl)
243               END DO
244            END DO
245            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
246            znam = 'syyice'//'_htc'//zchar
247!$OMP PARALLEL DO schedule(static) private(jj,ji)
248            DO jj = 1, jpj
249               DO ji = 1, jpi
250                  z2d(ji,jj) = syyice(ji,jj,jl)
251               END DO
252            END DO
253            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
254            znam = 'sxyice'//'_htc'//zchar
255!$OMP PARALLEL DO schedule(static) private(jj,ji)
256            DO jj = 1, jpj
257               DO ji = 1, jpi
258                  z2d(ji,jj) = sxyice(ji,jj,jl)
259               END DO
260            END DO
261            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
262            znam = 'sxsn'//'_htc'//zchar
263!$OMP PARALLEL DO schedule(static) private(jj,ji)
264            DO jj = 1, jpj
265               DO ji = 1, jpi
266                  z2d(ji,jj) = sxsn(ji,jj,jl)
267               END DO
268            END DO
269            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
270            znam = 'sysn'//'_htc'//zchar
271!$OMP PARALLEL DO schedule(static) private(jj,ji)
272            DO jj = 1, jpj
273               DO ji = 1, jpi
274                  z2d(ji,jj) = sysn(ji,jj,jl)
275               END DO
276            END DO
277            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
278            znam = 'sxxsn'//'_htc'//zchar
279!$OMP PARALLEL DO schedule(static) private(jj,ji)
280            DO jj = 1, jpj
281               DO ji = 1, jpi
282                  z2d(ji,jj) = sxxsn(ji,jj,jl)
283               END DO
284            END DO
285            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
286            znam = 'syysn'//'_htc'//zchar
287!$OMP PARALLEL DO schedule(static) private(jj,ji)
288            DO jj = 1, jpj
289               DO ji = 1, jpi
290                  z2d(ji,jj) = syysn(ji,jj,jl)
291               END DO
292            END DO
293            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
294            znam = 'sxysn'//'_htc'//zchar
295!$OMP PARALLEL DO schedule(static) private(jj,ji)
296            DO jj = 1, jpj
297               DO ji = 1, jpi
298                  z2d(ji,jj) = sxysn(ji,jj,jl)
299               END DO
300            END DO
301            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
302            znam = 'sxa'//'_htc'//zchar
303!$OMP PARALLEL DO schedule(static) private(jj,ji)
304            DO jj = 1, jpj
305               DO ji = 1, jpi
306                  z2d(ji,jj) = sxa(ji,jj,jl)
307               END DO
308            END DO
309            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
310            znam = 'sya'//'_htc'//zchar
311!$OMP PARALLEL DO schedule(static) private(jj,ji)
312            DO jj = 1, jpj
313               DO ji = 1, jpi
314                  z2d(ji,jj) = sya(ji,jj,jl)
315               END DO
316            END DO
317            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
318            znam = 'sxxa'//'_htc'//zchar
319!$OMP PARALLEL DO schedule(static) private(jj,ji)
320            DO jj = 1, jpj
321               DO ji = 1, jpi
322                  z2d(ji,jj) = sxxa(ji,jj,jl)
323               END DO
324            END DO
325            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
326            znam = 'syya'//'_htc'//zchar
327!$OMP PARALLEL DO schedule(static) private(jj,ji)
328            DO jj = 1, jpj
329               DO ji = 1, jpi
330                  z2d(ji,jj) = syya(ji,jj,jl)
331               END DO
332            END DO
333            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
334            znam = 'sxya'//'_htc'//zchar
335!$OMP PARALLEL DO schedule(static) private(jj,ji)
336            DO jj = 1, jpj
337               DO ji = 1, jpi
338                  z2d(ji,jj) = sxya(ji,jj,jl)
339               END DO
340            END DO
341            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
342            znam = 'sxc0'//'_htc'//zchar
343!$OMP PARALLEL DO schedule(static) private(jj,ji)
344            DO jj = 1, jpj
345               DO ji = 1, jpi
346                  z2d(ji,jj) = sxc0(ji,jj,jl)
347               END DO
348            END DO
349            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
350            znam = 'syc0'//'_htc'//zchar
351!$OMP PARALLEL DO schedule(static) private(jj,ji)
352            DO jj = 1, jpj
353               DO ji = 1, jpi
354                  z2d(ji,jj) = syc0(ji,jj,jl)
355               END DO
356            END DO
357            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
358            znam = 'sxxc0'//'_htc'//zchar
359!$OMP PARALLEL DO schedule(static) private(jj,ji)
360            DO jj = 1, jpj
361               DO ji = 1, jpi
362                  z2d(ji,jj) = sxxc0(ji,jj,jl)
363               END DO
364            END DO
365            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
366            znam = 'syyc0'//'_htc'//zchar
367!$OMP PARALLEL DO schedule(static) private(jj,ji)
368            DO jj = 1, jpj
369               DO ji = 1, jpi
370                  z2d(ji,jj) = syyc0(ji,jj,jl)
371               END DO
372            END DO
373            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
374            znam = 'sxyc0'//'_htc'//zchar
375!$OMP PARALLEL DO schedule(static) private(jj,ji)
376            DO jj = 1, jpj
377               DO ji = 1, jpi
378                  z2d(ji,jj) = sxyc0(ji,jj,jl)
379               END DO
380            END DO
381            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
382            znam = 'sxsal'//'_htc'//zchar
383!$OMP PARALLEL DO schedule(static) private(jj,ji)
384            DO jj = 1, jpj
385               DO ji = 1, jpi
386                  z2d(ji,jj) = sxsal(ji,jj,jl)
387               END DO
388            END DO
389            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
390            znam = 'sysal'//'_htc'//zchar
391!$OMP PARALLEL DO schedule(static) private(jj,ji)
392            DO jj = 1, jpj
393               DO ji = 1, jpi
394                  z2d(ji,jj) = sysal(ji,jj,jl)
395               END DO
396            END DO
397            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
398            znam = 'sxxsal'//'_htc'//zchar
399!$OMP PARALLEL DO schedule(static) private(jj,ji)
400            DO jj = 1, jpj
401               DO ji = 1, jpi
402                  z2d(ji,jj) = sxxsal(ji,jj,jl)
403               END DO
404            END DO
405            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
406            znam = 'syysal'//'_htc'//zchar
407!$OMP PARALLEL DO schedule(static) private(jj,ji)
408            DO jj = 1, jpj
409               DO ji = 1, jpi
410                  z2d(ji,jj) = syysal(ji,jj,jl)
411               END DO
412            END DO
413            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
414            znam = 'sxysal'//'_htc'//zchar
415!$OMP PARALLEL DO schedule(static) private(jj,ji)
416            DO jj = 1, jpj
417               DO ji = 1, jpi
418                  z2d(ji,jj) = sxysal(ji,jj,jl)
419               END DO
420            END DO
421            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
422            znam = 'sxage'//'_htc'//zchar
423!$OMP PARALLEL DO schedule(static) private(jj,ji)
424            DO jj = 1, jpj
425               DO ji = 1, jpi
426                  z2d(ji,jj) = sxage(ji,jj,jl)
427               END DO
428            END DO
429            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
430            znam = 'syage'//'_htc'//zchar
431!$OMP PARALLEL DO schedule(static) private(jj,ji)
432            DO jj = 1, jpj
433               DO ji = 1, jpi
434                  z2d(ji,jj) = syage(ji,jj,jl)
435               END DO
436            END DO
437            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
438            znam = 'sxxage'//'_htc'//zchar
439!$OMP PARALLEL DO schedule(static) private(jj,ji)
440            DO jj = 1, jpj
441               DO ji = 1, jpi
442                  z2d(ji,jj) = sxxage(ji,jj,jl)
443               END DO
444            END DO
445            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
446            znam = 'syyage'//'_htc'//zchar
447!$OMP PARALLEL DO schedule(static) private(jj,ji)
448            DO jj = 1, jpj
449               DO ji = 1, jpi
450                  z2d(ji,jj) = syyage(ji,jj,jl)
451               END DO
452            END DO
453            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
454            znam = 'sxyage'//'_htc'//zchar
455!$OMP PARALLEL DO schedule(static) private(jj,ji)
456            DO jj = 1, jpj
457               DO ji = 1, jpi
458                  z2d(ji,jj) = sxyage(ji,jj,jl)
459               END DO
460            END DO
461            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
462         END DO
463
464         CALL iom_rstput( iter, nitrst, numriw, 'sxopw ' ,  sxopw  )
465         CALL iom_rstput( iter, nitrst, numriw, 'syopw ' ,  syopw  )
466         CALL iom_rstput( iter, nitrst, numriw, 'sxxopw' ,  sxxopw )
467         CALL iom_rstput( iter, nitrst, numriw, 'syyopw' ,  syyopw )
468         CALL iom_rstput( iter, nitrst, numriw, 'sxyopw' ,  sxyopw )
469         
470         DO jl = 1, jpl 
471            WRITE(zchar,'(I2.2)') jl
472            DO jk = 1, nlay_i 
473               WRITE(zchar1,'(I2.2)') jk
474               znam = 'sxe'//'_il'//zchar1//'_htc'//zchar
475!$OMP PARALLEL DO schedule(static) private(jj,ji)
476               DO jj = 1, jpj
477                  DO ji = 1, jpi
478                     z2d(ji,jj) = sxe(ji,jj,jk,jl)
479                  END DO
480               END DO
481               CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
482               znam = 'sye'//'_il'//zchar1//'_htc'//zchar
483!$OMP PARALLEL DO schedule(static) private(jj,ji)
484               DO jj = 1, jpj
485                  DO ji = 1, jpi
486                     z2d(ji,jj) = sye(ji,jj,jk,jl)
487                  END DO
488               END DO
489               CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
490               znam = 'sxxe'//'_il'//zchar1//'_htc'//zchar
491!$OMP PARALLEL DO schedule(static) private(jj,ji)
492               DO jj = 1, jpj
493                  DO ji = 1, jpi
494                     z2d(ji,jj) = sxxe(ji,jj,jk,jl)
495                  END DO
496               END DO
497               CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
498               znam = 'syye'//'_il'//zchar1//'_htc'//zchar
499!$OMP PARALLEL DO schedule(static) private(jj,ji)
500               DO jj = 1, jpj
501                  DO ji = 1, jpi
502                     z2d(ji,jj) = syye(ji,jj,jk,jl)
503                  END DO
504               END DO
505               CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
506               znam = 'sxye'//'_il'//zchar1//'_htc'//zchar
507!$OMP PARALLEL DO schedule(static) private(jj,ji)
508               DO jj = 1, jpj
509                  DO ji = 1, jpi
510                     z2d(ji,jj) = sxye(ji,jj,jk,jl)
511                  END DO
512               END DO
513               CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
514            END DO
515         END DO
516
517      ENDIF
518     
519      ! close restart file
520      ! ------------------
521      IF( iter == nitrst ) THEN
522         CALL iom_close( numriw )
523         lrst_ice = .FALSE.
524      ENDIF
525      !
526      CALL wrk_dealloc( jpi, jpj, z2d )
527      !
528   END SUBROUTINE lim_rst_write
529
530
531   SUBROUTINE lim_rst_read
532      !!----------------------------------------------------------------------
533      !!                    ***  lim_rst_read  ***
534      !!
535      !! ** purpose  :   read of sea-ice variable restart in a netcdf file
536      !!----------------------------------------------------------------------
537      INTEGER :: ji, jj, jk, jl
538      REAL(wp) ::   zfice, ziter
539      REAL(wp), POINTER, DIMENSION(:,:) ::   z2d
540      CHARACTER(len=25) ::   znam
541      CHARACTER(len=2)  ::   zchar, zchar1
542      INTEGER           ::   jlibalt = jprstlib
543      LOGICAL           ::   llok
544      !!----------------------------------------------------------------------
545
546      CALL wrk_alloc( jpi, jpj, z2d )
547
548      IF(lwp) THEN
549         WRITE(numout,*)
550         WRITE(numout,*) 'lim_rst_read : read ice NetCDF restart file'
551         WRITE(numout,*) '~~~~~~~~~~~~~'
552      ENDIF
553
554      CALL iom_open ( TRIM(cn_icerst_indir)//'/'//cn_icerst_in, numrir, kiolib = jprstlib )
555
556      CALL iom_get( numrir, 'nn_fsbc', zfice )
557      CALL iom_get( numrir, 'kt_ice' , ziter )   
558      IF(lwp) WRITE(numout,*) '   read ice restart file at time step    : ', ziter
559      IF(lwp) WRITE(numout,*) '   in any case we force it to nit000 - 1 : ', nit000 - 1
560
561      !Control of date
562
563      IF( ( nit000 - NINT(ziter) ) /= 1 .AND. ABS( nrstdt ) == 1 )   &
564         &     CALL ctl_stop( 'lim_rst_read ===>>>> : problem with nit000 in ice restart',  &
565         &                   '   verify the file or rerun with the value 0 for the',        &
566         &                   '   control of time parameter  nrstdt' )
567      IF( NINT(zfice) /= nn_fsbc          .AND. ABS( nrstdt ) == 1 )   &
568         &     CALL ctl_stop( 'lim_rst_read ===>>>> : problem with nn_fsbc in ice restart',  &
569         &                   '   verify the file or rerun with the value 0 for the',         &
570         &                   '   control of time parameter  nrstdt' )
571
572      ! Prognostic variables
573      DO jl = 1, jpl 
574         WRITE(zchar,'(I2.2)') jl
575         znam = 'v_i'//'_htc'//zchar
576         CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
577         v_i(:,:,jl) = z2d(:,:)
578         znam = 'v_s'//'_htc'//zchar
579         CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
580         v_s(:,:,jl) = z2d(:,:) 
581         znam = 'smv_i'//'_htc'//zchar
582         CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
583         smv_i(:,:,jl) = z2d(:,:)
584         znam = 'oa_i'//'_htc'//zchar
585         CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
586         oa_i(:,:,jl) = z2d(:,:)
587         znam = 'a_i'//'_htc'//zchar
588         CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
589         a_i(:,:,jl) = z2d(:,:)
590         znam = 't_su'//'_htc'//zchar
591         CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
592         t_su(:,:,jl) = z2d(:,:)
593      END DO
594
595      DO jl = 1, jpl 
596         WRITE(zchar,'(I2.2)') jl
597         znam = 'tempt_sl1'//'_htc'//zchar
598         CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
599         e_s(:,:,1,jl) = z2d(:,:)
600      END DO
601
602      DO jl = 1, jpl 
603         WRITE(zchar,'(I2.2)') jl
604         DO jk = 1, nlay_i 
605            WRITE(zchar1,'(I2.2)') jk
606            znam = 'tempt'//'_il'//zchar1//'_htc'//zchar
607            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
608            e_i(:,:,jk,jl) = z2d(:,:)
609         END DO
610      END DO
611
612      CALL iom_get( numrir, jpdom_autoglo, 'u_ice'     , u_ice      )
613      CALL iom_get( numrir, jpdom_autoglo, 'v_ice'     , v_ice      )
614      CALL iom_get( numrir, jpdom_autoglo, 'stress1_i' , stress1_i  )
615      CALL iom_get( numrir, jpdom_autoglo, 'stress2_i' , stress2_i  )
616      CALL iom_get( numrir, jpdom_autoglo, 'stress12_i', stress12_i )
617      CALL iom_get( numrir, jpdom_autoglo, 'snwice_mass'  , snwice_mass )
618      CALL iom_get( numrir, jpdom_autoglo, 'snwice_mass_b', snwice_mass_b )
619
620      ! In case Prather scheme is used for advection, read second order moments
621      ! ------------------------------------------------------------------------
622      IF( nn_limadv == -1 ) THEN
623
624         DO jl = 1, jpl 
625            WRITE(zchar,'(I2.2)') jl
626            znam = 'sxice'//'_htc'//zchar
627            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
628            sxice(:,:,jl) = z2d(:,:)
629            znam = 'syice'//'_htc'//zchar
630            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
631            syice(:,:,jl) = z2d(:,:)
632            znam = 'sxxice'//'_htc'//zchar
633            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
634            sxxice(:,:,jl) = z2d(:,:)
635            znam = 'syyice'//'_htc'//zchar
636            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
637            syyice(:,:,jl) = z2d(:,:)
638            znam = 'sxyice'//'_htc'//zchar
639            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
640            sxyice(:,:,jl) = z2d(:,:)
641            znam = 'sxsn'//'_htc'//zchar
642            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
643            sxsn(:,:,jl) = z2d(:,:)
644            znam = 'sysn'//'_htc'//zchar
645            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
646            sysn(:,:,jl) = z2d(:,:)
647            znam = 'sxxsn'//'_htc'//zchar
648            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
649            sxxsn(:,:,jl) = z2d(:,:)
650            znam = 'syysn'//'_htc'//zchar
651            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
652            syysn(:,:,jl) = z2d(:,:)
653            znam = 'sxysn'//'_htc'//zchar
654            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
655            sxysn(:,:,jl) = z2d(:,:)
656            znam = 'sxa'//'_htc'//zchar
657            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
658            sxa(:,:,jl) = z2d(:,:)
659            znam = 'sya'//'_htc'//zchar
660            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
661            sya(:,:,jl) = z2d(:,:)
662            znam = 'sxxa'//'_htc'//zchar
663            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
664            sxxa(:,:,jl) = z2d(:,:)
665            znam = 'syya'//'_htc'//zchar
666            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
667            syya(:,:,jl) = z2d(:,:)
668            znam = 'sxya'//'_htc'//zchar
669            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
670            sxya(:,:,jl) = z2d(:,:)
671            znam = 'sxc0'//'_htc'//zchar
672            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
673            sxc0(:,:,jl) = z2d(:,:)
674            znam = 'syc0'//'_htc'//zchar
675            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
676            syc0(:,:,jl) = z2d(:,:)
677            znam = 'sxxc0'//'_htc'//zchar
678            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
679            sxxc0(:,:,jl) = z2d(:,:)
680            znam = 'syyc0'//'_htc'//zchar
681            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
682            syyc0(:,:,jl) = z2d(:,:)
683            znam = 'sxyc0'//'_htc'//zchar
684            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
685            sxyc0(:,:,jl) = z2d(:,:)
686            znam = 'sxsal'//'_htc'//zchar
687            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
688            sxsal(:,:,jl) = z2d(:,:)
689            znam = 'sysal'//'_htc'//zchar
690            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
691            sysal(:,:,jl) = z2d(:,:)
692            znam = 'sxxsal'//'_htc'//zchar
693            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
694            sxxsal(:,:,jl) = z2d(:,:)
695            znam = 'syysal'//'_htc'//zchar
696            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
697            syysal(:,:,jl) = z2d(:,:)
698            znam = 'sxysal'//'_htc'//zchar
699            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
700            sxysal(:,:,jl) = z2d(:,:)
701            znam = 'sxage'//'_htc'//zchar
702            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
703            sxage(:,:,jl) = z2d(:,:)
704            znam = 'syage'//'_htc'//zchar
705            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
706            syage(:,:,jl) = z2d(:,:)
707            znam = 'sxxage'//'_htc'//zchar
708            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
709            sxxage(:,:,jl) = z2d(:,:)
710            znam = 'syyage'//'_htc'//zchar
711            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
712            syyage(:,:,jl) = z2d(:,:)
713            znam = 'sxyage'//'_htc'//zchar
714            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
715            sxyage(:,:,jl)= z2d(:,:)
716         END DO
717
718         CALL iom_get( numrir, jpdom_autoglo, 'sxopw ' ,  sxopw  )
719         CALL iom_get( numrir, jpdom_autoglo, 'syopw ' ,  syopw  )
720         CALL iom_get( numrir, jpdom_autoglo, 'sxxopw' ,  sxxopw )
721         CALL iom_get( numrir, jpdom_autoglo, 'syyopw' ,  syyopw )
722         CALL iom_get( numrir, jpdom_autoglo, 'sxyopw' ,  sxyopw )
723
724         DO jl = 1, jpl 
725            WRITE(zchar,'(I2.2)') jl
726            DO jk = 1, nlay_i 
727               WRITE(zchar1,'(I2.2)') jk
728               znam = 'sxe'//'_il'//zchar1//'_htc'//zchar
729               CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
730               sxe(:,:,jk,jl) = z2d(:,:)
731               znam = 'sye'//'_il'//zchar1//'_htc'//zchar
732               CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
733               sye(:,:,jk,jl) = z2d(:,:)
734               znam = 'sxxe'//'_il'//zchar1//'_htc'//zchar
735               CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
736               sxxe(:,:,jk,jl) = z2d(:,:)
737               znam = 'syye'//'_il'//zchar1//'_htc'//zchar
738               CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
739               syye(:,:,jk,jl) = z2d(:,:)
740               znam = 'sxye'//'_il'//zchar1//'_htc'//zchar
741               CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
742               sxye(:,:,jk,jl) = z2d(:,:)
743            END DO
744         END DO
745         !
746      END IF
747     
748      ! clem: I do not understand why the following IF is needed
749      !       I suspect something inconsistent in the main code with option nn_icesal=1
750      IF( nn_icesal == 1 ) THEN
751         DO jl = 1, jpl 
752            sm_i(:,:,jl) = rn_icesal
753            DO jk = 1, nlay_i 
754               s_i(:,:,jk,jl) = rn_icesal
755            END DO
756         END DO
757      ENDIF
758      !
759      !CALL iom_close( numrir ) !clem: closed in sbcice_lim.F90
760      !
761      CALL wrk_dealloc( jpi, jpj, z2d )
762      !
763   END SUBROUTINE lim_rst_read
764
765#else
766   !!----------------------------------------------------------------------
767   !!   Default option :       Empty module            NO LIM sea-ice model
768   !!----------------------------------------------------------------------
769CONTAINS
770   SUBROUTINE lim_rst_read             ! Empty routine
771   END SUBROUTINE lim_rst_read
772   SUBROUTINE lim_rst_write            ! Empty routine
773   END SUBROUTINE lim_rst_write
774#endif
775
776   !!======================================================================
777END MODULE limrst
Note: See TracBrowser for help on using the repository browser.