[4619] | 1 | MODULE 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 |
---|
[10302] | 18 | USE timing |
---|
[4619] | 19 | |
---|
| 20 | IMPLICIT NONE |
---|
| 21 | PRIVATE |
---|
| 22 | |
---|
| 23 | PUBLIC trd_mxl_rst_read ! routine called by trd_mxl_init |
---|
| 24 | PUBLIC trd_mxl_rst_write ! routine called by step.F90 |
---|
| 25 | |
---|
| 26 | INTEGER :: nummxlw ! logical unit for mxl restart |
---|
| 27 | |
---|
| 28 | !!--------------------------------------------------------------------------------- |
---|
| 29 | !! NEMO/OPA 3.3 , NEMO Consortium (2010) |
---|
[5341] | 30 | !! $Id$ |
---|
[4619] | 31 | !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) |
---|
| 32 | !!--------------------------------------------------------------------------------- |
---|
| 33 | CONTAINS |
---|
| 34 | |
---|
| 35 | SUBROUTINE trd_mxl_rst_write( kt ) |
---|
| 36 | !!-------------------------------------------------------------------------------- |
---|
| 37 | !! *** SUBROUTINE trd_mxl_rst_wri *** |
---|
| 38 | !! |
---|
| 39 | !! ** Purpose : Write mixed-layer diagnostics restart fields. |
---|
| 40 | !!-------------------------------------------------------------------------------- |
---|
| 41 | INTEGER, INTENT( in ) :: kt ! ocean time-step index |
---|
| 42 | ! |
---|
| 43 | CHARACTER (len=35) :: charout |
---|
| 44 | INTEGER :: jk ! loop indice |
---|
| 45 | CHARACTER(LEN=20) :: clkt ! ocean time-step deine as a character |
---|
[5341] | 46 | CHARACTER(LEN=50) :: clname ! output restart file name |
---|
| 47 | CHARACTER(LEN=256) :: clpath ! full path to restart file |
---|
[4619] | 48 | !!-------------------------------------------------------------------------------- |
---|
| 49 | |
---|
| 50 | ! to get better performances with NetCDF format: |
---|
| 51 | ! we open and define the ocean restart_mxl file one time step before writing the data (-> at nitrst - 1) |
---|
| 52 | ! except if we write ocean restart_mxl files every time step or if an ocean restart_mxl file was writen at nitend - 1 |
---|
| 53 | IF( kt == nitrst - 1 .OR. nstock == 1 .OR. ( kt == nitend .AND. MOD( nitend - 1, nstock ) == 0 ) ) THEN |
---|
| 54 | ! beware of the format used to write kt (default is i8.8, that should be large enough...) |
---|
| 55 | IF( nitrst > 999999999 ) THEN ; WRITE(clkt, * ) nitrst |
---|
| 56 | ELSE ; WRITE(clkt, '(i8.8)') nitrst |
---|
| 57 | ENDIF |
---|
| 58 | ! create the file |
---|
| 59 | clname = TRIM(cexper)//"_"//TRIM(ADJUSTL(clkt))//"_"//TRIM(cn_trdrst_out) |
---|
[5341] | 60 | clpath = TRIM(cn_ocerst_outdir) |
---|
| 61 | IF( clpath(LEN_TRIM(clpath):) /= '/' ) clpath = TRIM(clpath) // '/' |
---|
[4619] | 62 | IF(lwp) THEN |
---|
| 63 | WRITE(numout,*) |
---|
| 64 | SELECT CASE ( jprstlib ) |
---|
| 65 | CASE ( jprstdimg ) ; WRITE(numout,*) ' open ocean restart_mxl binary file: '//clname |
---|
| 66 | CASE DEFAULT ; WRITE(numout,*) ' open ocean restart_mxl NetCDF file: '//clname |
---|
| 67 | END SELECT |
---|
| 68 | IF( kt == nitrst - 1 ) THEN ; WRITE(numout,*) ' kt = nitrst - 1 = ', kt,' date= ', ndastp |
---|
| 69 | ELSE ; WRITE(numout,*) ' kt = ' , kt,' date= ', ndastp |
---|
| 70 | ENDIF |
---|
| 71 | ENDIF |
---|
| 72 | |
---|
[5341] | 73 | CALL iom_open( TRIM(clpath)//TRIM(clname), nummxlw, ldwrt = .TRUE., kiolib = jprstlib ) |
---|
[4619] | 74 | ENDIF |
---|
| 75 | |
---|
| 76 | IF( kt == nitrst .AND. lwp ) THEN |
---|
| 77 | WRITE(numout,*) |
---|
| 78 | WRITE(numout,*) 'trdmxl_rst: output for ML diags. restart, with trd_mxl_rst_write routine kt =', kt |
---|
| 79 | WRITE(numout,*) '~~~~~~~~~~' |
---|
| 80 | WRITE(numout,*) |
---|
| 81 | ENDIF |
---|
[10302] | 82 | IF(nn_timing == 2) CALL timing_start('iom_rstput') |
---|
[4619] | 83 | IF( ln_trdmxl_instant ) THEN |
---|
| 84 | !-- Temperature |
---|
| 85 | CALL iom_rstput( kt, nitrst, nummxlw, 'tmlbb' , tmlbb ) |
---|
| 86 | CALL iom_rstput( kt, nitrst, nummxlw, 'tmlbn' , tmlbn ) |
---|
| 87 | CALL iom_rstput( kt, nitrst, nummxlw, 'tmlatfb' , tmlatfb ) |
---|
| 88 | |
---|
| 89 | !-- Salinity |
---|
| 90 | CALL iom_rstput( kt, nitrst, nummxlw, 'smlbb' , smlbb ) |
---|
| 91 | CALL iom_rstput( kt, nitrst, nummxlw, 'smlbn' , smlbn ) |
---|
| 92 | CALL iom_rstput( kt, nitrst, nummxlw, 'smlatfb' , smlatfb ) |
---|
| 93 | ELSE |
---|
| 94 | CALL iom_rstput( kt, nitrst, nummxlw, 'hmxlbn' , hmxlbn ) |
---|
| 95 | |
---|
| 96 | !-- Temperature |
---|
| 97 | CALL iom_rstput( kt, nitrst, nummxlw, 'tmlbn' , tmlbn ) |
---|
| 98 | CALL iom_rstput( kt, nitrst, nummxlw, 'tml_sumb' , tml_sumb ) |
---|
| 99 | DO jk = 1, jpltrd |
---|
| 100 | IF( jk < 10 ) THEN ; WRITE(charout,FMT="('tmltrd_csum_ub_', I1)") jk |
---|
| 101 | ELSE ; WRITE(charout,FMT="('tmltrd_csum_ub_', I2)") jk |
---|
| 102 | ENDIF |
---|
| 103 | CALL iom_rstput( kt, nitrst, nummxlw, charout, tmltrd_csum_ub(:,:,jk) ) |
---|
| 104 | ENDDO |
---|
| 105 | CALL iom_rstput( kt, nitrst, nummxlw, 'tmltrd_atf_sumb' , tmltrd_atf_sumb ) |
---|
| 106 | |
---|
| 107 | !-- Salinity |
---|
| 108 | CALL iom_rstput( kt, nitrst, nummxlw, 'smlbn' , smlbn ) |
---|
| 109 | CALL iom_rstput( kt, nitrst, nummxlw, 'sml_sumb' , sml_sumb ) |
---|
| 110 | DO jk = 1, jpltrd |
---|
| 111 | IF( jk < 10 ) THEN ; WRITE(charout,FMT="('smltrd_csum_ub_', I1)") jk |
---|
| 112 | ELSE ; WRITE(charout,FMT="('smltrd_csum_ub_', I2)") jk |
---|
| 113 | ENDIF |
---|
| 114 | CALL iom_rstput( kt, nitrst, nummxlw, charout , smltrd_csum_ub(:,:,jk) ) |
---|
| 115 | ENDDO |
---|
| 116 | CALL iom_rstput( kt, nitrst, nummxlw, 'smltrd_atf_sumb' , smltrd_atf_sumb ) |
---|
| 117 | ENDIF |
---|
[10302] | 118 | IF(nn_timing == 2) CALL timing_stop('iom_rstput') |
---|
[4619] | 119 | ! |
---|
| 120 | IF( kt == nitrst ) THEN |
---|
| 121 | CALL iom_close( nummxlw ) ! close the restart file (only at last time step) |
---|
| 122 | lrst_oce = .FALSE. |
---|
| 123 | ENDIF |
---|
| 124 | ! |
---|
| 125 | END SUBROUTINE trd_mxl_rst_write |
---|
| 126 | |
---|
| 127 | |
---|
| 128 | SUBROUTINE trd_mxl_rst_read |
---|
| 129 | !!---------------------------------------------------------------------------- |
---|
| 130 | !! *** SUBROUTINE trd_mxl_rst_lec *** |
---|
| 131 | !! |
---|
| 132 | !! ** Purpose : Read file for mixed-layer diagnostics restart. |
---|
| 133 | !!---------------------------------------------------------------------------- |
---|
| 134 | INTEGER :: inum ! temporary logical unit |
---|
| 135 | ! |
---|
| 136 | CHARACTER (len=35) :: charout |
---|
| 137 | INTEGER :: jk ! loop indice |
---|
| 138 | INTEGER :: jlibalt = jprstlib |
---|
| 139 | LOGICAL :: llok |
---|
[5341] | 140 | CHARACTER(LEN=256) :: clpath ! full path to restart file |
---|
[4619] | 141 | !!----------------------------------------------------------------------------- |
---|
| 142 | |
---|
| 143 | IF(lwp) THEN |
---|
| 144 | WRITE(numout,*) |
---|
| 145 | WRITE(numout,*) ' trd_mxl_rst_read : read the NetCDF mixed layer trend restart file' |
---|
| 146 | WRITE(numout,*) ' ~~~~~~~~~~~~~~~~' |
---|
| 147 | ENDIF |
---|
[5341] | 148 | |
---|
| 149 | clpath = TRIM(cn_ocerst_indir) |
---|
| 150 | IF( clpath(LEN_TRIM(clpath):) /= '/' ) clpath = TRIM(clpath) // '/' |
---|
| 151 | |
---|
[4619] | 152 | IF ( jprstlib == jprstdimg ) THEN |
---|
| 153 | ! eventually read netcdf file (monobloc) for restarting on different number of processors |
---|
| 154 | ! if {cn_trdrst_in}.nc exists, then set jlibalt to jpnf90 |
---|
[5341] | 155 | INQUIRE( FILE = TRIM(clpath)//TRIM(cn_trdrst_in)//'.nc', EXIST = llok ) |
---|
[4619] | 156 | IF ( llok ) THEN ; jlibalt = jpnf90 |
---|
| 157 | ELSE ; jlibalt = jprstlib |
---|
| 158 | ENDIF |
---|
| 159 | ENDIF |
---|
| 160 | |
---|
[5341] | 161 | CALL iom_open( TRIM(clpath)//TRIM(cn_trdrst_in), inum, kiolib = jlibalt ) |
---|
[10302] | 162 | IF(nn_timing == 2) CALL timing_start('iom_rstget') |
---|
[4619] | 163 | IF( ln_trdmxl_instant ) THEN |
---|
| 164 | !-- Temperature |
---|
| 165 | CALL iom_get( inum, jpdom_autoglo, 'tmlbb' , tmlbb ) |
---|
| 166 | CALL iom_get( inum, jpdom_autoglo, 'tmlbn' , tmlbn ) |
---|
| 167 | CALL iom_get( inum, jpdom_autoglo, 'tmlatfb' , tmlatfb ) |
---|
| 168 | ! |
---|
| 169 | !-- Salinity |
---|
| 170 | CALL iom_get( inum, jpdom_autoglo, 'smlbb' , smlbb ) |
---|
| 171 | CALL iom_get( inum, jpdom_autoglo, 'smlbn' , smlbn ) |
---|
| 172 | CALL iom_get( inum, jpdom_autoglo, 'smlatfb' , smlatfb ) |
---|
| 173 | ELSE |
---|
| 174 | CALL iom_get( inum, jpdom_autoglo, 'hmxlbn' , hmxlbn ) ! needed for hmxl_sum |
---|
| 175 | ! |
---|
| 176 | !-- Temperature |
---|
| 177 | CALL iom_get( inum, jpdom_autoglo, 'tmlbn' , tmlbn ) ! needed for tml_sum |
---|
| 178 | CALL iom_get( inum, jpdom_autoglo, 'tml_sumb' , tml_sumb ) |
---|
| 179 | DO jk = 1, jpltrd |
---|
| 180 | IF( jk < 10 ) THEN ; WRITE(charout,FMT="('tmltrd_csum_ub_', I1)") jk |
---|
| 181 | ELSE ; WRITE(charout,FMT="('tmltrd_csum_ub_', I2)") jk |
---|
| 182 | ENDIF |
---|
| 183 | CALL iom_get( inum, jpdom_autoglo, charout, tmltrd_csum_ub(:,:,jk) ) |
---|
| 184 | END DO |
---|
| 185 | CALL iom_get( inum, jpdom_autoglo, 'tmltrd_atf_sumb' , tmltrd_atf_sumb) |
---|
| 186 | ! |
---|
| 187 | !-- Salinity |
---|
| 188 | CALL iom_get( inum, jpdom_autoglo, 'smlbn' , smlbn ) ! needed for sml_sum |
---|
| 189 | CALL iom_get( inum, jpdom_autoglo, 'sml_sumb' , sml_sumb ) |
---|
| 190 | DO jk = 1, jpltrd |
---|
| 191 | IF( jk < 10 ) THEN ; WRITE(charout,FMT="('smltrd_csum_ub_', I1)") jk |
---|
| 192 | ELSE ; WRITE(charout,FMT="('smltrd_csum_ub_', I2)") jk |
---|
| 193 | ENDIF |
---|
| 194 | CALL iom_get( inum, jpdom_autoglo, charout, smltrd_csum_ub(:,:,jk) ) |
---|
| 195 | END DO |
---|
| 196 | CALL iom_get( inum, jpdom_autoglo, 'smltrd_atf_sumb' , smltrd_atf_sumb) |
---|
| 197 | ! |
---|
| 198 | ENDIF |
---|
[10302] | 199 | IF(nn_timing == 2) CALL timing_stop('iom_rstget') |
---|
| 200 | CALL iom_close( inum ) |
---|
[4619] | 201 | ! |
---|
| 202 | END SUBROUTINE trd_mxl_rst_read |
---|
| 203 | |
---|
| 204 | !!================================================================================= |
---|
| 205 | END MODULE trdmxl_rst |
---|