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/NEMO/LIM_SRC – NEMO

source: trunk/NEMO/LIM_SRC/limrst.F90 @ 508

Last change on this file since 508 was 508, checked in by opalod, 18 years ago

nemo_v1_update_071:RB: add iom for restart and reorganization of restart

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 13.7 KB
Line 
1MODULE limrst
2   !!======================================================================
3   !!                     ***  MODULE  limrst  ***
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   !!----------------------------------------------------------------------
9#if defined key_ice_lim
10   !!----------------------------------------------------------------------
11   !!   'key_ice_lim' :                                   LIM sea-ice model
12   !!----------------------------------------------------------------------
13   !!----------------------------------------------------------------------
14   !!   lim_rst_opn   : open ice restart file
15   !!   lim_rst_write : write of the ice restart file
16   !!   lim_rst_read  : read  the ice restart file
17   !!----------------------------------------------------------------------
18   USE ice
19   USE dom_oce
20   USE ice_oce         ! ice variables
21   USE daymod
22
23   USE in_out_manager
24   USE iom
25   USE restart
26
27   IMPLICIT NONE
28   PRIVATE
29
30   PUBLIC   lim_rst_opn     ! routine called by ??? module
31   PUBLIC   lim_rst_write   ! routine called by ??? module
32   PUBLIC   lim_rst_read    ! routine called by ??? module
33
34   LOGICAL, PUBLIC ::   lrst_ice         !: logical to control the oce restart write
35   INTEGER, PUBLIC ::   numrir, numriw   !: logical unit for ice restart (read and write)
36
37   !!----------------------------------------------------------------------
38   !!   LIM 2.0,  UCL-LOCEAN-IPSL (2006)
39   !! $Header$
40   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
41   !!----------------------------------------------------------------------
42
43CONTAINS
44
45# if ( defined key_mpp_mpi || defined key_mpp_shmem ) && defined key_dimgout
46   !!----------------------------------------------------------------------
47   !!   'key_mpp_mpi'     OR     'key_mpp_shmem'              MPP computing
48   !!   'key_dimgout' :                    Direct access file (DIMG format)
49   !!----------------------------------------------------------------------
50#  include "limrst_dimg.h90"
51
52# else
53   !!----------------------------------------------------------------------
54   !!   Default option                                          NetCDF file
55   !!----------------------------------------------------------------------
56
57   SUBROUTINE lim_rst_opn( kt )
58      !!----------------------------------------------------------------------
59      !!                    ***  lim_rst_opn  ***
60      !!
61      !! ** purpose  :   output of sea-ice variable in a netcdf file
62      !!----------------------------------------------------------------------
63      INTEGER, INTENT(in) ::   kt       ! number of iteration
64      !
65      CHARACTER(LEN=20)   ::   clkt     ! ocean time-step deine as a character
66      CHARACTER(LEN=50)   ::   clname   ! ice output restart file name
67      !!----------------------------------------------------------------------
68      !
69      IF( kt == nit000 )   lrst_ice = .FALSE.
70     
71      IF    ( kt == nitrst - 2*nfice + 1 .AND. lrst_ice ) THEN
72         CALL ctl_stop( 'lim_rst_opn: ice restart frequency must be larger than nfice' )
73         numriw = 0
74      ELSEIF( kt == nitrst - 2*nfice + 1 .OR.  nitend - nit000 +1 < 2*nfice ) THEN
75         ! beware if model runs less than 2*nfice time step
76         ! beware of the format used to write kt (default is i8.8, that should be large enough)
77         IF( nitrst > 1.0e9 ) THEN   
78            WRITE(clkt,*) nitrst
79         ELSE
80            WRITE(clkt,'(i8.8)') nitrst
81         ENDIF
82         ! create the file
83         IF(lwp) WRITE(numout,*)
84         clname = TRIM(cexper)//"_"//TRIM(ADJUSTL(clkt))//"_restart_ice"
85         IF(lwp) WRITE(numout,*) '             open ice restart.output NetCDF file: '//clname
86         CALL iom_open( clname, numriw, ldwrt = .TRUE. )
87         lrst_ice = .TRUE.
88      ENDIF
89      !
90   END SUBROUTINE lim_rst_opn
91
92   SUBROUTINE lim_rst_write( kt )
93      !!----------------------------------------------------------------------
94      !!                    ***  lim_rst_write  ***
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 + nfice -1
101      !!----------------------------------------------------------------------
102
103      iter = kt + nfice -1
104
105      IF( iter == nitrst ) THEN
106         IF(lwp) WRITE(numout,*)
107         IF(lwp) WRITE(numout,*) 'lim_rst_write : write ice restart.output NetCDF 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, 'nfice' , REAL( nfice, wp) )      ! time-step
115      CALL iom_rstput( iter, nitrst, numriw, 'kt_ice', REAL( iter, wp) )      ! date
116     
117      CALL iom_rstput( iter, nitrst, numriw, 'hicif' , hicif (:,:)   )      ! prognostic variables
118      CALL iom_rstput( iter, nitrst, numriw, 'hsnif' , hsnif (:,:)   )
119      CALL iom_rstput( iter, nitrst, numriw, 'frld'  , frld  (:,:)   )
120      CALL iom_rstput( iter, nitrst, numriw, 'sist'  , sist  (:,:)   )
121# if defined key_coupled
122      CALL iom_rstput( iter, nitrst, numriw, 'albege', albege(:,:) )
123# endif
124      CALL iom_rstput( iter, nitrst, numriw, 'tbif1' , tbif  (:,:,1) )
125      CALL iom_rstput( iter, nitrst, numriw, 'tbif2' , tbif  (:,:,2) )
126      CALL iom_rstput( iter, nitrst, numriw, 'tbif3' , tbif  (:,:,3) )
127      CALL iom_rstput( iter, nitrst, numriw, 'u_ice' , u_ice (:,:)   )
128      CALL iom_rstput( iter, nitrst, numriw, 'v_ice' , v_ice (:,:)   )
129      CALL iom_rstput( iter, nitrst, numriw, 'gtaux' , gtaux (:,:)   )
130      CALL iom_rstput( iter, nitrst, numriw, 'gtauy' , gtauy (:,:)   )
131      CALL iom_rstput( iter, nitrst, numriw, 'qstoif', qstoif(:,:)   )
132      CALL iom_rstput( iter, nitrst, numriw, 'fsbbq' , fsbbq (:,:)   )
133      CALL iom_rstput( iter, nitrst, numriw, 'sxice' , sxice (:,:)   )
134      CALL iom_rstput( iter, nitrst, numriw, 'syice' , syice (:,:)   )
135      CALL iom_rstput( iter, nitrst, numriw, 'sxxice', sxxice(:,:)   )
136      CALL iom_rstput( iter, nitrst, numriw, 'syyice', syyice(:,:)   )
137      CALL iom_rstput( iter, nitrst, numriw, 'sxyice', sxyice(:,:)   )
138      CALL iom_rstput( iter, nitrst, numriw, 'sxsn'  , sxsn  (:,:)   )
139      CALL iom_rstput( iter, nitrst, numriw, 'sysn'  , sysn  (:,:)   )
140      CALL iom_rstput( iter, nitrst, numriw, 'sxxsn' , sxxsn (:,:)   )
141      CALL iom_rstput( iter, nitrst, numriw, 'syysn' , syysn (:,:)   )
142      CALL iom_rstput( iter, nitrst, numriw, 'sxysn' , sxysn (:,:)   )
143      CALL iom_rstput( iter, nitrst, numriw, 'sxa'   , sxa   (:,:)   )
144      CALL iom_rstput( iter, nitrst, numriw, 'sya'   , sya   (:,:)   )
145      CALL iom_rstput( iter, nitrst, numriw, 'sxxa'  , sxxa  (:,:)   )
146      CALL iom_rstput( iter, nitrst, numriw, 'syya'  , syya  (:,:)   )
147      CALL iom_rstput( iter, nitrst, numriw, 'sxya'  , sxya  (:,:)   )
148      CALL iom_rstput( iter, nitrst, numriw, 'sxc0'  , sxc0  (:,:)   )
149      CALL iom_rstput( iter, nitrst, numriw, 'syc0'  , syc0  (:,:)   )
150      CALL iom_rstput( iter, nitrst, numriw, 'sxxc0' , sxxc0 (:,:)   )
151      CALL iom_rstput( iter, nitrst, numriw, 'syyc0' , syyc0 (:,:)   )
152      CALL iom_rstput( iter, nitrst, numriw, 'sxyc0' , sxyc0 (:,:)   )
153      CALL iom_rstput( iter, nitrst, numriw, 'sxc1'  , sxc1  (:,:)   )
154      CALL iom_rstput( iter, nitrst, numriw, 'syc1'  , syc1  (:,:)   )
155      CALL iom_rstput( iter, nitrst, numriw, 'sxxc1' , sxxc1 (:,:)   )
156      CALL iom_rstput( iter, nitrst, numriw, 'syyc1' , syyc1 (:,:)   )
157      CALL iom_rstput( iter, nitrst, numriw, 'sxyc1' , sxyc1 (:,:)   )
158      CALL iom_rstput( iter, nitrst, numriw, 'sxc2'  , sxc2  (:,:)   )
159      CALL iom_rstput( iter, nitrst, numriw, 'syc2'  , syc2  (:,:)   )
160      CALL iom_rstput( iter, nitrst, numriw, 'sxxc2' , sxxc2 (:,:)   )
161      CALL iom_rstput( iter, nitrst, numriw, 'syyc2' , syyc2 (:,:)   )
162      CALL iom_rstput( iter, nitrst, numriw, 'sxyc2' , sxyc2 (:,:)   )
163      CALL iom_rstput( iter, nitrst, numriw, 'sxst'  , sxst  (:,:)   )
164      CALL iom_rstput( iter, nitrst, numriw, 'syst'  , syst  (:,:)   )
165      CALL iom_rstput( iter, nitrst, numriw, 'sxxst' , sxxst (:,:)   )
166      CALL iom_rstput( iter, nitrst, numriw, 'syyst' , syyst (:,:)   )
167      CALL iom_rstput( iter, nitrst, numriw, 'sxyst' , sxyst (:,:)   )
168     
169      IF( iter == nitrst ) THEN
170         CALL iom_close( numriw )                         ! close the restart file
171         lrst_ice = .FALSE.
172      ENDIF
173      !
174   END SUBROUTINE lim_rst_write
175
176
177   SUBROUTINE lim_rst_read
178      !!----------------------------------------------------------------------
179      !!                    ***  lim_rst_read  ***
180      !!
181      !! ** purpose  :   read of sea-ice variable restart in a netcdf file
182      !!----------------------------------------------------------------------
183      !
184      REAL(wp) ::   zfice, ziter
185      !!----------------------------------------------------------------------
186
187      IF(lwp) THEN
188         WRITE(numout,*)
189         WRITE(numout,*) 'lim_rst_read : read ice NetCDF restart file'
190         WRITE(numout,*) '~~~~~~~~'
191      ENDIF
192
193      CALL iom_open ( 'restart_ice_in', numrir )
194
195      CALL iom_get( numrir, 'nfice' , zfice )
196      CALL iom_get( numrir, 'kt_ice', ziter )   
197      IF(lwp) WRITE(numout,*) '   read ice restart file at time step    : ', ziter
198      IF(lwp) WRITE(numout,*) '   in any case we force it to nit000 - 1 : ', nit000 - 1
199
200      !Control of date
201     
202      IF( ( nit000 - INT(ziter) ) /= 1 .AND. ABS( nrstdt ) == 1 )   &
203         &     CALL ctl_stop( 'lim_rst_read ===>>>> : problem with nit000 in ice restart',  &
204         &                   '   verify the file or rerun with the value 0 for the',        &
205         &                   '   control of time parameter  nrstdt' )
206      IF( INT(zfice) /= nfice          .AND. ABS( nrstdt ) == 1 )   &
207         &     CALL ctl_stop( 'lim_rst_read ===>>>> : problem with nfice in ice restart',  &
208         &                   '   verify the file or rerun with the value 0 for the',        &
209         &                   '   control of time parameter  nrstdt' )
210
211      CALL iom_get( numrir, jpdom_local, 'hicif' , hicif  )   
212      CALL iom_get( numrir, jpdom_local, 'hsnif' , hsnif  )   
213      CALL iom_get( numrir, jpdom_local, 'frld'  , frld   )   
214      CALL iom_get( numrir, jpdom_local, 'sist'  , sist   )   
215# if defined key_coupled 
216      CALL iom_get( numrir, jpdom_local, 'albege', albege )   
217# endif
218      CALL iom_get( numrir, jpdom_local, 'tbif1' , tbif(:,:,1) )   
219      CALL iom_get( numrir, jpdom_local, 'tbif2' , tbif(:,:,2) )   
220      CALL iom_get( numrir, jpdom_local, 'tbif3' , tbif(:,:,3) )   
221      CALL iom_get( numrir, jpdom_local, 'u_ice' , u_ice  )   
222      CALL iom_get( numrir, jpdom_local, 'v_ice' , v_ice  )   
223      CALL iom_get( numrir, jpdom_local, 'gtaux' , gtaux  )   
224      CALL iom_get( numrir, jpdom_local, 'gtauy' , gtauy  )   
225      CALL iom_get( numrir, jpdom_local, 'qstoif', qstoif )   
226      CALL iom_get( numrir, jpdom_local, 'fsbbq' , fsbbq  )   
227      CALL iom_get( numrir, jpdom_local, 'sxice' , sxice  )
228      CALL iom_get( numrir, jpdom_local, 'syice' , syice  )
229      CALL iom_get( numrir, jpdom_local, 'sxxice', sxxice )
230      CALL iom_get( numrir, jpdom_local, 'syyice', syyice )
231      CALL iom_get( numrir, jpdom_local, 'sxyice', sxyice )
232      CALL iom_get( numrir, jpdom_local, 'sxsn'  , sxsn   )
233      CALL iom_get( numrir, jpdom_local, 'sysn'  , sysn   )
234      CALL iom_get( numrir, jpdom_local, 'sxxsn' , sxxsn  )
235      CALL iom_get( numrir, jpdom_local, 'syysn' , syysn  )
236      CALL iom_get( numrir, jpdom_local, 'sxysn' , sxysn  )
237      CALL iom_get( numrir, jpdom_local, 'sxa'   , sxa    )
238      CALL iom_get( numrir, jpdom_local, 'sya'   , sya    )
239      CALL iom_get( numrir, jpdom_local, 'sxxa'  , sxxa   )
240      CALL iom_get( numrir, jpdom_local, 'syya'  , syya   )
241      CALL iom_get( numrir, jpdom_local, 'sxya'  , sxya   )
242      CALL iom_get( numrir, jpdom_local, 'sxc0'  , sxc0   )
243      CALL iom_get( numrir, jpdom_local, 'syc0'  , syc0   )
244      CALL iom_get( numrir, jpdom_local, 'sxxc0' , sxxc0  )
245      CALL iom_get( numrir, jpdom_local, 'syyc0' , syyc0  )
246      CALL iom_get( numrir, jpdom_local, 'sxyc0' , sxyc0  )
247      CALL iom_get( numrir, jpdom_local, 'sxc1'  , sxc1   )
248      CALL iom_get( numrir, jpdom_local, 'syc1'  , syc1   )
249      CALL iom_get( numrir, jpdom_local, 'sxxc1' , sxxc1  )
250      CALL iom_get( numrir, jpdom_local, 'syyc1' , syyc1  )
251      CALL iom_get( numrir, jpdom_local, 'sxyc1' , sxyc1  )
252      CALL iom_get( numrir, jpdom_local, 'sxc2'  , sxc2   )
253      CALL iom_get( numrir, jpdom_local, 'syc2'  , syc2   )
254      CALL iom_get( numrir, jpdom_local, 'sxxc2' , sxxc2  )
255      CALL iom_get( numrir, jpdom_local, 'syyc2' , syyc2  )
256      CALL iom_get( numrir, jpdom_local, 'sxyc2' , sxyc2  )
257      CALL iom_get( numrir, jpdom_local, 'sxst'  , sxst   )
258      CALL iom_get( numrir, jpdom_local, 'syst'  , syst   )
259      CALL iom_get( numrir, jpdom_local, 'sxxst' , sxxst  )
260      CALL iom_get( numrir, jpdom_local, 'syyst' , syyst  )
261      CALL iom_get( numrir, jpdom_local, 'sxyst' , sxyst  )
262     
263      CALL iom_close( numrir )
264      !
265   END SUBROUTINE lim_rst_read
266
267# endif
268
269#else
270   !!----------------------------------------------------------------------
271   !!   Default option :       Empty module            NO LIM sea-ice model
272   !!----------------------------------------------------------------------
273#endif
274
275   !!======================================================================
276END MODULE limrst
277
Note: See TracBrowser for help on using the repository browser.