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/DEV_r1837_mass_heat_salt_fluxes/NEMO/LIM_SRC_2 – NEMO

source: branches/DEV_r1837_mass_heat_salt_fluxes/NEMO/LIM_SRC_2/limrst_2.F90 @ 1855

Last change on this file since 1855 was 1855, checked in by gm, 14 years ago

ticket:#665 style change only, with the suppression of thd_ice_2 (merged in ice_2)

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