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.
trdmld_rst.F90 in trunk/NEMO/OPA_SRC/TRD – NEMO

source: trunk/NEMO/OPA_SRC/TRD/trdmld_rst.F90 @ 783

Last change on this file since 783 was 783, checked in by smasson, 16 years ago

write multiple restarts, see ticket:44

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.4 KB
Line 
1MODULE trdmld_rst
2   !!=================================================================================
3   !!                       ***  MODULE  trdmld_rst  ***
4   !! Ocean dynamic :  Input/Output files for restart on mixed-layer diagnostics
5   !!=================================================================================
6   !! History :  9.0  ! 05-05 (C. Deltel) Original code
7   !!---------------------------------------------------------------------------------
8#if defined key_trdmld
9   !!---------------------------------------------------------------------------------
10   USE dom_oce         ! ocean space and time domain
11   USE trdmod_oce      ! ocean variables for trend diagnostics (i.e. icp/mixed-layer/vorticity)
12   USE in_out_manager  ! I/O manager
13   USE daymod          ! calendar
14   USE iom             ! I/O module
15   USE restart         ! only for lrst_oce
16
17   IMPLICIT NONE
18   PRIVATE
19 
20   PUBLIC   trd_mld_rst_read    ! routine called by trd_mld_init
21   PUBLIC   trd_mld_rst_write   ! routine called by step.F90
22 
23   CHARACTER (len=48) ::   crestart = 'initial.nc'   ! restart file name
24   INTEGER ::   nummldw                              ! logical unit for mld restart
25
26   !!---------------------------------------------------------------------------------
27   !! OPA 9.0 , LOCEAN-IPSL (2006)
28   !! $Header: /home/opalod/NEMOCVSROOT/NEMO/OPA_SRC/TRD/trdmld_rst.F90,v 1.7 2007/06/05 10:40:59 opalod Exp $
29   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
30   !!---------------------------------------------------------------------------------
31 
32CONTAINS
33 
34   SUBROUTINE trd_mld_rst_write( kt )
35      !!--------------------------------------------------------------------------------
36      !!                  ***  SUBROUTINE trd_mld_rst_wri  ***
37      !!               
38      !! ** Purpose :   Write mixed-layer diagnostics restart fields.
39      !!--------------------------------------------------------------------------------
40      INTEGER, INTENT( in ) ::   kt   ! ocean time-step index
41      !
42      CHARACTER (len=35) :: charout
43      INTEGER ::   jk                 ! loop indice
44      CHARACTER(LEN=20)   ::   clkt     ! ocean time-step deine as a character
45      CHARACTER(LEN=50)   ::   clname   ! ice output restart file name
46      !!--------------------------------------------------------------------------------
47
48      ! to get better performances with NetCDF format:
49      ! we open and define the ocean restart_mld file one time step before writing the data (-> at nitrst - 1)
50      ! except if we write ocean restart_mld files every time step or if an ocean restart_mld file was writen at nitend - 1
51      IF( kt == nitrst - 1 .OR. nstock == 1 .OR. ( kt == nitend .AND. MOD( nitend - 1, nstock ) == 0 ) ) THEN
52         ! beware of the format used to write kt (default is i8.8, that should be large enough...)
53         IF( nitrst > 999999999 ) THEN   ;   WRITE(clkt, *       ) nitrst
54         ELSE                            ;   WRITE(clkt, '(i8.8)') nitrst
55         ENDIF
56         ! create the file
57         clname = TRIM(cexper)//"_"//TRIM(ADJUSTL(clkt))//"_restart_mld"
58         IF(lwp) THEN
59            WRITE(numout,*)
60            SELECT CASE ( jprstlib )
61            CASE ( jprstdimg )   ;   WRITE(numout,*) '             open ocean restart_mld binary file: '//clname
62            CASE DEFAULT         ;   WRITE(numout,*) '             open ocean restart_mld NetCDF file: '//clname
63            END SELECT
64            IF( kt == nitrst - 1 ) THEN   ;   WRITE(numout,*) '             kt = nitrst - 1 = ', kt,' date= ', ndastp
65            ELSE                          ;   WRITE(numout,*) '             kt = '             , kt,' date= ', ndastp
66            ENDIF
67         ENDIF
68
69         CALL iom_open( clname, nummldw, ldwrt = .TRUE., kiolib = jprstlib )
70      ENDIF
71
72      IF( kt == nitrst .AND. lwp ) THEN
73         WRITE(numout,*)
74         WRITE(numout,*) 'trdmld_rst: output for ML diags. restart, with trd_mld_rst_write routine kt =', kt
75         WRITE(numout,*) '~~~~~~~~~~'
76         WRITE(numout,*)
77      ENDIF
78
79      IF( ln_trdmld_instant ) THEN 
80         !-- Temperature
81         CALL iom_rstput( kt, nitrst, nummldw, 'tmlbb'           , tmlbb           )
82         CALL iom_rstput( kt, nitrst, nummldw, 'tmlbn'           , tmlbn           )
83         CALL iom_rstput( kt, nitrst, nummldw, 'tmlatfb'         , tmlatfb         )
84
85         !-- Salinity
86         CALL iom_rstput( kt, nitrst, nummldw, 'smlbb'           , smlbb           )
87         CALL iom_rstput( kt, nitrst, nummldw, 'smlbn'           , smlbn           )
88         CALL iom_rstput( kt, nitrst, nummldw, 'smlatfb'         , smlatfb         )
89      ELSE
90         CALL iom_rstput( kt, nitrst, nummldw, 'rmldbn'          , rmldbn          )
91
92         !-- Temperature
93         CALL iom_rstput( kt, nitrst, nummldw, 'tmlbn'           , tmlbn           )
94         CALL iom_rstput( kt, nitrst, nummldw, 'tml_sumb'        , tml_sumb        )
95         DO jk = 1, jpltrd
96            IF( jk < 10 ) THEN   ;   WRITE(charout,FMT="('tmltrd_csum_ub_', I1)") jk
97            ELSE                 ;   WRITE(charout,FMT="('tmltrd_csum_ub_', I2)") jk
98            ENDIF
99            CALL iom_rstput( kt, nitrst, nummldw, charout,  tmltrd_csum_ub(:,:,jk) )
100         ENDDO
101         CALL iom_rstput( kt, nitrst, nummldw, 'tmltrd_atf_sumb' , tmltrd_atf_sumb )
102
103         !-- Salinity
104         CALL iom_rstput( kt, nitrst, nummldw, 'smlbn'           , smlbn           )
105         CALL iom_rstput( kt, nitrst, nummldw, 'sml_sumb'        , sml_sumb        )
106         DO jk = 1, jpltrd
107            IF( jk < 10 ) THEN   ;   WRITE(charout,FMT="('smltrd_csum_ub_', I1)") jk
108            ELSE                 ;   WRITE(charout,FMT="('smltrd_csum_ub_', I2)") jk
109            ENDIF
110            CALL iom_rstput( kt, nitrst, nummldw, charout , smltrd_csum_ub(:,:,jk) )
111         ENDDO
112         CALL iom_rstput( kt, nitrst, nummldw, 'smltrd_atf_sumb' , smltrd_atf_sumb )
113      ENDIF
114      !
115      IF( kt == nitrst ) THEN
116         CALL iom_close( nummldw )     ! close the restart file (only at last time step)
117         lrst_oce = .FALSE.
118      ENDIF
119      !
120      !   
121   END SUBROUTINE trd_mld_rst_write
122
123
124   SUBROUTINE trd_mld_rst_read
125    !!----------------------------------------------------------------------------
126    !!                   ***  SUBROUTINE trd_mld_rst_lec  ***
127    !!                   
128    !! ** Purpose :   Read file for mixed-layer diagnostics restart.
129    !!----------------------------------------------------------------------------
130    INTEGER  ::  inum       ! temporary logical unit
131    !
132    CHARACTER (len=35) :: charout
133    INTEGER ::   jk         ! loop indice
134    !!-----------------------------------------------------------------------------
135
136    IF(lwp)  THEN
137       WRITE(numout,*)
138       WRITE(numout,*) ' trd_mld_rst_read : read the NetCDF MLD restart file'
139       WRITE(numout,*) ' ~~~~~~~~~~~~~~~~'
140    ENDIF
141
142    CALL iom_open( 'restart_mld', inum, kiolib = jprstlib ) 
143
144    IF( ln_trdmld_instant ) THEN 
145       !-- Temperature
146       CALL iom_get( inum, jpdom_autoglo, 'tmlbb'           , tmlbb          )
147       CALL iom_get( inum, jpdom_autoglo, 'tmlbn'           , tmlbn          )
148       CALL iom_get( inum, jpdom_autoglo, 'tmlatfb'         , tmlatfb        )
149
150       !-- Salinity
151       CALL iom_get( inum, jpdom_autoglo, 'smlbb'           , smlbb          )
152       CALL iom_get( inum, jpdom_autoglo, 'smlbn'           , smlbn          )
153       CALL iom_get( inum, jpdom_autoglo, 'smlatfb'         , smlatfb        )
154    ELSE
155       CALL iom_get( inum, jpdom_autoglo, 'rmldbn'          , rmldbn         ) ! needed for rmld_sum
156
157       !-- Temperature
158       CALL iom_get( inum, jpdom_autoglo, 'tmlbn'           , tmlbn          ) ! needed for tml_sum
159       CALL iom_get( inum, jpdom_autoglo, 'tml_sumb'        , tml_sumb       )
160       DO jk = 1, jpltrd
161          IF( jk < 10 )   THEN
162             WRITE(charout,FMT="('tmltrd_csum_ub_', I1)") jk
163          ELSE
164             WRITE(charout,FMT="('tmltrd_csum_ub_', I2)") jk
165          ENDIF
166          CALL iom_get( inum, jpdom_autoglo, charout, tmltrd_csum_ub(:,:,jk) )
167       ENDDO
168       CALL iom_get( inum, jpdom_autoglo, 'tmltrd_atf_sumb' , tmltrd_atf_sumb)
169
170       !-- Salinity
171       CALL iom_get( inum, jpdom_autoglo, 'smlbn'           , smlbn          ) ! needed for sml_sum
172       CALL iom_get( inum, jpdom_autoglo, 'sml_sumb'        , sml_sumb       )
173       DO jk = 1, jpltrd
174          IF( jk < 10 )   THEN
175             WRITE(charout,FMT="('smltrd_csum_ub_', I1)") jk
176          ELSE
177             WRITE(charout,FMT="('smltrd_csum_ub_', I2)") jk
178          ENDIF
179          CALL iom_get( inum, jpdom_autoglo, charout, smltrd_csum_ub(:,:,jk) )
180       ENDDO
181       CALL iom_get( inum, jpdom_autoglo, 'smltrd_atf_sumb' , smltrd_atf_sumb)
182
183       CALL iom_close( inum )
184    ENDIF
185
186  END SUBROUTINE trd_mld_rst_read
187 
188#else
189  !!=================================================================================
190  !!                       ***  MODULE  trdmld_rst  ***
191  !! Ocean dynamic :  Input/Output files for restart on mixed-layer diagnostics
192  !!=================================================================================
193CONTAINS
194  SUBROUTINE trd_mld_rst_write( kt )           !  No ML diags ==> empty routine
195    WRITE(*,*) 'trd_mld_rst_wri: You should not have seen this print! error?', kt
196  END SUBROUTINE trd_mld_rst_write
197  SUBROUTINE trd_mld_rst_read                  !  No ML Diags ==> empty routine
198  END SUBROUTINE trd_mld_rst_read
199#endif
200
201  !!=================================================================================
202END MODULE trdmld_rst
Note: See TracBrowser for help on using the repository browser.