[821] | 1 | MODULE limrst_2 |
---|
[3] | 2 | !!====================================================================== |
---|
[821] | 3 | !! *** MODULE limrst_2 *** |
---|
[3] | 4 | !! Ice restart : write the ice restart file |
---|
| 5 | !!====================================================================== |
---|
[508] | 6 | !! History : 2.0 ! 01-04 (C. Ethe, G. Madec) Original code |
---|
| 7 | !! ! 06-07 (S. Masson) use IOM for restart read/write |
---|
| 8 | !!---------------------------------------------------------------------- |
---|
[821] | 9 | #if defined key_lim2 |
---|
[3] | 10 | !!---------------------------------------------------------------------- |
---|
[821] | 11 | !! 'key_lim2' : LIM 2.0 sea-ice model |
---|
[3] | 12 | !!---------------------------------------------------------------------- |
---|
| 13 | !!---------------------------------------------------------------------- |
---|
[821] | 14 | !! lim_rst_opn_2 : open ice restart file |
---|
| 15 | !! lim_rst_write_2 : write of the ice restart file |
---|
| 16 | !! lim_rst_read_2 : read the ice restart file |
---|
[508] | 17 | !!---------------------------------------------------------------------- |
---|
[1715] | 18 | USE dom_oce ! ocean space and time domain |
---|
[821] | 19 | USE ice_2 |
---|
[888] | 20 | USE sbc_oce |
---|
| 21 | USE sbc_ice |
---|
[3] | 22 | |
---|
[508] | 23 | USE in_out_manager |
---|
| 24 | USE iom |
---|
| 25 | |
---|
[3] | 26 | IMPLICIT NONE |
---|
| 27 | PRIVATE |
---|
| 28 | |
---|
[888] | 29 | PUBLIC lim_rst_opn_2 ! routine called by sbcice_lim_2.F90 |
---|
| 30 | PUBLIC lim_rst_write_2 ! routine called by sbcice_lim_2.F90 |
---|
| 31 | PUBLIC lim_rst_read_2 ! routine called by iceini_2.F90 |
---|
[3] | 32 | |
---|
[544] | 33 | LOGICAL, PUBLIC :: lrst_ice !: logical to control the ice restart write |
---|
[508] | 34 | INTEGER, PUBLIC :: numrir, numriw !: logical unit for ice restart (read and write) |
---|
| 35 | |
---|
[3] | 36 | !!---------------------------------------------------------------------- |
---|
[508] | 37 | !! LIM 2.0, UCL-LOCEAN-IPSL (2006) |
---|
[1156] | 38 | !! $Id$ |
---|
[508] | 39 | !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt) |
---|
[3] | 40 | !!---------------------------------------------------------------------- |
---|
| 41 | |
---|
| 42 | CONTAINS |
---|
| 43 | |
---|
[821] | 44 | SUBROUTINE lim_rst_opn_2( kt ) |
---|
[3] | 45 | !!---------------------------------------------------------------------- |
---|
[821] | 46 | !! *** lim_rst_opn_2 *** |
---|
[508] | 47 | !! |
---|
| 48 | !! ** purpose : output of sea-ice variable in a netcdf file |
---|
| 49 | !!---------------------------------------------------------------------- |
---|
| 50 | INTEGER, INTENT(in) :: kt ! number of iteration |
---|
| 51 | ! |
---|
| 52 | CHARACTER(LEN=20) :: clkt ! ocean time-step deine as a character |
---|
| 53 | CHARACTER(LEN=50) :: clname ! ice output restart file name |
---|
| 54 | !!---------------------------------------------------------------------- |
---|
| 55 | ! |
---|
[783] | 56 | IF( kt == nit000 ) lrst_ice = .FALSE. ! default definition |
---|
[508] | 57 | |
---|
[783] | 58 | ! to get better performances with NetCDF format: |
---|
[888] | 59 | ! we open and define the ice restart file one ice time step before writing the data (-> at nitrst - 2*nn_fsbc + 1) |
---|
| 60 | ! except if we write ice 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 .OR. ( kt == nitend - nn_fsbc + 1 .AND. .NOT. lrst_ice ) ) THEN |
---|
[783] | 62 | ! beware of the format used to write kt (default is i8.8, that should be large enough...) |
---|
| 63 | IF( nitrst > 99999999 ) THEN ; WRITE(clkt, * ) nitrst |
---|
| 64 | ELSE ; WRITE(clkt, '(i8.8)') nitrst |
---|
[508] | 65 | ENDIF |
---|
| 66 | ! create the file |
---|
[1229] | 67 | clname = TRIM(cexper)//"_"//TRIM(ADJUSTL(clkt))//"_"//TRIM(cn_icerst_out) |
---|
[783] | 68 | IF(lwp) THEN |
---|
| 69 | WRITE(numout,*) |
---|
| 70 | SELECT CASE ( jprstlib ) |
---|
| 71 | CASE ( jprstdimg ) ; WRITE(numout,*) ' open ice restart binary file: '//clname |
---|
| 72 | CASE DEFAULT ; WRITE(numout,*) ' open ice restart NetCDF file: '//clname |
---|
| 73 | END SELECT |
---|
[888] | 74 | IF( kt == nitrst - 2*nn_fsbc + 1 ) THEN |
---|
| 75 | WRITE(numout,*) ' kt = nitrst - 2*nn_fsbc + 1 = ', kt,' date= ', ndastp |
---|
| 76 | ELSE ; WRITE(numout,*) ' kt = ' , kt,' date= ', ndastp |
---|
[783] | 77 | ENDIF |
---|
| 78 | ENDIF |
---|
| 79 | |
---|
[547] | 80 | CALL iom_open( clname, numriw, ldwrt = .TRUE., kiolib = jprstlib ) |
---|
[508] | 81 | lrst_ice = .TRUE. |
---|
| 82 | ENDIF |
---|
| 83 | ! |
---|
[821] | 84 | END SUBROUTINE lim_rst_opn_2 |
---|
[508] | 85 | |
---|
[821] | 86 | SUBROUTINE lim_rst_write_2( kt ) |
---|
[508] | 87 | !!---------------------------------------------------------------------- |
---|
[821] | 88 | !! *** lim_rst_write_2 *** |
---|
[3] | 89 | !! |
---|
| 90 | !! ** purpose : output of sea-ice variable in a netcdf file |
---|
[508] | 91 | !!---------------------------------------------------------------------- |
---|
[888] | 92 | INTEGER, INTENT(in) :: kt ! number of iteration |
---|
| 93 | ! |
---|
| 94 | INTEGER :: iter ! kt + nn_fsbc -1 |
---|
[3] | 95 | !!---------------------------------------------------------------------- |
---|
| 96 | |
---|
[888] | 97 | iter = kt + nn_fsbc - 1 ! ice restarts are written at kt == nitrst - nn_fsbc + 1 |
---|
[3] | 98 | |
---|
[508] | 99 | IF( iter == nitrst ) THEN |
---|
| 100 | IF(lwp) WRITE(numout,*) |
---|
[821] | 101 | IF(lwp) WRITE(numout,*) 'lim_rst_write_2 : write ice restart file kt =', kt |
---|
[888] | 102 | IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~~~' |
---|
[3] | 103 | ENDIF |
---|
| 104 | |
---|
[719] | 105 | ! Write in numriw (if iter == nitrst) |
---|
[508] | 106 | ! ------------------ |
---|
| 107 | ! ! calendar control |
---|
[888] | 108 | CALL iom_rstput( iter, nitrst, numriw, 'kt_ice', REAL( iter, wp) ) |
---|
[3] | 109 | |
---|
[508] | 110 | CALL iom_rstput( iter, nitrst, numriw, 'hicif' , hicif (:,:) ) ! prognostic variables |
---|
| 111 | CALL iom_rstput( iter, nitrst, numriw, 'hsnif' , hsnif (:,:) ) |
---|
| 112 | CALL iom_rstput( iter, nitrst, numriw, 'frld' , frld (:,:) ) |
---|
| 113 | CALL iom_rstput( iter, nitrst, numriw, 'sist' , sist (:,:) ) |
---|
| 114 | CALL iom_rstput( iter, nitrst, numriw, 'tbif1' , tbif (:,:,1) ) |
---|
| 115 | CALL iom_rstput( iter, nitrst, numriw, 'tbif2' , tbif (:,:,2) ) |
---|
| 116 | CALL iom_rstput( iter, nitrst, numriw, 'tbif3' , tbif (:,:,3) ) |
---|
[1470] | 117 | CALL iom_rstput( iter, nitrst, numriw, 'u_ice' , u_ice (:,:) ) |
---|
| 118 | CALL iom_rstput( iter, nitrst, numriw, 'v_ice' , v_ice (:,:) ) |
---|
[508] | 119 | CALL iom_rstput( iter, nitrst, numriw, 'qstoif', qstoif(:,:) ) |
---|
| 120 | CALL iom_rstput( iter, nitrst, numriw, 'fsbbq' , fsbbq (:,:) ) |
---|
| 121 | CALL iom_rstput( iter, nitrst, numriw, 'sxice' , sxice (:,:) ) |
---|
| 122 | CALL iom_rstput( iter, nitrst, numriw, 'syice' , syice (:,:) ) |
---|
| 123 | CALL iom_rstput( iter, nitrst, numriw, 'sxxice', sxxice(:,:) ) |
---|
| 124 | CALL iom_rstput( iter, nitrst, numriw, 'syyice', syyice(:,:) ) |
---|
| 125 | CALL iom_rstput( iter, nitrst, numriw, 'sxyice', sxyice(:,:) ) |
---|
| 126 | CALL iom_rstput( iter, nitrst, numriw, 'sxsn' , sxsn (:,:) ) |
---|
| 127 | CALL iom_rstput( iter, nitrst, numriw, 'sysn' , sysn (:,:) ) |
---|
| 128 | CALL iom_rstput( iter, nitrst, numriw, 'sxxsn' , sxxsn (:,:) ) |
---|
| 129 | CALL iom_rstput( iter, nitrst, numriw, 'syysn' , syysn (:,:) ) |
---|
| 130 | CALL iom_rstput( iter, nitrst, numriw, 'sxysn' , sxysn (:,:) ) |
---|
| 131 | CALL iom_rstput( iter, nitrst, numriw, 'sxa' , sxa (:,:) ) |
---|
| 132 | CALL iom_rstput( iter, nitrst, numriw, 'sya' , sya (:,:) ) |
---|
| 133 | CALL iom_rstput( iter, nitrst, numriw, 'sxxa' , sxxa (:,:) ) |
---|
| 134 | CALL iom_rstput( iter, nitrst, numriw, 'syya' , syya (:,:) ) |
---|
| 135 | CALL iom_rstput( iter, nitrst, numriw, 'sxya' , sxya (:,:) ) |
---|
| 136 | CALL iom_rstput( iter, nitrst, numriw, 'sxc0' , sxc0 (:,:) ) |
---|
| 137 | CALL iom_rstput( iter, nitrst, numriw, 'syc0' , syc0 (:,:) ) |
---|
| 138 | CALL iom_rstput( iter, nitrst, numriw, 'sxxc0' , sxxc0 (:,:) ) |
---|
| 139 | CALL iom_rstput( iter, nitrst, numriw, 'syyc0' , syyc0 (:,:) ) |
---|
| 140 | CALL iom_rstput( iter, nitrst, numriw, 'sxyc0' , sxyc0 (:,:) ) |
---|
| 141 | CALL iom_rstput( iter, nitrst, numriw, 'sxc1' , sxc1 (:,:) ) |
---|
| 142 | CALL iom_rstput( iter, nitrst, numriw, 'syc1' , syc1 (:,:) ) |
---|
| 143 | CALL iom_rstput( iter, nitrst, numriw, 'sxxc1' , sxxc1 (:,:) ) |
---|
| 144 | CALL iom_rstput( iter, nitrst, numriw, 'syyc1' , syyc1 (:,:) ) |
---|
| 145 | CALL iom_rstput( iter, nitrst, numriw, 'sxyc1' , sxyc1 (:,:) ) |
---|
| 146 | CALL iom_rstput( iter, nitrst, numriw, 'sxc2' , sxc2 (:,:) ) |
---|
| 147 | CALL iom_rstput( iter, nitrst, numriw, 'syc2' , syc2 (:,:) ) |
---|
| 148 | CALL iom_rstput( iter, nitrst, numriw, 'sxxc2' , sxxc2 (:,:) ) |
---|
| 149 | CALL iom_rstput( iter, nitrst, numriw, 'syyc2' , syyc2 (:,:) ) |
---|
| 150 | CALL iom_rstput( iter, nitrst, numriw, 'sxyc2' , sxyc2 (:,:) ) |
---|
| 151 | CALL iom_rstput( iter, nitrst, numriw, 'sxst' , sxst (:,:) ) |
---|
| 152 | CALL iom_rstput( iter, nitrst, numriw, 'syst' , syst (:,:) ) |
---|
| 153 | CALL iom_rstput( iter, nitrst, numriw, 'sxxst' , sxxst (:,:) ) |
---|
| 154 | CALL iom_rstput( iter, nitrst, numriw, 'syyst' , syyst (:,:) ) |
---|
| 155 | CALL iom_rstput( iter, nitrst, numriw, 'sxyst' , sxyst (:,:) ) |
---|
[3] | 156 | |
---|
[508] | 157 | IF( iter == nitrst ) THEN |
---|
| 158 | CALL iom_close( numriw ) ! close the restart file |
---|
| 159 | lrst_ice = .FALSE. |
---|
| 160 | ENDIF |
---|
| 161 | ! |
---|
[821] | 162 | END SUBROUTINE lim_rst_write_2 |
---|
[3] | 163 | |
---|
| 164 | |
---|
[821] | 165 | SUBROUTINE lim_rst_read_2 |
---|
[508] | 166 | !!---------------------------------------------------------------------- |
---|
[821] | 167 | !! *** lim_rst_read_2 *** |
---|
[508] | 168 | !! |
---|
| 169 | !! ** purpose : read of sea-ice variable restart in a netcdf file |
---|
| 170 | !!---------------------------------------------------------------------- |
---|
[888] | 171 | REAL(wp) :: ziter |
---|
[1473] | 172 | INTEGER :: jlibalt = jprstlib |
---|
| 173 | LOGICAL :: llok |
---|
[1470] | 174 | INTEGER :: itest |
---|
[508] | 175 | !!---------------------------------------------------------------------- |
---|
[3] | 176 | |
---|
[508] | 177 | IF(lwp) THEN |
---|
| 178 | WRITE(numout,*) |
---|
[821] | 179 | WRITE(numout,*) 'lim_rst_read_2 : read ice NetCDF restart file' |
---|
[888] | 180 | WRITE(numout,*) '~~~~~~~~~~~~~~' |
---|
[508] | 181 | ENDIF |
---|
[3] | 182 | |
---|
[1473] | 183 | IF ( jprstlib == jprstdimg ) THEN |
---|
| 184 | ! eventually read netcdf file (monobloc) for restarting on different number of processors |
---|
| 185 | ! if {cn_icerst_in}.nc exists, then set jlibalt to jpnf90 |
---|
| 186 | INQUIRE( FILE = TRIM(cn_icerst_in)//'.nc', EXIST = llok ) |
---|
| 187 | IF ( llok ) THEN ; jlibalt = jpnf90 ; ELSE ; jlibalt = jprstlib ; ENDIF |
---|
| 188 | ENDIF |
---|
[3] | 189 | |
---|
[1473] | 190 | CALL iom_open ( cn_icerst_in, numrir, kiolib = jlibalt ) |
---|
| 191 | |
---|
[888] | 192 | CALL iom_get( numrir, 'kt_ice' , ziter ) |
---|
| 193 | IF(lwp) WRITE(numout,*) ' read ice restart file at time step : ', INT( ziter ) |
---|
[508] | 194 | IF(lwp) WRITE(numout,*) ' in any case we force it to nit000 - 1 : ', nit000 - 1 |
---|
[391] | 195 | |
---|
[3] | 196 | !Control of date |
---|
| 197 | |
---|
[508] | 198 | IF( ( nit000 - INT(ziter) ) /= 1 .AND. ABS( nrstdt ) == 1 ) & |
---|
| 199 | & CALL ctl_stop( 'lim_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' ) |
---|
[3] | 202 | |
---|
[683] | 203 | CALL iom_get( numrir, jpdom_autoglo, 'hicif' , hicif ) |
---|
| 204 | CALL iom_get( numrir, jpdom_autoglo, 'hsnif' , hsnif ) |
---|
| 205 | CALL iom_get( numrir, jpdom_autoglo, 'frld' , frld ) |
---|
| 206 | CALL iom_get( numrir, jpdom_autoglo, 'sist' , sist ) |
---|
| 207 | CALL iom_get( numrir, jpdom_autoglo, 'tbif1' , tbif(:,:,1) ) |
---|
| 208 | CALL iom_get( numrir, jpdom_autoglo, 'tbif2' , tbif(:,:,2) ) |
---|
| 209 | CALL iom_get( numrir, jpdom_autoglo, 'tbif3' , tbif(:,:,3) ) |
---|
[1470] | 210 | |
---|
| 211 | itest = iom_varid( numrir, 'u_ice', ldstop = .FALSE. ) ! test if the variable u_ice is included in the file |
---|
| 212 | IF( itest > 0 ) THEN ! yes -> new restart files (from NEMO 3.2) |
---|
| 213 | CALL iom_get( numrir, jpdom_autoglo, 'u_ice', u_ice ) |
---|
| 214 | CALL iom_get( numrir, jpdom_autoglo, 'v_ice', v_ice ) |
---|
| 215 | ELSE ! no -> old restart file with variable called [uv]i_ice (inroduced in NEMO 3.0) |
---|
| 216 | CALL iom_get( numrir, jpdom_autoglo, 'ui_ice', u_ice ) |
---|
| 217 | CALL iom_get( numrir, jpdom_autoglo, 'vi_ice', v_ice ) |
---|
| 218 | ENDIF |
---|
| 219 | |
---|
[683] | 220 | CALL iom_get( numrir, jpdom_autoglo, 'qstoif', qstoif ) |
---|
| 221 | CALL iom_get( numrir, jpdom_autoglo, 'fsbbq' , fsbbq ) |
---|
| 222 | CALL iom_get( numrir, jpdom_autoglo, 'sxice' , sxice ) |
---|
| 223 | CALL iom_get( numrir, jpdom_autoglo, 'syice' , syice ) |
---|
| 224 | CALL iom_get( numrir, jpdom_autoglo, 'sxxice', sxxice ) |
---|
| 225 | CALL iom_get( numrir, jpdom_autoglo, 'syyice', syyice ) |
---|
| 226 | CALL iom_get( numrir, jpdom_autoglo, 'sxyice', sxyice ) |
---|
| 227 | CALL iom_get( numrir, jpdom_autoglo, 'sxsn' , sxsn ) |
---|
| 228 | CALL iom_get( numrir, jpdom_autoglo, 'sysn' , sysn ) |
---|
| 229 | CALL iom_get( numrir, jpdom_autoglo, 'sxxsn' , sxxsn ) |
---|
| 230 | CALL iom_get( numrir, jpdom_autoglo, 'syysn' , syysn ) |
---|
| 231 | CALL iom_get( numrir, jpdom_autoglo, 'sxysn' , sxysn ) |
---|
| 232 | CALL iom_get( numrir, jpdom_autoglo, 'sxa' , sxa ) |
---|
| 233 | CALL iom_get( numrir, jpdom_autoglo, 'sya' , sya ) |
---|
| 234 | CALL iom_get( numrir, jpdom_autoglo, 'sxxa' , sxxa ) |
---|
| 235 | CALL iom_get( numrir, jpdom_autoglo, 'syya' , syya ) |
---|
| 236 | CALL iom_get( numrir, jpdom_autoglo, 'sxya' , sxya ) |
---|
| 237 | CALL iom_get( numrir, jpdom_autoglo, 'sxc0' , sxc0 ) |
---|
| 238 | CALL iom_get( numrir, jpdom_autoglo, 'syc0' , syc0 ) |
---|
| 239 | CALL iom_get( numrir, jpdom_autoglo, 'sxxc0' , sxxc0 ) |
---|
| 240 | CALL iom_get( numrir, jpdom_autoglo, 'syyc0' , syyc0 ) |
---|
| 241 | CALL iom_get( numrir, jpdom_autoglo, 'sxyc0' , sxyc0 ) |
---|
| 242 | CALL iom_get( numrir, jpdom_autoglo, 'sxc1' , sxc1 ) |
---|
| 243 | CALL iom_get( numrir, jpdom_autoglo, 'syc1' , syc1 ) |
---|
| 244 | CALL iom_get( numrir, jpdom_autoglo, 'sxxc1' , sxxc1 ) |
---|
| 245 | CALL iom_get( numrir, jpdom_autoglo, 'syyc1' , syyc1 ) |
---|
| 246 | CALL iom_get( numrir, jpdom_autoglo, 'sxyc1' , sxyc1 ) |
---|
| 247 | CALL iom_get( numrir, jpdom_autoglo, 'sxc2' , sxc2 ) |
---|
| 248 | CALL iom_get( numrir, jpdom_autoglo, 'syc2' , syc2 ) |
---|
| 249 | CALL iom_get( numrir, jpdom_autoglo, 'sxxc2' , sxxc2 ) |
---|
| 250 | CALL iom_get( numrir, jpdom_autoglo, 'syyc2' , syyc2 ) |
---|
| 251 | CALL iom_get( numrir, jpdom_autoglo, 'sxyc2' , sxyc2 ) |
---|
| 252 | CALL iom_get( numrir, jpdom_autoglo, 'sxst' , sxst ) |
---|
| 253 | CALL iom_get( numrir, jpdom_autoglo, 'syst' , syst ) |
---|
| 254 | CALL iom_get( numrir, jpdom_autoglo, 'sxxst' , sxxst ) |
---|
| 255 | CALL iom_get( numrir, jpdom_autoglo, 'syyst' , syyst ) |
---|
| 256 | CALL iom_get( numrir, jpdom_autoglo, 'sxyst' , sxyst ) |
---|
[473] | 257 | |
---|
[508] | 258 | CALL iom_close( numrir ) |
---|
| 259 | ! |
---|
[821] | 260 | END SUBROUTINE lim_rst_read_2 |
---|
[3] | 261 | |
---|
| 262 | #else |
---|
| 263 | !!---------------------------------------------------------------------- |
---|
[821] | 264 | !! Default option : Empty module NO LIM 2.0 sea-ice model |
---|
[3] | 265 | !!---------------------------------------------------------------------- |
---|
| 266 | #endif |
---|
| 267 | |
---|
| 268 | !!====================================================================== |
---|
[821] | 269 | END MODULE limrst_2 |
---|