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

source: trunk/NEMOGCM/NEMO/OPA_SRC/TRD/trdmxl_rst.F90 @ 6140

Last change on this file since 6140 was 6140, checked in by timgraham, 8 years ago

Merge of branches/2015/dev_merge_2015 back into trunk. Merge excludes NEMOGCM/TOOLS/OBSTOOLS/ for now due to issues with the change of file type. Will sort these manually with further commits.

Branch merged as follows:
In the working copy of branch ran:
svn merge svn+ssh://forge.ipsl.jussieu.fr/ipsl/forge/projets/nemo/svn/trunk@HEAD
Small conflicts due to bug fixes applied to trunk since the dev_merge_2015 was copied. Bug fixes were applied to the branch as well so these were easy to resolve.
Branch committed at this stage

In working copy run:
svn switch svn+ssh://forge.ipsl.jussieu.fr/ipsl/forge/projets/nemo/svn/trunk
to switch working copy

Run:
svn merge --reintegrate svn+ssh://forge.ipsl.jussieu.fr/ipsl/forge/projets/nemo/svn/branches/2015/dev_merge_2015
to merge the branch into the trunk and then commit - no conflicts at this stage.

  • Property svn:keywords set to Id
File size: 9.2 KB
Line 
1MODULE trdmxl_rst
2   !!=================================================================================
3   !!                       ***  MODULE  trdmxl_rst  ***
4   !! Ocean dynamic :  Input/Output files for restart on mixed-layer diagnostics
5   !!=================================================================================
6   !! History :  1.0  ! 2005-05 (C. Deltel)  Original code
7   !!---------------------------------------------------------------------------------
8
9   !!---------------------------------------------------------------------------------
10   !!  trd_mxl_rst_write : write mixed layer trend restart
11   !!  trd_mxl_rst_read  : read  mixed layer trend restart
12   !!---------------------------------------------------------------------------------
13   USE dom_oce         ! ocean space and time domain
14   USE trd_oce         ! trends: ocean variables
15   USE in_out_manager  ! I/O manager
16   USE iom             ! I/O module
17   USE restart         ! only for lrst_oce
18
19   IMPLICIT NONE
20   PRIVATE
21 
22   PUBLIC   trd_mxl_rst_read    ! routine called by trd_mxl_init
23   PUBLIC   trd_mxl_rst_write   ! routine called by step.F90
24 
25   INTEGER ::   nummxlw         ! logical unit for mxl restart
26
27   !!---------------------------------------------------------------------------------
28   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
29   !! $Id$
30   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
31   !!---------------------------------------------------------------------------------
32CONTAINS
33 
34   SUBROUTINE trd_mxl_rst_write( kt )
35      !!--------------------------------------------------------------------------------
36      !!                  ***  SUBROUTINE trd_mxl_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   ! output restart file name
46      CHARACTER(LEN=256)  ::   clpath   ! full path to restart file
47      !!--------------------------------------------------------------------------------
48
49      ! to get better performances with NetCDF format:
50      ! we open and define the ocean restart_mxl file one time step before writing the data (-> at nitrst - 1)
51      ! except if we write ocean restart_mxl files every time step or if an ocean restart_mxl file was writen at nitend - 1
52      IF( kt == nitrst - 1 .OR. nstock == 1 .OR. ( kt == nitend .AND. MOD( nitend - 1, nstock ) == 0 ) ) THEN
53         ! beware of the format used to write kt (default is i8.8, that should be large enough...)
54         IF( nitrst > 999999999 ) THEN   ;   WRITE(clkt, *       ) nitrst
55         ELSE                            ;   WRITE(clkt, '(i8.8)') nitrst
56         ENDIF
57         ! create the file
58         clname = TRIM(cexper)//"_"//TRIM(ADJUSTL(clkt))//"_"//TRIM(cn_trdrst_out)
59         clpath = TRIM(cn_ocerst_outdir)
60         IF( clpath(LEN_TRIM(clpath):) /= '/' ) clpath = TRIM(clpath) // '/'
61         IF(lwp) THEN
62            WRITE(numout,*)
63            SELECT CASE ( jprstlib )
64            CASE DEFAULT         ;   WRITE(numout,*) '             open ocean restart_mxl NetCDF file: '//clname
65            END SELECT
66            IF( kt == nitrst - 1 ) THEN   ;   WRITE(numout,*) '             kt = nitrst - 1 = ', kt,' date= ', ndastp
67            ELSE                          ;   WRITE(numout,*) '             kt = '             , kt,' date= ', ndastp
68            ENDIF
69         ENDIF
70
71         CALL iom_open( TRIM(clpath)//TRIM(clname), nummxlw, ldwrt = .TRUE., kiolib = jprstlib )
72      ENDIF
73
74      IF( kt == nitrst .AND. lwp ) THEN
75         WRITE(numout,*)
76         WRITE(numout,*) 'trdmxl_rst: output for ML diags. restart, with trd_mxl_rst_write routine kt =', kt
77         WRITE(numout,*) '~~~~~~~~~~'
78         WRITE(numout,*)
79      ENDIF
80
81      IF( ln_trdmxl_instant ) THEN 
82         !-- Temperature
83         CALL iom_rstput( kt, nitrst, nummxlw, 'tmlbb'           , tmlbb           )
84         CALL iom_rstput( kt, nitrst, nummxlw, 'tmlbn'           , tmlbn           )
85         CALL iom_rstput( kt, nitrst, nummxlw, 'tmlatfb'         , tmlatfb         )
86
87         !-- Salinity
88         CALL iom_rstput( kt, nitrst, nummxlw, 'smlbb'           , smlbb           )
89         CALL iom_rstput( kt, nitrst, nummxlw, 'smlbn'           , smlbn           )
90         CALL iom_rstput( kt, nitrst, nummxlw, 'smlatfb'         , smlatfb         )
91      ELSE
92         CALL iom_rstput( kt, nitrst, nummxlw, 'hmxlbn'          , hmxlbn          )
93
94         !-- Temperature
95         CALL iom_rstput( kt, nitrst, nummxlw, 'tmlbn'           , tmlbn           )
96         CALL iom_rstput( kt, nitrst, nummxlw, 'tml_sumb'        , tml_sumb        )
97         DO jk = 1, jpltrd
98            IF( jk < 10 ) THEN   ;   WRITE(charout,FMT="('tmltrd_csum_ub_', I1)")   jk
99            ELSE                 ;   WRITE(charout,FMT="('tmltrd_csum_ub_', I2)")   jk
100            ENDIF
101            CALL iom_rstput( kt, nitrst, nummxlw, charout,  tmltrd_csum_ub(:,:,jk) )
102         ENDDO
103         CALL iom_rstput( kt, nitrst, nummxlw, 'tmltrd_atf_sumb' , tmltrd_atf_sumb )
104
105         !-- Salinity
106         CALL iom_rstput( kt, nitrst, nummxlw, 'smlbn'           , smlbn           )
107         CALL iom_rstput( kt, nitrst, nummxlw, 'sml_sumb'        , sml_sumb        )
108         DO jk = 1, jpltrd
109            IF( jk < 10 ) THEN   ;   WRITE(charout,FMT="('smltrd_csum_ub_', I1)")   jk
110            ELSE                 ;   WRITE(charout,FMT="('smltrd_csum_ub_', I2)")   jk
111            ENDIF
112            CALL iom_rstput( kt, nitrst, nummxlw, charout , smltrd_csum_ub(:,:,jk) )
113         ENDDO
114         CALL iom_rstput( kt, nitrst, nummxlw, 'smltrd_atf_sumb' , smltrd_atf_sumb )
115      ENDIF
116      !
117      IF( kt == nitrst ) THEN
118         CALL iom_close( nummxlw )     ! close the restart file (only at last time step)
119         lrst_oce = .FALSE.
120      ENDIF
121      !
122   END SUBROUTINE trd_mxl_rst_write
123
124
125   SUBROUTINE trd_mxl_rst_read
126      !!----------------------------------------------------------------------------
127      !!                   ***  SUBROUTINE trd_mxl_rst_lec  ***
128      !!                   
129      !! ** Purpose :   Read file for mixed-layer diagnostics restart.
130      !!----------------------------------------------------------------------------
131      INTEGER  ::  inum       ! temporary logical unit
132      !
133      CHARACTER (len=35) :: charout
134      INTEGER ::   jk         ! loop indice
135      INTEGER ::   jlibalt = jprstlib
136      LOGICAL ::   llok
137      CHARACTER(LEN=256)  ::   clpath   ! full path to restart file
138      !!-----------------------------------------------------------------------------
139
140      IF(lwp)  THEN
141         WRITE(numout,*)
142         WRITE(numout,*) ' trd_mxl_rst_read : read the NetCDF mixed layer trend restart file'
143         WRITE(numout,*) ' ~~~~~~~~~~~~~~~~'
144      ENDIF
145
146      clpath = TRIM(cn_ocerst_indir)
147      IF( clpath(LEN_TRIM(clpath):) /= '/' ) clpath = TRIM(clpath) // '/'
148      CALL iom_open( TRIM(clpath)//TRIM(cn_trdrst_in), inum, kiolib = jlibalt ) 
149
150      IF( ln_trdmxl_instant ) THEN 
151         !-- Temperature
152         CALL iom_get( inum, jpdom_autoglo, 'tmlbb'           , tmlbb          )
153         CALL iom_get( inum, jpdom_autoglo, 'tmlbn'           , tmlbn          )
154         CALL iom_get( inum, jpdom_autoglo, 'tmlatfb'         , tmlatfb        )
155         !
156         !-- Salinity
157         CALL iom_get( inum, jpdom_autoglo, 'smlbb'           , smlbb          )
158         CALL iom_get( inum, jpdom_autoglo, 'smlbn'           , smlbn          )
159         CALL iom_get( inum, jpdom_autoglo, 'smlatfb'         , smlatfb        )
160      ELSE
161         CALL iom_get( inum, jpdom_autoglo, 'hmxlbn'          , hmxlbn         ) ! needed for hmxl_sum
162         !
163         !-- Temperature
164         CALL iom_get( inum, jpdom_autoglo, 'tmlbn'           , tmlbn          ) ! needed for tml_sum
165         CALL iom_get( inum, jpdom_autoglo, 'tml_sumb'        , tml_sumb       )
166         DO jk = 1, jpltrd
167            IF( jk < 10 ) THEN   ;   WRITE(charout,FMT="('tmltrd_csum_ub_', I1)")   jk
168            ELSE                 ;   WRITE(charout,FMT="('tmltrd_csum_ub_', I2)")   jk
169            ENDIF
170            CALL iom_get( inum, jpdom_autoglo, charout, tmltrd_csum_ub(:,:,jk) )
171         END DO
172         CALL iom_get( inum, jpdom_autoglo, 'tmltrd_atf_sumb' , tmltrd_atf_sumb)
173         !
174         !-- Salinity
175         CALL iom_get( inum, jpdom_autoglo, 'smlbn'           , smlbn          ) ! needed for sml_sum
176         CALL iom_get( inum, jpdom_autoglo, 'sml_sumb'        , sml_sumb       )
177         DO jk = 1, jpltrd
178            IF( jk < 10 ) THEN   ;   WRITE(charout,FMT="('smltrd_csum_ub_', I1)")   jk
179            ELSE                 ;   WRITE(charout,FMT="('smltrd_csum_ub_', I2)")   jk
180            ENDIF
181            CALL iom_get( inum, jpdom_autoglo, charout, smltrd_csum_ub(:,:,jk) )
182         END DO
183         CALL iom_get( inum, jpdom_autoglo, 'smltrd_atf_sumb' , smltrd_atf_sumb)
184         !
185         CALL iom_close( inum )
186      ENDIF
187      !
188   END SUBROUTINE trd_mxl_rst_read
189 
190  !!=================================================================================
191END MODULE trdmxl_rst
Note: See TracBrowser for help on using the repository browser.