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