[8586] | 1 | MODULE icerst |
---|
| 2 | !!====================================================================== |
---|
| 3 | !! *** MODULE icerst *** |
---|
| 4 | !! sea-ice : write/read the ice restart file |
---|
| 5 | !!====================================================================== |
---|
[9604] | 6 | !! History: 4.0 ! 2018 (many people) SI3 [aka Sea Ice cube] |
---|
[8586] | 7 | !!---------------------------------------------------------------------- |
---|
[9570] | 8 | #if defined key_si3 |
---|
[8586] | 9 | !!---------------------------------------------------------------------- |
---|
[9570] | 10 | !! 'key_si3' SI3 sea-ice model |
---|
[8586] | 11 | !!---------------------------------------------------------------------- |
---|
| 12 | !! ice_rst_opn : open restart file |
---|
| 13 | !! ice_rst_write : write restart file |
---|
| 14 | !! ice_rst_read : read restart file |
---|
| 15 | !!---------------------------------------------------------------------- |
---|
| 16 | USE ice ! sea-ice variables |
---|
| 17 | USE dom_oce ! ocean domain |
---|
[8948] | 18 | USE sbc_oce , ONLY : nn_fsbc, ln_cpl |
---|
[8586] | 19 | USE icectl |
---|
| 20 | ! |
---|
| 21 | USE in_out_manager ! I/O manager |
---|
| 22 | USE iom ! I/O manager library |
---|
[10280] | 23 | USE ioipsl, ONLY : ju2ymds ! for calendar |
---|
[8586] | 24 | USE lib_mpp ! MPP library |
---|
| 25 | USE lib_fortran ! fortran utilities (glob_sum + no signed zero) |
---|
| 26 | |
---|
| 27 | IMPLICIT NONE |
---|
| 28 | PRIVATE |
---|
| 29 | |
---|
| 30 | PUBLIC ice_rst_opn ! called by icestp |
---|
| 31 | PUBLIC ice_rst_write ! called by icestp |
---|
| 32 | PUBLIC ice_rst_read ! called by ice_init |
---|
| 33 | |
---|
| 34 | !!---------------------------------------------------------------------- |
---|
[9598] | 35 | !! NEMO/ICE 4.0 , NEMO Consortium (2018) |
---|
[9950] | 36 | !! $Id$ |
---|
[9598] | 37 | !! Software governed by the CeCILL licence (./LICENSE) |
---|
[8586] | 38 | !!---------------------------------------------------------------------- |
---|
| 39 | CONTAINS |
---|
| 40 | |
---|
| 41 | SUBROUTINE ice_rst_opn( kt ) |
---|
| 42 | !!---------------------------------------------------------------------- |
---|
| 43 | !! *** ice_rst_opn *** |
---|
| 44 | !! |
---|
| 45 | !! ** purpose : open restart file |
---|
| 46 | !!---------------------------------------------------------------------- |
---|
| 47 | INTEGER, INTENT(in) :: kt ! number of iteration |
---|
| 48 | ! |
---|
[10280] | 49 | INTEGER :: iyear, imonth, iday |
---|
| 50 | REAL (wp) :: zsec |
---|
| 51 | REAL (wp) :: zfjulday |
---|
[8586] | 52 | CHARACTER(len=20) :: clkt ! ocean time-step define as a character |
---|
| 53 | CHARACTER(len=50) :: clname ! ice output restart file name |
---|
| 54 | CHARACTER(len=256) :: clpath ! full path to ice output restart file |
---|
| 55 | !!---------------------------------------------------------------------- |
---|
| 56 | ! |
---|
| 57 | IF( kt == nit000 ) lrst_ice = .FALSE. ! default definition |
---|
| 58 | |
---|
| 59 | ! in order to get better performances with NetCDF format, we open and define the ice restart file |
---|
| 60 | ! one ice time step before writing the data (-> at nitrst - 2*nn_fsbc + 1), except if we write ice |
---|
| 61 | ! restart files every ice time step or if an ice restart file was writen at nitend - 2*nn_fsbc + 1 |
---|
| 62 | IF( kt == nitrst - 2*nn_fsbc + 1 .OR. nstock == nn_fsbc & |
---|
| 63 | & .OR. ( kt == nitend - nn_fsbc + 1 .AND. .NOT. lrst_ice ) ) THEN |
---|
| 64 | IF( nitrst <= nitend .AND. nitrst > 0 ) THEN |
---|
| 65 | ! beware of the format used to write kt (default is i8.8, that should be large enough...) |
---|
[10280] | 66 | IF ( ln_rstdate ) THEN |
---|
| 67 | zfjulday = fjulday + (2*nn_fsbc+1)*rdt / rday |
---|
| 68 | IF( ABS(zfjulday - REAL(NINT(zfjulday),wp)) < 0.1 / rday ) zfjulday = REAL(NINT(zfjulday),wp) ! avoid truncation error |
---|
| 69 | CALL ju2ymds( zfjulday, iyear, imonth, iday, zsec ) |
---|
| 70 | WRITE(clkt, '(i4.4,2i2.2)') iyear, imonth, iday |
---|
| 71 | ELSE |
---|
| 72 | IF( nitrst > 99999999 ) THEN ; WRITE(clkt, * ) nitrst |
---|
| 73 | ELSE ; WRITE(clkt, '(i8.8)') nitrst |
---|
| 74 | ENDIF |
---|
[8586] | 75 | ENDIF |
---|
| 76 | ! create the file |
---|
| 77 | clname = TRIM(cexper)//"_"//TRIM(ADJUSTL(clkt))//"_"//TRIM(cn_icerst_out) |
---|
| 78 | clpath = TRIM(cn_icerst_outdir) |
---|
| 79 | IF( clpath(LEN_TRIM(clpath):) /= '/' ) clpath = TRIM(clpath)//'/' |
---|
| 80 | IF(lwp) THEN |
---|
| 81 | WRITE(numout,*) |
---|
| 82 | SELECT CASE ( jprstlib ) |
---|
| 83 | CASE DEFAULT |
---|
| 84 | WRITE(numout,*) ' open ice restart NetCDF file: ',TRIM(clpath)//clname |
---|
| 85 | END SELECT |
---|
| 86 | IF( kt == nitrst - 2*nn_fsbc + 1 ) THEN |
---|
| 87 | WRITE(numout,*) ' kt = nitrst - 2*nn_fsbc + 1 = ', kt,' date= ', ndastp |
---|
| 88 | ELSE |
---|
| 89 | WRITE(numout,*) ' kt = ' , kt,' date= ', ndastp |
---|
| 90 | ENDIF |
---|
| 91 | ENDIF |
---|
| 92 | ! |
---|
[8817] | 93 | CALL iom_open( TRIM(clpath)//TRIM(clname), numriw, ldwrt = .TRUE., kiolib = jprstlib, kdlev = jpl ) |
---|
[8586] | 94 | lrst_ice = .TRUE. |
---|
| 95 | ENDIF |
---|
| 96 | ENDIF |
---|
| 97 | ! |
---|
| 98 | IF( ln_icectl ) CALL ice_prt( kt, iiceprt, jiceprt, 1, ' - Beginning the time step - ' ) ! control print |
---|
[8817] | 99 | ! |
---|
[8586] | 100 | END SUBROUTINE ice_rst_opn |
---|
| 101 | |
---|
| 102 | |
---|
| 103 | SUBROUTINE ice_rst_write( kt ) |
---|
| 104 | !!---------------------------------------------------------------------- |
---|
| 105 | !! *** ice_rst_write *** |
---|
| 106 | !! |
---|
| 107 | !! ** purpose : write restart file |
---|
| 108 | !!---------------------------------------------------------------------- |
---|
| 109 | INTEGER, INTENT(in) :: kt ! number of iteration |
---|
| 110 | !! |
---|
| 111 | INTEGER :: jk ,jl ! dummy loop indices |
---|
| 112 | INTEGER :: iter |
---|
| 113 | CHARACTER(len=25) :: znam |
---|
| 114 | CHARACTER(len=2) :: zchar, zchar1 |
---|
[8817] | 115 | REAL(wp), DIMENSION(jpi,jpj,jpl) :: z3d ! 3D workspace |
---|
[8586] | 116 | !!---------------------------------------------------------------------- |
---|
| 117 | |
---|
| 118 | iter = kt + nn_fsbc - 1 ! ice restarts are written at kt == nitrst - nn_fsbc + 1 |
---|
| 119 | |
---|
| 120 | IF( iter == nitrst ) THEN |
---|
| 121 | IF(lwp) WRITE(numout,*) |
---|
| 122 | IF(lwp) WRITE(numout,*) 'ice_rst_write : write ice restart file kt =', kt |
---|
| 123 | IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~~' |
---|
| 124 | ENDIF |
---|
| 125 | |
---|
| 126 | ! Write in numriw (if iter == nitrst) |
---|
| 127 | ! ------------------ |
---|
| 128 | ! ! calendar control |
---|
| 129 | CALL iom_rstput( iter, nitrst, numriw, 'nn_fsbc', REAL( nn_fsbc, wp ) ) ! time-step |
---|
| 130 | CALL iom_rstput( iter, nitrst, numriw, 'kt_ice' , REAL( iter , wp ) ) ! date |
---|
| 131 | |
---|
[8817] | 132 | ! Prognostic variables |
---|
| 133 | CALL iom_rstput( iter, nitrst, numriw, 'v_i' , v_i ) |
---|
| 134 | CALL iom_rstput( iter, nitrst, numriw, 'v_s' , v_s ) |
---|
| 135 | CALL iom_rstput( iter, nitrst, numriw, 'sv_i', sv_i ) |
---|
| 136 | CALL iom_rstput( iter, nitrst, numriw, 'oa_i', oa_i ) |
---|
| 137 | CALL iom_rstput( iter, nitrst, numriw, 'a_i' , a_i ) |
---|
| 138 | CALL iom_rstput( iter, nitrst, numriw, 't_su', t_su ) |
---|
| 139 | ! Melt ponds |
---|
| 140 | CALL iom_rstput( iter, nitrst, numriw, 'a_ip', a_ip ) |
---|
| 141 | CALL iom_rstput( iter, nitrst, numriw, 'v_ip', v_ip ) |
---|
[9271] | 142 | ! Snow enthalpy |
---|
| 143 | DO jk = 1, nlay_s |
---|
| 144 | WRITE(zchar1,'(I2.2)') jk |
---|
| 145 | znam = 'e_s'//'_l'//zchar1 |
---|
| 146 | z3d(:,:,:) = e_s(:,:,jk,:) |
---|
| 147 | CALL iom_rstput( iter, nitrst, numriw, znam , z3d ) |
---|
| 148 | END DO |
---|
| 149 | ! Ice enthalpy |
---|
[8817] | 150 | DO jk = 1, nlay_i |
---|
| 151 | WRITE(zchar1,'(I2.2)') jk |
---|
[9123] | 152 | znam = 'e_i'//'_l'//zchar1 |
---|
[8817] | 153 | z3d(:,:,:) = e_i(:,:,jk,:) |
---|
| 154 | CALL iom_rstput( iter, nitrst, numriw, znam , z3d ) |
---|
[8586] | 155 | END DO |
---|
[8817] | 156 | ! ice velocity |
---|
[8586] | 157 | CALL iom_rstput( iter, nitrst, numriw, 'u_ice', u_ice ) ! u_ice |
---|
| 158 | CALL iom_rstput( iter, nitrst, numriw, 'v_ice', v_ice ) ! v_ice |
---|
[8948] | 159 | ! fields needed for Met Office (Jules) coupling |
---|
| 160 | IF( ln_cpl ) THEN |
---|
[8933] | 161 | CALL iom_rstput( iter, nitrst, numriw, 'cnd_ice', cnd_ice ) |
---|
| 162 | CALL iom_rstput( iter, nitrst, numriw, 't1_ice' , t1_ice ) |
---|
| 163 | ENDIF |
---|
| 164 | ! |
---|
| 165 | |
---|
[8586] | 166 | ! close restart file |
---|
| 167 | ! ------------------ |
---|
| 168 | IF( iter == nitrst ) THEN |
---|
| 169 | CALL iom_close( numriw ) |
---|
| 170 | lrst_ice = .FALSE. |
---|
| 171 | ENDIF |
---|
| 172 | ! |
---|
| 173 | END SUBROUTINE ice_rst_write |
---|
| 174 | |
---|
| 175 | |
---|
| 176 | SUBROUTINE ice_rst_read |
---|
| 177 | !!---------------------------------------------------------------------- |
---|
| 178 | !! *** ice_rst_read *** |
---|
| 179 | !! |
---|
| 180 | !! ** purpose : read restart file |
---|
| 181 | !!---------------------------------------------------------------------- |
---|
[8817] | 182 | INTEGER :: jk, jl |
---|
| 183 | LOGICAL :: llok |
---|
| 184 | INTEGER :: id1 ! local integer |
---|
| 185 | INTEGER :: jlibalt = jprstlib |
---|
[8586] | 186 | CHARACTER(len=25) :: znam |
---|
| 187 | CHARACTER(len=2) :: zchar, zchar1 |
---|
[8817] | 188 | REAL(wp) :: zfice, ziter |
---|
| 189 | REAL(wp), DIMENSION(jpi,jpj,jpl) :: z3d ! 3D workspace |
---|
[8586] | 190 | !!---------------------------------------------------------------------- |
---|
| 191 | |
---|
| 192 | IF(lwp) THEN |
---|
| 193 | WRITE(numout,*) |
---|
| 194 | WRITE(numout,*) 'ice_rst_read: read ice NetCDF restart file' |
---|
| 195 | WRITE(numout,*) '~~~~~~~~~~~~' |
---|
| 196 | ENDIF |
---|
| 197 | |
---|
[8817] | 198 | CALL iom_open ( TRIM(cn_icerst_indir)//'/'//cn_icerst_in, numrir, kiolib = jprstlib, kdlev = jpl ) |
---|
[8586] | 199 | |
---|
| 200 | CALL iom_get( numrir, 'nn_fsbc', zfice ) |
---|
| 201 | CALL iom_get( numrir, 'kt_ice' , ziter ) |
---|
| 202 | IF(lwp) WRITE(numout,*) ' read ice restart file at time step : ', ziter |
---|
| 203 | IF(lwp) WRITE(numout,*) ' in any case we force it to nit000 - 1 : ', nit000 - 1 |
---|
| 204 | |
---|
| 205 | ! Control of date |
---|
| 206 | IF( ( nit000 - NINT(ziter) ) /= 1 .AND. ABS( nrstdt ) == 1 ) & |
---|
| 207 | & CALL ctl_stop( 'ice_rst_read ===>>>> : problem with nit000 in ice restart', & |
---|
| 208 | & ' verify the file or rerun with the value 0 for the', & |
---|
| 209 | & ' control of time parameter nrstdt' ) |
---|
| 210 | IF( NINT(zfice) /= nn_fsbc .AND. ABS( nrstdt ) == 1 ) & |
---|
| 211 | & CALL ctl_stop( 'ice_rst_read ===>>>> : problem with nn_fsbc in ice restart', & |
---|
| 212 | & ' verify the file or rerun with the value 0 for the', & |
---|
| 213 | & ' control of time parameter nrstdt' ) |
---|
| 214 | |
---|
| 215 | ! Prognostic variables |
---|
[8817] | 216 | CALL iom_get( numrir, jpdom_autoglo, 'v_i' , v_i ) |
---|
| 217 | CALL iom_get( numrir, jpdom_autoglo, 'v_s' , v_s ) |
---|
| 218 | CALL iom_get( numrir, jpdom_autoglo, 'sv_i', sv_i ) |
---|
| 219 | CALL iom_get( numrir, jpdom_autoglo, 'oa_i', oa_i ) |
---|
| 220 | CALL iom_get( numrir, jpdom_autoglo, 'a_i' , a_i ) |
---|
| 221 | CALL iom_get( numrir, jpdom_autoglo, 't_su', t_su ) |
---|
| 222 | ! Melt ponds |
---|
[9122] | 223 | id1 = iom_varid( numrir, 'a_ip' , ldstop = .FALSE. ) |
---|
[8637] | 224 | IF( id1 > 0 ) THEN ! fields exist (melt ponds) |
---|
[8817] | 225 | CALL iom_get( numrir, jpdom_autoglo, 'a_ip' , a_ip ) |
---|
| 226 | CALL iom_get( numrir, jpdom_autoglo, 'v_ip' , v_ip ) |
---|
[8637] | 227 | ELSE ! start from rest |
---|
[8817] | 228 | IF(lwp) WRITE(numout,*) ' ==>> previous run without melt ponds output then set it to zero' |
---|
[8637] | 229 | a_ip(:,:,:) = 0._wp |
---|
| 230 | v_ip(:,:,:) = 0._wp |
---|
[8586] | 231 | ENDIF |
---|
[9271] | 232 | ! Snow enthalpy |
---|
| 233 | DO jk = 1, nlay_s |
---|
[8817] | 234 | WRITE(zchar1,'(I2.2)') jk |
---|
[9271] | 235 | znam = 'e_s'//'_l'//zchar1 |
---|
| 236 | CALL iom_get( numrir, jpdom_autoglo, znam , z3d ) |
---|
| 237 | e_s(:,:,jk,:) = z3d(:,:,:) |
---|
| 238 | END DO |
---|
| 239 | ! Ice enthalpy |
---|
| 240 | DO jk = 1, nlay_i |
---|
| 241 | WRITE(zchar1,'(I2.2)') jk |
---|
[9123] | 242 | znam = 'e_i'//'_l'//zchar1 |
---|
[8817] | 243 | CALL iom_get( numrir, jpdom_autoglo, znam , z3d ) |
---|
| 244 | e_i(:,:,jk,:) = z3d(:,:,:) |
---|
[8586] | 245 | END DO |
---|
[8817] | 246 | ! ice velocity |
---|
[8586] | 247 | CALL iom_get( numrir, jpdom_autoglo, 'u_ice', u_ice ) |
---|
| 248 | CALL iom_get( numrir, jpdom_autoglo, 'v_ice', v_ice ) |
---|
[8948] | 249 | ! fields needed for Met Office (Jules) coupling |
---|
| 250 | IF( ln_cpl ) THEN |
---|
[8933] | 251 | CALL iom_get( numrir, jpdom_autoglo, 'cnd_ice', cnd_ice ) |
---|
| 252 | CALL iom_get( numrir, jpdom_autoglo, 't1_ice' , t1_ice ) |
---|
| 253 | ENDIF |
---|
[8586] | 254 | |
---|
| 255 | END SUBROUTINE ice_rst_read |
---|
| 256 | |
---|
| 257 | #else |
---|
| 258 | !!---------------------------------------------------------------------- |
---|
[9570] | 259 | !! Default option : Empty module NO SI3 sea-ice model |
---|
[8586] | 260 | !!---------------------------------------------------------------------- |
---|
| 261 | #endif |
---|
| 262 | |
---|
| 263 | !!====================================================================== |
---|
| 264 | END MODULE icerst |
---|