[8413] | 1 | MODULE icerst |
---|
| 2 | !!====================================================================== |
---|
| 3 | !! *** MODULE icerst *** |
---|
[8534] | 4 | !! sea-ice : write/read the ice restart file |
---|
[8413] | 5 | !!====================================================================== |
---|
[8486] | 6 | !! History: 3.0 ! 2005-04 (M. Vancoppenolle) Original code |
---|
| 7 | !! - ! 2008-03 (C. Ethe) restart files in using IOM interface |
---|
| 8 | !! 4.0 ! 2011-02 (G. Madec) dynamical allocation |
---|
[8413] | 9 | !!---------------------------------------------------------------------- |
---|
| 10 | #if defined key_lim3 |
---|
| 11 | !!---------------------------------------------------------------------- |
---|
[8534] | 12 | !! 'key_lim3' ESIM sea-ice model |
---|
[8413] | 13 | !!---------------------------------------------------------------------- |
---|
[8534] | 14 | !! ice_rst_opn : open restart file |
---|
| 15 | !! ice_rst_write : write restart file |
---|
| 16 | !! ice_rst_read : read restart file |
---|
[8413] | 17 | !!---------------------------------------------------------------------- |
---|
| 18 | USE ice ! sea-ice variables |
---|
| 19 | USE dom_oce ! ocean domain |
---|
| 20 | USE sbc_oce , ONLY : nn_fsbc |
---|
| 21 | USE icectl |
---|
| 22 | ! |
---|
| 23 | USE in_out_manager ! I/O manager |
---|
[8534] | 24 | USE iom ! I/O manager library |
---|
[8413] | 25 | USE lib_mpp ! MPP library |
---|
[8534] | 26 | USE lib_fortran ! fortran utilities (glob_sum + no signed zero) |
---|
[8413] | 27 | |
---|
| 28 | IMPLICIT NONE |
---|
| 29 | PRIVATE |
---|
| 30 | |
---|
[8518] | 31 | PUBLIC ice_rst_opn ! called by icestp |
---|
| 32 | PUBLIC ice_rst_write ! called by icestp |
---|
| 33 | PUBLIC ice_rst_read ! called by ice_init |
---|
[8413] | 34 | |
---|
| 35 | !!---------------------------------------------------------------------- |
---|
[8486] | 36 | !! NEMO/ICE 4.0 , NEMO Consortium (2017) |
---|
[8413] | 37 | !! $Id: icerst.F90 8411 2017-08-07 16:09:12Z clem $ |
---|
| 38 | !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) |
---|
| 39 | !!---------------------------------------------------------------------- |
---|
| 40 | CONTAINS |
---|
| 41 | |
---|
| 42 | SUBROUTINE ice_rst_opn( kt ) |
---|
| 43 | !!---------------------------------------------------------------------- |
---|
| 44 | !! *** ice_rst_opn *** |
---|
| 45 | !! |
---|
[8534] | 46 | !! ** purpose : open restart file |
---|
[8413] | 47 | !!---------------------------------------------------------------------- |
---|
| 48 | INTEGER, INTENT(in) :: kt ! number of iteration |
---|
| 49 | ! |
---|
| 50 | CHARACTER(len=20) :: clkt ! ocean time-step define as a character |
---|
| 51 | CHARACTER(len=50) :: clname ! ice output restart file name |
---|
| 52 | CHARACTER(len=256) :: clpath ! full path to ice output restart file |
---|
| 53 | !!---------------------------------------------------------------------- |
---|
| 54 | ! |
---|
| 55 | IF( kt == nit000 ) lrst_ice = .FALSE. ! default definition |
---|
| 56 | |
---|
| 57 | ! in order to get better performances with NetCDF format, we open and define the ice restart file |
---|
| 58 | ! one ice time step before writing the data (-> at nitrst - 2*nn_fsbc + 1), except if we write ice |
---|
| 59 | ! restart files every ice time step or if an ice restart file was writen at nitend - 2*nn_fsbc + 1 |
---|
| 60 | IF( kt == nitrst - 2*nn_fsbc + 1 .OR. nstock == nn_fsbc & |
---|
| 61 | & .OR. ( kt == nitend - nn_fsbc + 1 .AND. .NOT. lrst_ice ) ) THEN |
---|
| 62 | IF( nitrst <= nitend .AND. nitrst > 0 ) THEN |
---|
| 63 | ! beware of the format used to write kt (default is i8.8, that should be large enough...) |
---|
| 64 | IF( nitrst > 99999999 ) THEN ; WRITE(clkt, * ) nitrst |
---|
| 65 | ELSE ; WRITE(clkt, '(i8.8)') nitrst |
---|
| 66 | ENDIF |
---|
| 67 | ! create the file |
---|
| 68 | clname = TRIM(cexper)//"_"//TRIM(ADJUSTL(clkt))//"_"//TRIM(cn_icerst_out) |
---|
| 69 | clpath = TRIM(cn_icerst_outdir) |
---|
| 70 | IF( clpath(LEN_TRIM(clpath):) /= '/' ) clpath = TRIM(clpath)//'/' |
---|
| 71 | IF(lwp) THEN |
---|
| 72 | WRITE(numout,*) |
---|
| 73 | SELECT CASE ( jprstlib ) |
---|
| 74 | CASE DEFAULT |
---|
| 75 | WRITE(numout,*) ' open ice restart NetCDF file: ',TRIM(clpath)//clname |
---|
| 76 | END SELECT |
---|
[8518] | 77 | IF( kt == nitrst - 2*nn_fsbc + 1 ) THEN |
---|
| 78 | WRITE(numout,*) ' kt = nitrst - 2*nn_fsbc + 1 = ', kt,' date= ', ndastp |
---|
| 79 | ELSE |
---|
| 80 | WRITE(numout,*) ' kt = ' , kt,' date= ', ndastp |
---|
[8413] | 81 | ENDIF |
---|
| 82 | ENDIF |
---|
| 83 | ! |
---|
| 84 | CALL iom_open( TRIM(clpath)//TRIM(clname), numriw, ldwrt = .TRUE., kiolib = jprstlib ) |
---|
| 85 | lrst_ice = .TRUE. |
---|
| 86 | ENDIF |
---|
| 87 | ENDIF |
---|
| 88 | ! |
---|
[8514] | 89 | IF( ln_icectl ) CALL ice_prt( kt, iiceprt, jiceprt, 1, ' - Beginning the time step - ' ) ! control print |
---|
[8413] | 90 | END SUBROUTINE ice_rst_opn |
---|
| 91 | |
---|
| 92 | |
---|
| 93 | SUBROUTINE ice_rst_write( kt ) |
---|
| 94 | !!---------------------------------------------------------------------- |
---|
| 95 | !! *** ice_rst_write *** |
---|
| 96 | !! |
---|
[8534] | 97 | !! ** purpose : write restart file |
---|
[8413] | 98 | !!---------------------------------------------------------------------- |
---|
| 99 | INTEGER, INTENT(in) :: kt ! number of iteration |
---|
| 100 | !! |
---|
[8518] | 101 | INTEGER :: jk ,jl ! dummy loop indices |
---|
[8413] | 102 | INTEGER :: iter |
---|
| 103 | CHARACTER(len=25) :: znam |
---|
| 104 | CHARACTER(len=2) :: zchar, zchar1 |
---|
| 105 | REAL(wp), DIMENSION(jpi,jpj) :: z2d |
---|
| 106 | !!---------------------------------------------------------------------- |
---|
| 107 | |
---|
| 108 | iter = kt + nn_fsbc - 1 ! ice restarts are written at kt == nitrst - nn_fsbc + 1 |
---|
| 109 | |
---|
| 110 | IF( iter == nitrst ) THEN |
---|
| 111 | IF(lwp) WRITE(numout,*) |
---|
| 112 | IF(lwp) WRITE(numout,*) 'ice_rst_write : write ice restart file kt =', kt |
---|
| 113 | IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~~' |
---|
| 114 | ENDIF |
---|
| 115 | |
---|
| 116 | ! Write in numriw (if iter == nitrst) |
---|
| 117 | ! ------------------ |
---|
| 118 | ! ! calendar control |
---|
| 119 | CALL iom_rstput( iter, nitrst, numriw, 'nn_fsbc', REAL( nn_fsbc, wp ) ) ! time-step |
---|
| 120 | CALL iom_rstput( iter, nitrst, numriw, 'kt_ice' , REAL( iter , wp ) ) ! date |
---|
| 121 | |
---|
[8486] | 122 | !!gm It is possible and easy to define a 3D domain size (jpi,jpj,jpl) or use a SIZE( tab, DIM=3) in iom_rtput ) |
---|
| 123 | !!gm ===>>> just a simple iom_rstput( iter, nitrst, numriw, 'v_i', v_i ) etc... |
---|
| 124 | !!gm "just" ask Sebatien |
---|
| 125 | |
---|
[8413] | 126 | ! Prognostic variables |
---|
| 127 | DO jl = 1, jpl |
---|
| 128 | WRITE(zchar,'(I2.2)') jl |
---|
| 129 | znam = 'v_i'//'_htc'//zchar |
---|
| 130 | z2d(:,:) = v_i(:,:,jl) |
---|
[8518] | 131 | CALL iom_rstput( iter, nitrst, numriw, znam , z2d ) ! v_i |
---|
[8413] | 132 | znam = 'v_s'//'_htc'//zchar |
---|
| 133 | z2d(:,:) = v_s(:,:,jl) |
---|
[8518] | 134 | CALL iom_rstput( iter, nitrst, numriw, znam , z2d ) ! v_s |
---|
[8413] | 135 | znam = 'smv_i'//'_htc'//zchar |
---|
| 136 | z2d(:,:) = smv_i(:,:,jl) |
---|
[8518] | 137 | CALL iom_rstput( iter, nitrst, numriw, znam , z2d ) ! smv_i |
---|
[8413] | 138 | znam = 'oa_i'//'_htc'//zchar |
---|
| 139 | z2d(:,:) = oa_i(:,:,jl) |
---|
[8518] | 140 | CALL iom_rstput( iter, nitrst, numriw, znam , z2d ) ! oa_i |
---|
[8413] | 141 | znam = 'a_i'//'_htc'//zchar |
---|
| 142 | z2d(:,:) = a_i(:,:,jl) |
---|
[8518] | 143 | CALL iom_rstput( iter, nitrst, numriw, znam , z2d ) ! a_i |
---|
[8413] | 144 | znam = 't_su'//'_htc'//zchar |
---|
| 145 | z2d(:,:) = t_su(:,:,jl) |
---|
[8518] | 146 | CALL iom_rstput( iter, nitrst, numriw, znam , z2d ) ! t_su |
---|
[8413] | 147 | END DO |
---|
| 148 | |
---|
| 149 | ! MV MP 2016 |
---|
| 150 | IF ( nn_pnd_scheme > 0 ) THEN |
---|
| 151 | DO jl = 1, jpl |
---|
| 152 | WRITE(zchar,'(I2.2)') jl |
---|
| 153 | znam = 'a_ip'//'_htc'//zchar |
---|
| 154 | z2d(:,:) = a_ip(:,:,jl) |
---|
[8518] | 155 | CALL iom_rstput( iter, nitrst, numriw, znam , z2d ) ! a_ip |
---|
[8413] | 156 | znam = 'v_ip'//'_htc'//zchar |
---|
| 157 | z2d(:,:) = v_ip(:,:,jl) |
---|
[8518] | 158 | CALL iom_rstput( iter, nitrst, numriw, znam , z2d ) ! v_ip |
---|
[8413] | 159 | END DO |
---|
| 160 | ENDIF |
---|
| 161 | ! END MV MP 2016 |
---|
| 162 | |
---|
| 163 | DO jl = 1, jpl |
---|
| 164 | WRITE(zchar,'(I2.2)') jl |
---|
| 165 | znam = 'tempt_sl1'//'_htc'//zchar |
---|
| 166 | z2d(:,:) = e_s(:,:,1,jl) |
---|
[8518] | 167 | CALL iom_rstput( iter, nitrst, numriw, znam , z2d ) ! e_s |
---|
[8413] | 168 | DO jk = 1, nlay_i |
---|
| 169 | WRITE(zchar1,'(I2.2)') jk |
---|
| 170 | znam = 'tempt'//'_il'//zchar1//'_htc'//zchar |
---|
| 171 | z2d(:,:) = e_i(:,:,jk,jl) |
---|
[8518] | 172 | CALL iom_rstput( iter, nitrst, numriw, znam , z2d ) ! e_i |
---|
[8413] | 173 | END DO |
---|
| 174 | END DO |
---|
| 175 | |
---|
[8518] | 176 | CALL iom_rstput( iter, nitrst, numriw, 'u_ice', u_ice ) ! u_ice |
---|
| 177 | CALL iom_rstput( iter, nitrst, numriw, 'v_ice', v_ice ) ! v_ice |
---|
[8413] | 178 | |
---|
| 179 | ! close restart file |
---|
| 180 | ! ------------------ |
---|
| 181 | IF( iter == nitrst ) THEN |
---|
| 182 | CALL iom_close( numriw ) |
---|
| 183 | lrst_ice = .FALSE. |
---|
| 184 | ENDIF |
---|
| 185 | ! |
---|
| 186 | END SUBROUTINE ice_rst_write |
---|
| 187 | |
---|
| 188 | |
---|
| 189 | SUBROUTINE ice_rst_read |
---|
| 190 | !!---------------------------------------------------------------------- |
---|
| 191 | !! *** ice_rst_read *** |
---|
| 192 | !! |
---|
[8534] | 193 | !! ** purpose : read restart file |
---|
[8413] | 194 | !!---------------------------------------------------------------------- |
---|
[8518] | 195 | INTEGER :: jk, jl |
---|
[8413] | 196 | REAL(wp) :: zfice, ziter |
---|
| 197 | REAL(wp), DIMENSION(jpi,jpj) :: z2d |
---|
| 198 | CHARACTER(len=25) :: znam |
---|
| 199 | CHARACTER(len=2) :: zchar, zchar1 |
---|
| 200 | INTEGER :: jlibalt = jprstlib |
---|
| 201 | LOGICAL :: llok |
---|
| 202 | !!---------------------------------------------------------------------- |
---|
| 203 | |
---|
| 204 | IF(lwp) THEN |
---|
| 205 | WRITE(numout,*) |
---|
[8518] | 206 | WRITE(numout,*) 'ice_rst_read: read ice NetCDF restart file' |
---|
| 207 | WRITE(numout,*) '~~~~~~~~~~~~' |
---|
[8413] | 208 | ENDIF |
---|
| 209 | |
---|
| 210 | CALL iom_open ( TRIM(cn_icerst_indir)//'/'//cn_icerst_in, numrir, kiolib = jprstlib ) |
---|
| 211 | |
---|
| 212 | CALL iom_get( numrir, 'nn_fsbc', zfice ) |
---|
| 213 | CALL iom_get( numrir, 'kt_ice' , ziter ) |
---|
| 214 | IF(lwp) WRITE(numout,*) ' read ice restart file at time step : ', ziter |
---|
| 215 | IF(lwp) WRITE(numout,*) ' in any case we force it to nit000 - 1 : ', nit000 - 1 |
---|
| 216 | |
---|
[8518] | 217 | ! Control of date |
---|
[8413] | 218 | IF( ( nit000 - NINT(ziter) ) /= 1 .AND. ABS( nrstdt ) == 1 ) & |
---|
| 219 | & CALL ctl_stop( 'ice_rst_read ===>>>> : problem with nit000 in ice restart', & |
---|
| 220 | & ' verify the file or rerun with the value 0 for the', & |
---|
| 221 | & ' control of time parameter nrstdt' ) |
---|
| 222 | IF( NINT(zfice) /= nn_fsbc .AND. ABS( nrstdt ) == 1 ) & |
---|
| 223 | & CALL ctl_stop( 'ice_rst_read ===>>>> : problem with nn_fsbc in ice restart', & |
---|
| 224 | & ' verify the file or rerun with the value 0 for the', & |
---|
| 225 | & ' control of time parameter nrstdt' ) |
---|
| 226 | |
---|
| 227 | ! Prognostic variables |
---|
| 228 | DO jl = 1, jpl |
---|
| 229 | WRITE(zchar,'(I2.2)') jl |
---|
| 230 | znam = 'v_i'//'_htc'//zchar |
---|
| 231 | CALL iom_get( numrir, jpdom_autoglo, znam , z2d ) |
---|
| 232 | v_i(:,:,jl) = z2d(:,:) |
---|
| 233 | znam = 'v_s'//'_htc'//zchar |
---|
| 234 | CALL iom_get( numrir, jpdom_autoglo, znam , z2d ) |
---|
| 235 | v_s(:,:,jl) = z2d(:,:) |
---|
| 236 | znam = 'smv_i'//'_htc'//zchar |
---|
| 237 | CALL iom_get( numrir, jpdom_autoglo, znam , z2d ) |
---|
| 238 | smv_i(:,:,jl) = z2d(:,:) |
---|
| 239 | znam = 'oa_i'//'_htc'//zchar |
---|
| 240 | CALL iom_get( numrir, jpdom_autoglo, znam , z2d ) |
---|
| 241 | oa_i(:,:,jl) = z2d(:,:) |
---|
| 242 | znam = 'a_i'//'_htc'//zchar |
---|
| 243 | CALL iom_get( numrir, jpdom_autoglo, znam , z2d ) |
---|
| 244 | a_i(:,:,jl) = z2d(:,:) |
---|
| 245 | znam = 't_su'//'_htc'//zchar |
---|
| 246 | CALL iom_get( numrir, jpdom_autoglo, znam , z2d ) |
---|
| 247 | t_su(:,:,jl) = z2d(:,:) |
---|
| 248 | END DO |
---|
| 249 | |
---|
| 250 | ! MV MP 2016 |
---|
| 251 | IF ( nn_pnd_scheme > 0 ) THEN |
---|
| 252 | DO jl = 1, jpl |
---|
| 253 | WRITE(zchar,'(I2.2)') jl |
---|
| 254 | znam = 'a_ip'//'_htc'//zchar |
---|
| 255 | CALL iom_get( numrir, jpdom_autoglo, znam , z2d ) |
---|
| 256 | a_ip(:,:,jl) = z2d(:,:) |
---|
| 257 | znam = 'v_ip'//'_htc'//zchar |
---|
| 258 | CALL iom_get( numrir, jpdom_autoglo, znam , z2d ) |
---|
| 259 | v_ip(:,:,jl) = z2d(:,:) |
---|
| 260 | END DO |
---|
| 261 | ENDIF |
---|
| 262 | ! END MV MP 2016 |
---|
| 263 | |
---|
| 264 | DO jl = 1, jpl |
---|
| 265 | WRITE(zchar,'(I2.2)') jl |
---|
| 266 | znam = 'tempt_sl1'//'_htc'//zchar |
---|
| 267 | CALL iom_get( numrir, jpdom_autoglo, znam , z2d ) |
---|
| 268 | e_s(:,:,1,jl) = z2d(:,:) |
---|
| 269 | DO jk = 1, nlay_i |
---|
| 270 | WRITE(zchar1,'(I2.2)') jk |
---|
| 271 | znam = 'tempt'//'_il'//zchar1//'_htc'//zchar |
---|
| 272 | CALL iom_get( numrir, jpdom_autoglo, znam , z2d ) |
---|
| 273 | e_i(:,:,jk,jl) = z2d(:,:) |
---|
| 274 | END DO |
---|
| 275 | END DO |
---|
| 276 | |
---|
[8518] | 277 | CALL iom_get( numrir, jpdom_autoglo, 'u_ice', u_ice ) |
---|
| 278 | CALL iom_get( numrir, jpdom_autoglo, 'v_ice', v_ice ) |
---|
[8413] | 279 | |
---|
| 280 | END SUBROUTINE ice_rst_read |
---|
| 281 | |
---|
| 282 | #else |
---|
| 283 | !!---------------------------------------------------------------------- |
---|
[8534] | 284 | !! Default option : Empty module NO ESIM sea-ice model |
---|
[8413] | 285 | !!---------------------------------------------------------------------- |
---|
| 286 | #endif |
---|
| 287 | |
---|
| 288 | !!====================================================================== |
---|
| 289 | END MODULE icerst |
---|