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/2014/dev_r4650_UKMO11_restart_functionality/NEMOGCM/NEMO/LIM_SRC_2 – NEMO

source: branches/2014/dev_r4650_UKMO11_restart_functionality/NEMOGCM/NEMO/LIM_SRC_2/limrst_2.F90 @ 4780

Last change on this file since 4780 was 4780, checked in by edblockley, 10 years ago

Second commit in UKMO11 development branch.

This change allows the user to replace the nn_stock frequency-based restart dump writing functionality with a list-based version (nn_stocklist).
This is conterolled using the logical ln_rst_list which defaults to false.
At present the list is hard-wired to have maximum 10 entries but this could be modified if required.

Ed

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