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

source: branches/dev_001_SBC/NEMO/LIM_SRC/limrst_2.F90 @ 882

Last change on this file since 882 was 882, checked in by ctlod, 16 years ago

dev_001_SBC: Step II: change effectively the modules names in addining _2 extension, see ticket: #110

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 13.2 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   !!----------------------------------------------------------------------
9#if defined key_lim2
10   !!----------------------------------------------------------------------
11   !!   'key_lim2' :                                  LIM 2.0 sea-ice model
12   !!----------------------------------------------------------------------
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 ice_2
19   USE sbc_oce
20   USE sbc_ice
21   USE daymod
22
23   USE in_out_manager
24   USE iom
25
26   IMPLICIT NONE
27   PRIVATE
28
29   PUBLIC   lim_rst_opn_2     ! routine called by sbcice_lim_2.F90
30   PUBLIC   lim_rst_write_2   ! routine called by sbcice_lim_2.F90
31   PUBLIC   lim_rst_read_2    ! routine called by iceini_2.F90
32
33   LOGICAL, PUBLIC ::   lrst_ice         !: logical to control the ice restart write
34   INTEGER, PUBLIC ::   numrir, numriw   !: logical unit for ice restart (read and write)
35
36   !!----------------------------------------------------------------------
37   !!   LIM 2.0,  UCL-LOCEAN-IPSL (2006)
38   !! $Id$
39   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
40   !!----------------------------------------------------------------------
41
42CONTAINS
43
44   SUBROUTINE lim_rst_opn_2( kt )
45      !!----------------------------------------------------------------------
46      !!                    ***  lim_rst_opn_2  ***
47      !!
48      !! ** purpose  :   output of sea-ice variable in a netcdf file
49      !!----------------------------------------------------------------------
50      INTEGER, INTENT(in) ::   kt       ! number of iteration
51      !
52      CHARACTER(LEN=20)   ::   clkt     ! ocean time-step deine as a character
53      CHARACTER(LEN=50)   ::   clname   ! ice output restart file name
54      !!----------------------------------------------------------------------
55      !
56      IF( kt == nit000 )   lrst_ice = .FALSE.   ! default definition
57     
58      ! to get better performances with NetCDF format:
59      ! we open and define the ice restart file one ice time step before writing the data (-> at nitrst - 2*nn_fsbc + 1)
60      ! 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
61      IF( kt == nitrst - 2*nn_fsbc + 1 .OR. nstock == nn_fsbc .OR. ( kt == nitend - nn_fsbc + 1 .AND. .NOT. lrst_ice ) ) 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))//"_restart_ice"
68         IF(lwp) THEN
69            WRITE(numout,*)
70            SELECT CASE ( jprstlib )
71            CASE ( jprstdimg )   ;   WRITE(numout,*) '             open ice restart binary file: '//clname
72            CASE DEFAULT         ;   WRITE(numout,*) '             open ice restart NetCDF file: '//clname
73            END SELECT
74            IF( kt == nitrst - 2*nn_fsbc + 1 ) THEN   
75               WRITE(numout,*)         '             kt = nitrst - 2*nn_fsbc + 1 = ', kt,' date= ', ndastp
76            ELSE   ;   WRITE(numout,*) '             kt = '                         , kt,' date= ', ndastp
77            ENDIF
78         ENDIF
79
80         CALL iom_open( clname, numriw, ldwrt = .TRUE., kiolib = jprstlib )
81         lrst_ice = .TRUE.
82      ENDIF
83      !
84   END SUBROUTINE lim_rst_opn_2
85
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# if defined key_coupled
116      CALL iom_rstput( iter, nitrst, numriw, 'albege', albege(:,:) )
117# endif
118      CALL iom_rstput( iter, nitrst, numriw, 'tbif1' , tbif  (:,:,1) )
119      CALL iom_rstput( iter, nitrst, numriw, 'tbif2' , tbif  (:,:,2) )
120      CALL iom_rstput( iter, nitrst, numriw, 'tbif3' , tbif  (:,:,3) )
121      CALL iom_rstput( iter, nitrst, numriw, 'ui_ice', ui_ice(:,:)   )
122      CALL iom_rstput( iter, nitrst, numriw, 'vi_ice', vi_ice(:,:)   )
123      CALL iom_rstput( iter, nitrst, numriw, 'qstoif', qstoif(:,:)   )
124      CALL iom_rstput( iter, nitrst, numriw, 'fsbbq' , fsbbq (:,:)   )
125      CALL iom_rstput( iter, nitrst, numriw, 'sxice' , sxice (:,:)   )
126      CALL iom_rstput( iter, nitrst, numriw, 'syice' , syice (:,:)   )
127      CALL iom_rstput( iter, nitrst, numriw, 'sxxice', sxxice(:,:)   )
128      CALL iom_rstput( iter, nitrst, numriw, 'syyice', syyice(:,:)   )
129      CALL iom_rstput( iter, nitrst, numriw, 'sxyice', sxyice(:,:)   )
130      CALL iom_rstput( iter, nitrst, numriw, 'sxsn'  , sxsn  (:,:)   )
131      CALL iom_rstput( iter, nitrst, numriw, 'sysn'  , sysn  (:,:)   )
132      CALL iom_rstput( iter, nitrst, numriw, 'sxxsn' , sxxsn (:,:)   )
133      CALL iom_rstput( iter, nitrst, numriw, 'syysn' , syysn (:,:)   )
134      CALL iom_rstput( iter, nitrst, numriw, 'sxysn' , sxysn (:,:)   )
135      CALL iom_rstput( iter, nitrst, numriw, 'sxa'   , sxa   (:,:)   )
136      CALL iom_rstput( iter, nitrst, numriw, 'sya'   , sya   (:,:)   )
137      CALL iom_rstput( iter, nitrst, numriw, 'sxxa'  , sxxa  (:,:)   )
138      CALL iom_rstput( iter, nitrst, numriw, 'syya'  , syya  (:,:)   )
139      CALL iom_rstput( iter, nitrst, numriw, 'sxya'  , sxya  (:,:)   )
140      CALL iom_rstput( iter, nitrst, numriw, 'sxc0'  , sxc0  (:,:)   )
141      CALL iom_rstput( iter, nitrst, numriw, 'syc0'  , syc0  (:,:)   )
142      CALL iom_rstput( iter, nitrst, numriw, 'sxxc0' , sxxc0 (:,:)   )
143      CALL iom_rstput( iter, nitrst, numriw, 'syyc0' , syyc0 (:,:)   )
144      CALL iom_rstput( iter, nitrst, numriw, 'sxyc0' , sxyc0 (:,:)   )
145      CALL iom_rstput( iter, nitrst, numriw, 'sxc1'  , sxc1  (:,:)   )
146      CALL iom_rstput( iter, nitrst, numriw, 'syc1'  , syc1  (:,:)   )
147      CALL iom_rstput( iter, nitrst, numriw, 'sxxc1' , sxxc1 (:,:)   )
148      CALL iom_rstput( iter, nitrst, numriw, 'syyc1' , syyc1 (:,:)   )
149      CALL iom_rstput( iter, nitrst, numriw, 'sxyc1' , sxyc1 (:,:)   )
150      CALL iom_rstput( iter, nitrst, numriw, 'sxc2'  , sxc2  (:,:)   )
151      CALL iom_rstput( iter, nitrst, numriw, 'syc2'  , syc2  (:,:)   )
152      CALL iom_rstput( iter, nitrst, numriw, 'sxxc2' , sxxc2 (:,:)   )
153      CALL iom_rstput( iter, nitrst, numriw, 'syyc2' , syyc2 (:,:)   )
154      CALL iom_rstput( iter, nitrst, numriw, 'sxyc2' , sxyc2 (:,:)   )
155      CALL iom_rstput( iter, nitrst, numriw, 'sxst'  , sxst  (:,:)   )
156      CALL iom_rstput( iter, nitrst, numriw, 'syst'  , syst  (:,:)   )
157      CALL iom_rstput( iter, nitrst, numriw, 'sxxst' , sxxst (:,:)   )
158      CALL iom_rstput( iter, nitrst, numriw, 'syyst' , syyst (:,:)   )
159      CALL iom_rstput( iter, nitrst, numriw, 'sxyst' , sxyst (:,:)   )
160     
161      IF( iter == nitrst ) THEN
162         CALL iom_close( numriw )                         ! close the restart file
163         lrst_ice = .FALSE.
164      ENDIF
165      !
166   END SUBROUTINE lim_rst_write_2
167
168
169   SUBROUTINE lim_rst_read_2
170      !!----------------------------------------------------------------------
171      !!                    ***  lim_rst_read_2  ***
172      !!
173      !! ** purpose  :   read of sea-ice variable restart in a netcdf file
174      !!----------------------------------------------------------------------
175      REAL(wp) ::   ziter
176      !!----------------------------------------------------------------------
177
178      IF(lwp) THEN
179         WRITE(numout,*)
180         WRITE(numout,*) 'lim_rst_read_2 : read ice NetCDF restart file'
181         WRITE(numout,*) '~~~~~~~~~~~~~~'
182      ENDIF
183
184      CALL iom_open ( 'restart_ice_in', numrir, kiolib = jprstlib )
185
186      CALL iom_get( numrir, 'kt_ice' , ziter )
187      IF(lwp) WRITE(numout,*) '   read ice restart file at time step    : ', INT( ziter )
188      IF(lwp) WRITE(numout,*) '   in any case we force it to nit000 - 1 : ', nit000 - 1
189
190      !Control of date
191     
192      IF( ( nit000 - INT(ziter) ) /= 1 .AND. ABS( nrstdt ) == 1 )   &
193         &     CALL ctl_stop( 'lim_rst_read ===>>>> : problem with nit000 in ice restart',  &
194         &                   '   verify the file or rerun with the value 0 for the',        &
195         &                   '   control of time parameter  nrstdt' )
196
197      CALL iom_get( numrir, jpdom_autoglo, 'hicif' , hicif  )   
198      CALL iom_get( numrir, jpdom_autoglo, 'hsnif' , hsnif  )   
199      CALL iom_get( numrir, jpdom_autoglo, 'frld'  , frld   )   
200      CALL iom_get( numrir, jpdom_autoglo, 'sist'  , sist   )   
201# if defined key_coupled 
202      CALL iom_get( numrir, jpdom_autoglo, 'albege', albege )   
203# endif
204      CALL iom_get( numrir, jpdom_autoglo, 'tbif1' , tbif(:,:,1) )   
205      CALL iom_get( numrir, jpdom_autoglo, 'tbif2' , tbif(:,:,2) )   
206      CALL iom_get( numrir, jpdom_autoglo, 'tbif3' , tbif(:,:,3) )   
207      CALL iom_get( numrir, jpdom_autoglo, 'ui_ice', ui_ice )   
208      CALL iom_get( numrir, jpdom_autoglo, 'vi_ice', vi_ice )   
209      CALL iom_get( numrir, jpdom_autoglo, 'qstoif', qstoif )   
210      CALL iom_get( numrir, jpdom_autoglo, 'fsbbq' , fsbbq  )   
211      CALL iom_get( numrir, jpdom_autoglo, 'sxice' , sxice  )
212      CALL iom_get( numrir, jpdom_autoglo, 'syice' , syice  )
213      CALL iom_get( numrir, jpdom_autoglo, 'sxxice', sxxice )
214      CALL iom_get( numrir, jpdom_autoglo, 'syyice', syyice )
215      CALL iom_get( numrir, jpdom_autoglo, 'sxyice', sxyice )
216      CALL iom_get( numrir, jpdom_autoglo, 'sxsn'  , sxsn   )
217      CALL iom_get( numrir, jpdom_autoglo, 'sysn'  , sysn   )
218      CALL iom_get( numrir, jpdom_autoglo, 'sxxsn' , sxxsn  )
219      CALL iom_get( numrir, jpdom_autoglo, 'syysn' , syysn  )
220      CALL iom_get( numrir, jpdom_autoglo, 'sxysn' , sxysn  )
221      CALL iom_get( numrir, jpdom_autoglo, 'sxa'   , sxa    )
222      CALL iom_get( numrir, jpdom_autoglo, 'sya'   , sya    )
223      CALL iom_get( numrir, jpdom_autoglo, 'sxxa'  , sxxa   )
224      CALL iom_get( numrir, jpdom_autoglo, 'syya'  , syya   )
225      CALL iom_get( numrir, jpdom_autoglo, 'sxya'  , sxya   )
226      CALL iom_get( numrir, jpdom_autoglo, 'sxc0'  , sxc0   )
227      CALL iom_get( numrir, jpdom_autoglo, 'syc0'  , syc0   )
228      CALL iom_get( numrir, jpdom_autoglo, 'sxxc0' , sxxc0  )
229      CALL iom_get( numrir, jpdom_autoglo, 'syyc0' , syyc0  )
230      CALL iom_get( numrir, jpdom_autoglo, 'sxyc0' , sxyc0  )
231      CALL iom_get( numrir, jpdom_autoglo, 'sxc1'  , sxc1   )
232      CALL iom_get( numrir, jpdom_autoglo, 'syc1'  , syc1   )
233      CALL iom_get( numrir, jpdom_autoglo, 'sxxc1' , sxxc1  )
234      CALL iom_get( numrir, jpdom_autoglo, 'syyc1' , syyc1  )
235      CALL iom_get( numrir, jpdom_autoglo, 'sxyc1' , sxyc1  )
236      CALL iom_get( numrir, jpdom_autoglo, 'sxc2'  , sxc2   )
237      CALL iom_get( numrir, jpdom_autoglo, 'syc2'  , syc2   )
238      CALL iom_get( numrir, jpdom_autoglo, 'sxxc2' , sxxc2  )
239      CALL iom_get( numrir, jpdom_autoglo, 'syyc2' , syyc2  )
240      CALL iom_get( numrir, jpdom_autoglo, 'sxyc2' , sxyc2  )
241      CALL iom_get( numrir, jpdom_autoglo, 'sxst'  , sxst   )
242      CALL iom_get( numrir, jpdom_autoglo, 'syst'  , syst   )
243      CALL iom_get( numrir, jpdom_autoglo, 'sxxst' , sxxst  )
244      CALL iom_get( numrir, jpdom_autoglo, 'syyst' , syyst  )
245      CALL iom_get( numrir, jpdom_autoglo, 'sxyst' , sxyst  )
246     
247      CALL iom_close( numrir )
248      !
249   END SUBROUTINE lim_rst_read_2
250
251#else
252   !!----------------------------------------------------------------------
253   !!   Default option :       Empty module        NO LIM 2.0 sea-ice model
254   !!----------------------------------------------------------------------
255#endif
256
257   !!======================================================================
258END MODULE limrst_2
Note: See TracBrowser for help on using the repository browser.