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