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_2.F90 in branches/nemo_v3_3_beta/NEMOGCM/NEMO/LIM_SRC_2 – NEMO

source: branches/nemo_v3_3_beta/NEMOGCM/NEMO/LIM_SRC_2/limrst_2.F90 @ 2370

Last change on this file since 2370 was 2370, checked in by gm, 13 years ago

v3.3beta: ice-ocean stress at kt with VP & EVP (LIM-2 and -3)

  • Property svn:keywords set to Id
File size: 14.9 KB
Line 
1MODULE limrst_2
2   !!======================================================================
3   !!                     ***  MODULE  limrst_2  ***
4   !! Ice restart :  write the ice restart file
5   !!======================================================================
6   !! History :  2.0  !  01-04  (C. Ethe, G. Madec)  Original code
7   !!                 !  06-07  (S. Masson)  use IOM for restart read/write
8   !!            3.3  !  09-05  (G.Garric) addition of the lim2_evp case
9   !!----------------------------------------------------------------------
10#if defined key_lim2
11   !!----------------------------------------------------------------------
12   !!   'key_lim2' :                                  LIM 2.0 sea-ice model
13   !!----------------------------------------------------------------------
14   !!----------------------------------------------------------------------
15   !!   lim_rst_opn_2   : open ice restart file
16   !!   lim_rst_write_2 : write of the ice restart file
17   !!   lim_rst_read_2  : read  the ice restart file
18   !!----------------------------------------------------------------------
19   USE dom_oce         ! ocean space and time domain
20   USE ice_2
21   USE sbc_oce
22   USE sbc_ice
23
24   USE in_out_manager
25   USE iom
26
27   IMPLICIT NONE
28   PRIVATE
29
30   PUBLIC   lim_rst_opn_2     ! routine called by sbcice_lim_2.F90
31   PUBLIC   lim_rst_write_2   ! routine called by sbcice_lim_2.F90
32   PUBLIC   lim_rst_read_2    ! routine called by iceini_2.F90
33
34   LOGICAL, PUBLIC ::   lrst_ice         !: logical to control the ice restart write
35   INTEGER, PUBLIC ::   numrir, numriw   !: logical unit for ice restart (read and write)
36
37   !!----------------------------------------------------------------------
38   !! NEMO/LIM2 3.3 , UCL - NEMO Consortium (2010)
39   !! $Id$
40   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
41   !!----------------------------------------------------------------------
42
43CONTAINS
44
45   SUBROUTINE lim_rst_opn_2( kt )
46      !!----------------------------------------------------------------------
47      !!                    ***  lim_rst_opn_2  ***
48      !!
49      !! ** purpose  :   output of sea-ice variable in a netcdf file
50      !!----------------------------------------------------------------------
51      INTEGER, INTENT(in) ::   kt       ! number of iteration
52      !
53      CHARACTER(LEN=20)   ::   clkt     ! ocean time-step deine as a character
54      CHARACTER(LEN=50)   ::   clname   ! ice output restart file name
55      !!----------------------------------------------------------------------
56      !
57      IF( kt == nit000 )   lrst_ice = .FALSE.   ! default definition
58     
59      ! to get better performances with NetCDF format:
60      ! we open and define the ice restart file one ice time step before writing the data (-> at nitrst - 2*nn_fsbc + 1)
61      ! except if we write ice restart files every ice time step or if an ice restart file was writen at nitend - 2*nn_fsbc + 1
62      IF( kt == nitrst - 2*nn_fsbc + 1 .OR. nstock == nn_fsbc .OR. ( kt == nitend - nn_fsbc + 1 .AND. .NOT. lrst_ice ) ) THEN
63         ! beware of the format used to write kt (default is i8.8, that should be large enough...)
64         IF( nitrst > 99999999 ) THEN   ;   WRITE(clkt, *       ) nitrst
65         ELSE                           ;   WRITE(clkt, '(i8.8)') nitrst
66         ENDIF
67         ! create the file
68         clname = TRIM(cexper)//"_"//TRIM(ADJUSTL(clkt))//"_"//TRIM(cn_icerst_out)
69         IF(lwp) THEN
70            WRITE(numout,*)
71            SELECT CASE ( jprstlib )
72            CASE ( jprstdimg )   ;   WRITE(numout,*) '             open ice restart binary file: '//clname
73            CASE DEFAULT         ;   WRITE(numout,*) '             open ice restart NetCDF file: '//clname
74            END SELECT
75            IF( kt == nitrst - 2*nn_fsbc + 1 ) THEN   
76               WRITE(numout,*)         '             kt = nitrst - 2*nn_fsbc + 1 = ', kt,' date= ', ndastp
77            ELSE   ;   WRITE(numout,*) '             kt = '                         , kt,' date= ', ndastp
78            ENDIF
79         ENDIF
80
81         CALL iom_open( clname, numriw, ldwrt = .TRUE., kiolib = jprstlib )
82         lrst_ice = .TRUE.
83      ENDIF
84      !
85   END SUBROUTINE lim_rst_opn_2
86
87   SUBROUTINE lim_rst_write_2( kt )
88      !!----------------------------------------------------------------------
89      !!                    ***  lim_rst_write_2  ***
90      !!
91      !! ** purpose  :   output of sea-ice variable in a netcdf file
92      !!----------------------------------------------------------------------
93      INTEGER, INTENT(in) ::   kt   ! number of iteration
94      !
95      INTEGER ::   iter   ! kt + nn_fsbc -1
96      !!----------------------------------------------------------------------
97
98      iter = kt + nn_fsbc - 1   ! ice restarts are written at kt == nitrst - nn_fsbc + 1
99
100      IF( iter == nitrst ) THEN
101         IF(lwp) WRITE(numout,*)
102         IF(lwp) WRITE(numout,*) 'lim_rst_write_2 : write ice restart file  kt =', kt
103         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~~~'
104      ENDIF
105
106      ! Write in numriw (if iter == nitrst)
107      ! ------------------
108      !                                                                     ! calendar control
109      CALL iom_rstput( iter, nitrst, numriw, 'kt_ice', REAL( iter, wp) ) 
110     
111      CALL iom_rstput( iter, nitrst, numriw, 'hicif'      , hicif (:,:)   )      ! prognostic variables
112      CALL iom_rstput( iter, nitrst, numriw, 'hsnif'      , hsnif (:,:)   )
113      CALL iom_rstput( iter, nitrst, numriw, 'frld'       , frld  (:,:)   )
114      CALL iom_rstput( iter, nitrst, numriw, 'sist'       , sist  (:,:)   )
115      CALL iom_rstput( iter, nitrst, numriw, 'tbif1'      , tbif  (:,:,1) )
116      CALL iom_rstput( iter, nitrst, numriw, 'tbif2'      , tbif  (:,:,2) )
117      CALL iom_rstput( iter, nitrst, numriw, 'tbif3'      , tbif  (:,:,3) )
118      CALL iom_rstput( iter, nitrst, numriw, 'u_ice'      , u_ice (:,:)   )
119      CALL iom_rstput( iter, nitrst, numriw, 'v_ice'      , v_ice (:,:)   )
120      CALL iom_rstput( iter, nitrst, numriw, 'qstoif'     , qstoif(:,:)   )
121      CALL iom_rstput( iter, nitrst, numriw, 'fsbbq'      , fsbbq (:,:)   )
122#if ! defined key_lim2_vp
123      CALL iom_rstput( iter, nitrst, numriw, 'stress1_i'  , stress1_i (:,:) )    ! EVP rheology
124      CALL iom_rstput( iter, nitrst, numriw, 'stress2_i'  , stress2_i (:,:) )
125      CALL iom_rstput( iter, nitrst, numriw, 'stress12_i' , stress12_i(:,:) )
126#endif
127      CALL iom_rstput( iter, nitrst, numriw, 'sxice'      , sxice (:,:)   )
128      CALL iom_rstput( iter, nitrst, numriw, 'syice'      , syice (:,:)   )
129      CALL iom_rstput( iter, nitrst, numriw, 'sxxice'     , sxxice(:,:)   )
130      CALL iom_rstput( iter, nitrst, numriw, 'syyice'     , syyice(:,:)   )
131      CALL iom_rstput( iter, nitrst, numriw, 'sxyice'     , sxyice(:,:)   )
132      CALL iom_rstput( iter, nitrst, numriw, 'sxsn'       , sxsn  (:,:)   )
133      CALL iom_rstput( iter, nitrst, numriw, 'sysn'       , sysn  (:,:)   )
134      CALL iom_rstput( iter, nitrst, numriw, 'sxxsn'      , sxxsn (:,:)   )
135      CALL iom_rstput( iter, nitrst, numriw, 'syysn'      , syysn (:,:)   )
136      CALL iom_rstput( iter, nitrst, numriw, 'sxysn'      , sxysn (:,:)   )
137      CALL iom_rstput( iter, nitrst, numriw, 'sxa'        , sxa   (:,:)   )
138      CALL iom_rstput( iter, nitrst, numriw, 'sya'        , sya   (:,:)   )
139      CALL iom_rstput( iter, nitrst, numriw, 'sxxa'       , sxxa  (:,:)   )
140      CALL iom_rstput( iter, nitrst, numriw, 'syya'       , syya  (:,:)   )
141      CALL iom_rstput( iter, nitrst, numriw, 'sxya'       , sxya  (:,:)   )
142      CALL iom_rstput( iter, nitrst, numriw, 'sxc0'       , sxc0  (:,:)   )
143      CALL iom_rstput( iter, nitrst, numriw, 'syc0'       , syc0  (:,:)   )
144      CALL iom_rstput( iter, nitrst, numriw, 'sxxc0'      , sxxc0 (:,:)   )
145      CALL iom_rstput( iter, nitrst, numriw, 'syyc0'      , syyc0 (:,:)   )
146      CALL iom_rstput( iter, nitrst, numriw, 'sxyc0'      , sxyc0 (:,:)   )
147      CALL iom_rstput( iter, nitrst, numriw, 'sxc1'       , sxc1  (:,:)   )
148      CALL iom_rstput( iter, nitrst, numriw, 'syc1'       , syc1  (:,:)   )
149      CALL iom_rstput( iter, nitrst, numriw, 'sxxc1'      , sxxc1 (:,:)   )
150      CALL iom_rstput( iter, nitrst, numriw, 'syyc1'      , syyc1 (:,:)   )
151      CALL iom_rstput( iter, nitrst, numriw, 'sxyc1'      , sxyc1 (:,:)   )
152      CALL iom_rstput( iter, nitrst, numriw, 'sxc2'       , sxc2  (:,:)   )
153      CALL iom_rstput( iter, nitrst, numriw, 'syc2'       , syc2  (:,:)   )
154      CALL iom_rstput( iter, nitrst, numriw, 'sxxc2'      , sxxc2 (:,:)   )
155      CALL iom_rstput( iter, nitrst, numriw, 'syyc2'      , syyc2 (:,:)   )
156      CALL iom_rstput( iter, nitrst, numriw, 'sxyc2'      , sxyc2 (:,:)   )
157      CALL iom_rstput( iter, nitrst, numriw, 'sxst'       , sxst  (:,:)   )
158      CALL iom_rstput( iter, nitrst, numriw, 'syst'       , syst  (:,:)   )
159      CALL iom_rstput( iter, nitrst, numriw, 'sxxst'      , sxxst (:,:)   )
160      CALL iom_rstput( iter, nitrst, numriw, 'syyst'      , syyst (:,:)   )
161      CALL iom_rstput( iter, nitrst, numriw, 'sxyst'      , sxyst (:,:)   )
162     
163      IF( iter == nitrst ) THEN
164         CALL iom_close( numriw )                         ! close the restart file
165         lrst_ice = .FALSE.
166      ENDIF
167      !
168   END SUBROUTINE lim_rst_write_2
169
170
171   SUBROUTINE lim_rst_read_2
172      !!----------------------------------------------------------------------
173      !!                    ***  lim_rst_read_2  ***
174      !!
175      !! ** purpose  :   read of sea-ice variable restart in a netcdf file
176      !!----------------------------------------------------------------------
177      REAL(wp) ::   ziter
178      INTEGER  ::   jlibalt = jprstlib
179      LOGICAL  ::   llok
180      INTEGER  ::   itest
181      !!----------------------------------------------------------------------
182
183      IF(lwp) THEN
184         WRITE(numout,*)
185         WRITE(numout,*) 'lim_rst_read_2 : read ice NetCDF restart file'
186         WRITE(numout,*) '~~~~~~~~~~~~~~'
187      ENDIF
188
189      IF ( jprstlib == jprstdimg ) THEN
190        ! eventually read netcdf file (monobloc)  for restarting on different number of processors
191        ! if {cn_icerst_in}.nc exists, then set jlibalt to jpnf90
192        INQUIRE( FILE = TRIM(cn_icerst_in)//'.nc', EXIST = llok )
193        IF ( llok ) THEN ; jlibalt = jpnf90  ; ELSE ; jlibalt = jprstlib ; ENDIF
194      ENDIF
195
196      CALL iom_open ( cn_icerst_in, numrir, kiolib = jlibalt )
197
198      CALL iom_get( numrir, 'kt_ice' , ziter )
199      IF(lwp) WRITE(numout,*) '   read ice restart file at time step    : ', INT( ziter )
200      IF(lwp) WRITE(numout,*) '   in any case we force it to nit000 - 1 : ', nit000 - 1
201
202      !Control of date
203     
204      IF( ( nit000 - INT(ziter) ) /= 1 .AND. ABS( nrstdt ) == 1 )   &
205         &     CALL ctl_stop( 'lim_rst_read ===>>>> : problem with nit000 in ice restart',  &
206         &                   '   verify the file or rerun with the value 0 for the',        &
207         &                   '   control of time parameter  nrstdt' )
208
209      CALL iom_get( numrir, jpdom_autoglo, 'hicif' , hicif  )   
210      CALL iom_get( numrir, jpdom_autoglo, 'hsnif' , hsnif  )   
211      CALL iom_get( numrir, jpdom_autoglo, 'frld'  , frld   )   
212      CALL iom_get( numrir, jpdom_autoglo, 'sist'  , sist   )   
213      CALL iom_get( numrir, jpdom_autoglo, 'tbif1' , tbif(:,:,1) )   
214      CALL iom_get( numrir, jpdom_autoglo, 'tbif2' , tbif(:,:,2) )   
215      CALL iom_get( numrir, jpdom_autoglo, 'tbif3' , tbif(:,:,3) )   
216
217      itest = iom_varid( numrir, 'u_ice', ldstop = .FALSE. )   ! test if the variable u_ice is included in the file
218      IF( itest > 0 ) THEN   ! yes -> new restart files (from NEMO 3.2)
219         CALL iom_get( numrir, jpdom_autoglo, 'u_ice', u_ice ) 
220         CALL iom_get( numrir, jpdom_autoglo, 'v_ice', v_ice )   
221      ELSE                   ! no  -> old restart file with variable called [uv]i_ice (inroduced in NEMO 3.0)
222         CALL iom_get( numrir, jpdom_autoglo, 'ui_ice', u_ice ) 
223         CALL iom_get( numrir, jpdom_autoglo, 'vi_ice', v_ice )   
224      ENDIF
225
226      CALL iom_get( numrir, jpdom_autoglo, 'qstoif'     , qstoif )   
227      CALL iom_get( numrir, jpdom_autoglo, 'fsbbq'      , fsbbq  )   
228#if ! defined key_lim2_vp
229      CALL iom_get( numrir, jpdom_autoglo, 'stress1_i'  , stress1_i  )
230      CALL iom_get( numrir, jpdom_autoglo, 'stress2_i'  , stress2_i  )
231      CALL iom_get( numrir, jpdom_autoglo, 'stress12_i' , stress12_i )
232#endif
233      CALL iom_get( numrir, jpdom_autoglo, 'sxice'      , sxice  )
234      CALL iom_get( numrir, jpdom_autoglo, 'syice'      , syice  )
235      CALL iom_get( numrir, jpdom_autoglo, 'sxxice'     , sxxice )
236      CALL iom_get( numrir, jpdom_autoglo, 'syyice'     , syyice )
237      CALL iom_get( numrir, jpdom_autoglo, 'sxyice'     , sxyice )
238      CALL iom_get( numrir, jpdom_autoglo, 'sxsn'       , sxsn   )
239      CALL iom_get( numrir, jpdom_autoglo, 'sysn'       , sysn   )
240      CALL iom_get( numrir, jpdom_autoglo, 'sxxsn'      , sxxsn  )
241      CALL iom_get( numrir, jpdom_autoglo, 'syysn'      , syysn  )
242      CALL iom_get( numrir, jpdom_autoglo, 'sxysn'      , sxysn  )
243      CALL iom_get( numrir, jpdom_autoglo, 'sxa'        , sxa    )
244      CALL iom_get( numrir, jpdom_autoglo, 'sya'        , sya    )
245      CALL iom_get( numrir, jpdom_autoglo, 'sxxa'       , sxxa   )
246      CALL iom_get( numrir, jpdom_autoglo, 'syya'       , syya   )
247      CALL iom_get( numrir, jpdom_autoglo, 'sxya'       , sxya   )
248      CALL iom_get( numrir, jpdom_autoglo, 'sxc0'       , sxc0   )
249      CALL iom_get( numrir, jpdom_autoglo, 'syc0'       , syc0   )
250      CALL iom_get( numrir, jpdom_autoglo, 'sxxc0'      , sxxc0  )
251      CALL iom_get( numrir, jpdom_autoglo, 'syyc0'      , syyc0  )
252      CALL iom_get( numrir, jpdom_autoglo, 'sxyc0'      , sxyc0  )
253      CALL iom_get( numrir, jpdom_autoglo, 'sxc1'       , sxc1   )
254      CALL iom_get( numrir, jpdom_autoglo, 'syc1'       , syc1   )
255      CALL iom_get( numrir, jpdom_autoglo, 'sxxc1'      , sxxc1  )
256      CALL iom_get( numrir, jpdom_autoglo, 'syyc1'      , syyc1  )
257      CALL iom_get( numrir, jpdom_autoglo, 'sxyc1'      , sxyc1  )
258      CALL iom_get( numrir, jpdom_autoglo, 'sxc2'       , sxc2   )
259      CALL iom_get( numrir, jpdom_autoglo, 'syc2'       , syc2   )
260      CALL iom_get( numrir, jpdom_autoglo, 'sxxc2'      , sxxc2  )
261      CALL iom_get( numrir, jpdom_autoglo, 'syyc2'      , syyc2  )
262      CALL iom_get( numrir, jpdom_autoglo, 'sxyc2'      , sxyc2  )
263      CALL iom_get( numrir, jpdom_autoglo, 'sxst'       , sxst   )
264      CALL iom_get( numrir, jpdom_autoglo, 'syst'       , syst   )
265      CALL iom_get( numrir, jpdom_autoglo, 'sxxst'      , sxxst  )
266      CALL iom_get( numrir, jpdom_autoglo, 'syyst'      , syyst  )
267      CALL iom_get( numrir, jpdom_autoglo, 'sxyst'      , sxyst  )
268     
269      CALL iom_close( numrir )
270      !
271   END SUBROUTINE lim_rst_read_2
272
273#else
274   !!----------------------------------------------------------------------
275   !!   Default option :       Empty module        NO LIM 2.0 sea-ice model
276   !!----------------------------------------------------------------------
277#endif
278
279   !!======================================================================
280END MODULE limrst_2
Note: See TracBrowser for help on using the repository browser.