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 @ 238

Last change on this file since 238 was 238, checked in by opalod, 19 years ago

CT : UPDATE172 : remove all direct acces modules and the related cpp key key_fdir

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 11.3 KB
Line 
1MODULE limrst
2   !!======================================================================
3   !!                     ***  MODULE  limrst  ***
4   !! Ice restart :  write the ice restart file
5   !!======================================================================
6#if defined key_ice_lim
7   !!----------------------------------------------------------------------
8   !!   'key_ice_lim' :                                   LIM sea-ice model
9   !!----------------------------------------------------------------------
10   !!   lim_rst_write   : write of the restart file
11   !!   lim_rst_read    : read  the restart file
12   !!----------------------------------------------------------------------
13   !! * Modules used
14   USE in_out_manager
15   USE ice
16   USE ioipsl
17   USE dom_oce
18   USE ice_oce         ! ice variables
19   USE daymod
20
21   IMPLICIT NONE
22   PRIVATE
23
24   !! * Accessibility
25   PUBLIC lim_rst_write  ! routine called by lim_step.F90
26   PUBLIC lim_rst_read   ! routine called by lim_init.F90
27
28   !!----------------------------------------------------------------------
29   !!   LIM 2.0 , UCL-LODYC-IPSL  (2003)
30   !!----------------------------------------------------------------------
31
32CONTAINS
33
34# if ( defined key_mpp_mpi || defined key_mpp_shmem ) && defined key_dimgout
35   !!----------------------------------------------------------------------
36   !!   'key_mpp_mpi'     OR
37   !!   'key_mpp_shmem'
38   !!   'key_dimgout' :                           clipper type restart file
39   !!                 :                     can be used in mpp
40   !!----------------------------------------------------------------------
41#  include "limrst_dimg.h90"
42
43# else
44   !!----------------------------------------------------------------------
45   !!   Default option                                          NetCDF file
46   !!----------------------------------------------------------------------
47
48   SUBROUTINE lim_rst_write( niter )
49      !!----------------------------------------------------------------------
50      !!                    ***  lim_rst_write  ***
51      !!
52      !! ** purpose  :   output of sea-ice variable in a netcdf file
53      !!
54      !!----------------------------------------------------------------------
55      ! Arguments
56      INTEGER  ::    niter        ! number of iteration
57
58      !- dummy variables :
59      LOGICAL :: &
60         llbon
61      INTEGER :: &
62         ji, jj
63      INTEGER :: &
64         inumwrs, it0, itime
65      REAL(wp), DIMENSION(1) :: &
66         zdept
67      REAL(wp), DIMENSION(2) :: &
68         zinfo
69      REAL(wp),DIMENSION(jpi,jpj,35) :: &
70         zmoment
71      REAL(wp) :: &
72         zsec, zdate0, zdt
73
74      CHARACTER(len=45)  ::  &
75         ccfile = 'restart_ice_out.nc'
76
77      inumwrs  = 61
78      INQUIRE ( FILE = ccfile, EXIST = llbon )
79      IF( llbon ) THEN
80         OPEN ( UNIT = inumwrs , FILE = ccfile, STATUS = 'old' )
81         CLOSE( inumwrs , STATUS = 'delete' )
82      ENDIF
83
84
85      it0      = niter
86      zinfo(1) = FLOAT( nfice  )  ! coupling frequency OPA ICELLN  nfice
87      zinfo(2) = FLOAT( it0   )   ! iteration number
88
89      zsec     = 0.e0
90      itime    = 0
91      zdept(1) = 0.e0
92      zdt      = rdt_ice * nstock
93
94      ! Write in inumwrs
95
96      DO jj = 1, jpj              ! 3D array: 10 time faster than 35 restput
97         DO ji = 1, jpi
98            zmoment(ji,jj,1)  = sxice(ji,jj)
99            zmoment(ji,jj,2)  = syice(ji,jj)
100            zmoment(ji,jj,3)  = sxxice(ji,jj)
101            zmoment(ji,jj,4)  = syyice(ji,jj)
102            zmoment(ji,jj,5)  = sxyice(ji,jj)
103            zmoment(ji,jj,6)  = sxsn(ji,jj)
104            zmoment(ji,jj,7)  = sysn(ji,jj)
105            zmoment(ji,jj,8)  = sxxsn(ji,jj)
106            zmoment(ji,jj,9)  = syysn(ji,jj)
107            zmoment(ji,jj,10) = sxysn(ji,jj)
108            zmoment(ji,jj,11) = sxa(ji,jj)
109            zmoment(ji,jj,12) = sya(ji,jj)
110            zmoment(ji,jj,13) = sxxa(ji,jj)
111            zmoment(ji,jj,14) = syya(ji,jj)
112            zmoment(ji,jj,15) = sxya(ji,jj)
113            zmoment(ji,jj,16) = sxc0(ji,jj)
114            zmoment(ji,jj,17) = syc0(ji,jj)
115            zmoment(ji,jj,18) = sxxc0(ji,jj)
116            zmoment(ji,jj,19) = syyc0(ji,jj)
117            zmoment(ji,jj,20) = sxyc0(ji,jj)
118            zmoment(ji,jj,21) = sxc1(ji,jj)
119            zmoment(ji,jj,22) = syc1(ji,jj)
120            zmoment(ji,jj,23) = sxxc1(ji,jj)
121            zmoment(ji,jj,24) = syyc1(ji,jj)
122            zmoment(ji,jj,25) = sxyc1(ji,jj)
123            zmoment(ji,jj,26) = sxc2(ji,jj)
124            zmoment(ji,jj,27) = syc2(ji,jj)
125            zmoment(ji,jj,28) = sxxc2(ji,jj)
126            zmoment(ji,jj,29) = syyc2(ji,jj)
127            zmoment(ji,jj,30) = sxyc2(ji,jj)
128            zmoment(ji,jj,31) = sxst(ji,jj)
129            zmoment(ji,jj,32) = syst(ji,jj)
130            zmoment(ji,jj,33) = sxxst(ji,jj)
131            zmoment(ji,jj,34) = syyst(ji,jj)
132            zmoment(ji,jj,35) = sxyst(ji,jj)
133         END DO
134      END DO
135
136      CALL ymds2ju( nyear, nmonth, nday, zsec, zdate0 )
137      CALL restini( 'NONE', jpi, jpj, glamt, gphit, 1 , zdept, ccfile, itime, zdate0, zdt, inumwrs )
138     
139      CALL restput( inumwrs, 'info'   ,   1,   1, 2 , 0, zinfo   )  ! restart informations
140       
141      CALL restput( inumwrs, 'hicif'  , jpi, jpj, 1 , 0, hicif   )  ! prognostic variables
142      CALL restput( inumwrs, 'hsnif'  , jpi, jpj, 1 , 0, hsnif   )
143      CALL restput( inumwrs, 'frld'   , jpi, jpj, 1 , 0, frld    )
144      CALL restput( inumwrs, 'sist'   , jpi, jpj, 1 , 0, sist    )
145# if defined key_coupled
146      CALL restput( inumwrs, 'albege' , jpi, jpj, 1 , 0, albege  )
147# endif
148      CALL restput( inumwrs, 'tbif'   , jpi, jpj, 3 , 0, tbif    )
149      CALL restput( inumwrs, 'u_ice'  , jpi, jpj, 1 , 0, u_ice   )
150      CALL restput( inumwrs, 'v_ice'  , jpi, jpj, 1 , 0, v_ice   )
151      CALL restput( inumwrs, 'gtaux'  , jpi, jpj, 1 , 0, gtaux  )
152      CALL restput( inumwrs, 'gtauy'  , jpi, jpj, 1 , 0, gtauy  )
153      CALL restput( inumwrs, 'qstoif' , jpi, jpj, 1 , 0, qstoif  )
154      CALL restput( inumwrs, 'fsbbq'  , jpi, jpj, 1 , 0, fsbbq   )
155      CALL restput( inumwrs, 'moment' , jpi, jpj, 35, 0, zmoment )
156
157     
158      CALL restclo( inumwrs )
159
160   END SUBROUTINE lim_rst_write
161
162
163   SUBROUTINE lim_rst_read( niter )
164      !-----------------------------------------------------------------------
165      !  restart from a state defined in a binary file
166      !-----------------------------------------------------------------------
167      ! Arguments
168      INTEGER  ::   niter        ! number of iteration
169
170      !- dummy variables :
171      CHARACTER(len=45)  ::  &
172         ccfile = 'restart_ice_in.nc'
173      INTEGER :: &
174        ji, jj
175      INTEGER :: &
176         inumrst, it0, it1, itime, ibvar, ifice
177      LOGICAL :: &
178         llog
179      REAL(wp),DIMENSION(jpi,jpj) :: &
180         zlamt, zphit
181      REAL(wp),DIMENSION(jpi,jpj,35) :: &
182         zmoment
183      REAL(wp),DIMENSION(1) :: &
184         zdept
185      REAL(wp),DIMENSION(2) :: &
186         zinfo
187      REAL(wp) :: &
188         zdate0, zdt
189      CHARACTER ( len = 10 ) ::  &
190         clvnames(60)       
191
192
193      !Initialisations
194      inumrst    = 71
195      it0        = nit000
196      itime      = 0
197      llog       = .FALSE.
198      zlamt(:,:) = 0.
199      zphit(:,:) = 0.
200      zdept(1)   = 0.
201
202      CALL restini(ccfile , jpi, jpj, zlamt, zphit, 1 , zdept, ccfile, itime, zdate0, zdt, inumrst )     
203      CALL ioget_vname( inumrst, ibvar, clvnames )
204
205      CALL restget    ( inumrst,'info', 1, 1 , 2, 0, llog, zinfo )
206 
207      ifice   = INT( zinfo(1) )
208      it1     = INT( zinfo(2) )
209
210      IF(lwp) THEN
211         WRITE(numout,*)
212         WRITE(numout,*) 'lim_rst_read : READ restart file name ', ccfile,' at time step : ', it1
213         WRITE(numout,*) '~~~~~~~~~~~~   number of variables   : ', ibvar
214         WRITE(numout,*) '               NetCDF variables      : ', clvnames(1:ibvar)
215      ENDIF
216
217     
218      !Control of date
219     
220      IF( ( it0 - it1 ) /= 1 .AND. ABS( nrstdt ) == 1 ) THEN
221         IF(lwp) THEN
222            WRITE(numout,cform_err)
223            WRITE(numout,*) 'lim_rst_read ===>>>> : problem with nit000 for the restart'
224            WRITE(numout,*) '   we stop. verify the file or rerun with the value  0 for the'
225            WRITE(numout,*) '   control of time parameter  nrstdt'
226            nstop = nstop + 1
227         ENDIF
228      ENDIF
229
230      CALL restget( inumrst, 'hicif'  , jpi, jpj, 1 , 0, llog, hicif   )
231      CALL restget( inumrst, 'hsnif'  , jpi, jpj, 1 , 0, llog, hsnif   )
232      CALL restget( inumrst, 'frld'   , jpi, jpj, 1 , 0, llog, frld    )
233      CALL restget( inumrst, 'sist'   , jpi, jpj, 1 , 0, llog, sist    )
234# if defined key_coupled 
235      CALL restget( inumrst, 'albege' , jpi, jpj, 1 , 0, llog, albege  )
236# endif
237      CALL restget( inumrst, 'tbif'   , jpi, jpj, 3 , 0, llog, tbif    )
238      CALL restget( inumrst, 'u_ice'  , jpi, jpj, 1 , 0, llog, u_ice   )
239      CALL restget( inumrst, 'v_ice'  , jpi, jpj, 1 , 0, llog, v_ice   )
240      CALL restget( inumrst, 'gtaux'  , jpi, jpj, 1 , 0, llog, gtaux  )
241      CALL restget( inumrst, 'gtauy'  , jpi, jpj, 1 , 0, llog, gtauy  )
242      CALL restget( inumrst, 'qstoif' , jpi, jpj, 1 , 0, llog, qstoif  )
243      CALL restget( inumrst, 'fsbbq'  , jpi, jpj, 1 , 0, llog, fsbbq   )
244      CALL restget( inumrst, 'moment' , jpi, jpj, 35, 0, llog, zmoment )
245
246      CALL restclo( inumrst )
247
248      niter = it1
249      DO jj = 1, jpj
250         DO ji = 1, jpi
251            sxice(ji,jj)  = zmoment(ji,jj,1)
252            syice(ji,jj)  = zmoment(ji,jj,2)
253            sxxice(ji,jj) = zmoment(ji,jj,3)
254            syyice(ji,jj) = zmoment(ji,jj,4)
255            sxyice(ji,jj) = zmoment(ji,jj,5)
256            sxsn(ji,jj)   = zmoment(ji,jj,6)
257            sysn(ji,jj)   = zmoment(ji,jj,7)
258            sxxsn(ji,jj)  = zmoment(ji,jj,8)
259            syysn(ji,jj)  = zmoment(ji,jj,9)
260            sxysn(ji,jj)  = zmoment(ji,jj,10)
261            sxa(ji,jj)    = zmoment(ji,jj,11)
262            sya(ji,jj)    = zmoment(ji,jj,12)
263            sxxa(ji,jj)   = zmoment(ji,jj,13)
264            syya(ji,jj)   = zmoment(ji,jj,14)
265            sxya(ji,jj)   = zmoment(ji,jj,15)
266            sxc0(ji,jj)   = zmoment(ji,jj,16)
267            syc0(ji,jj)   = zmoment(ji,jj,17)
268            sxxc0(ji,jj)  = zmoment(ji,jj,18)
269            syyc0(ji,jj)  = zmoment(ji,jj,19)
270            sxyc0(ji,jj)  = zmoment(ji,jj,20)
271            sxc1(ji,jj)   = zmoment(ji,jj,21)
272            syc1(ji,jj)   = zmoment(ji,jj,22)
273            sxxc1(ji,jj)  = zmoment(ji,jj,23)
274            syyc1(ji,jj)  = zmoment(ji,jj,24)
275            sxyc1(ji,jj)  = zmoment(ji,jj,25)
276            sxc2(ji,jj)   = zmoment(ji,jj,26)
277            syc2(ji,jj)   = zmoment(ji,jj,27)
278            sxxc2(ji,jj)  = zmoment(ji,jj,28)
279            syyc2(ji,jj)  = zmoment(ji,jj,29)
280            sxyc2(ji,jj)  = zmoment(ji,jj,30)
281            sxst(ji,jj)   = zmoment(ji,jj,31)
282            syst(ji,jj)   = zmoment(ji,jj,32)
283            sxxst(ji,jj)  = zmoment(ji,jj,33)
284            syyst(ji,jj)  = zmoment(ji,jj,34)
285            sxyst(ji,jj)  = zmoment(ji,jj,35)
286         END DO
287      END DO
288
289     
290   END SUBROUTINE lim_rst_read
291
292# endif
293
294#else
295   !!----------------------------------------------------------------------
296   !!   Default option :       Empty module            NO LIM sea-ice model
297   !!----------------------------------------------------------------------
298CONTAINS
299   SUBROUTINE lim_rst_read             ! Empty routine
300   END SUBROUTINE lim_rst_read
301   SUBROUTINE lim_rst_write            ! Empty routine
302   END SUBROUTINE lim_rst_write
303#endif
304
305   !!======================================================================
306END MODULE limrst
Note: See TracBrowser for help on using the repository browser.