[3] | 1 | MODULE restart |
---|
| 2 | !!====================================================================== |
---|
| 3 | !! *** MODULE restart *** |
---|
| 4 | !! Ocean restart : write the ocean restart file |
---|
[508] | 5 | !!====================================================================== |
---|
[2528] | 6 | !! History : OPA ! 1999-11 (M. Imbard) Original code |
---|
| 7 | !! NEMO 1.0 ! 2002-08 (G. Madec) F90: Free form |
---|
| 8 | !! 2.0 ! 2006-07 (S. Masson) use IOM for restart |
---|
| 9 | !! 3.3 ! 2010-04 (M. Leclair, G. Madec) modified LF-RA |
---|
| 10 | !! - - ! 2010-10 (C. Ethe, G. Madec) TRC-TRA merge (T-S in 4D) |
---|
[5836] | 11 | !! 3.7 ! 2014-01 (G. Madec) suppression of curl and hdiv from the restart |
---|
| 12 | !! - ! 2014-12 (G. Madec) remove KPP scheme |
---|
[14139] | 13 | !! 4.1 ! 2020-11 (S. Techene, G. Madec) move ssh initiatlisation in rst_read_ssh |
---|
| 14 | !! - ! add restart in Shallow Water Eq. case |
---|
[508] | 15 | !!---------------------------------------------------------------------- |
---|
[3] | 16 | |
---|
| 17 | !!---------------------------------------------------------------------- |
---|
[14139] | 18 | !! rst_opn : open the ocean restart file for writting |
---|
| 19 | !! rst_write : write the ocean restart file |
---|
| 20 | !! rst_read_open : open the restart file for reading |
---|
| 21 | !! rst_read : read the ocean restart file |
---|
| 22 | !! rst_read_ssh : ssh set from restart or domcfg.nc file or usr_def_istat_ssh |
---|
[3] | 23 | !!---------------------------------------------------------------------- |
---|
[14139] | 24 | USE oce ! ocean dynamics and tracers |
---|
| 25 | USE dom_oce ! ocean space and time domain |
---|
| 26 | USE sbc_ice ! only lk_si3 |
---|
| 27 | USE phycst ! physical constants |
---|
| 28 | USE eosbn2 ! equation of state |
---|
| 29 | USE wet_dry ! Wetting/Drying flux limiting |
---|
| 30 | USE usrdef_istate, ONLY : usr_def_istate_ssh ! user defined ssh initial state |
---|
| 31 | USE trdmxl_oce ! ocean active mixed layer tracers trends variables |
---|
| 32 | USE diu_bulk ! ??? |
---|
[5836] | 33 | ! |
---|
[14139] | 34 | USE in_out_manager ! I/O manager |
---|
| 35 | USE iom ! I/O module |
---|
| 36 | USE lib_mpp ! distribued memory computing library |
---|
[9367] | 37 | |
---|
[3] | 38 | IMPLICIT NONE |
---|
| 39 | PRIVATE |
---|
| 40 | |
---|
[14139] | 41 | PUBLIC rst_opn ! called by step.F90 |
---|
| 42 | PUBLIC rst_write ! called by step.F90 |
---|
| 43 | PUBLIC rst_read_open ! called in rst_read_ssh |
---|
| 44 | PUBLIC rst_read ! called by istate.F90 |
---|
| 45 | PUBLIC rst_read_ssh ! called by domain.F90 |
---|
| 46 | |
---|
| 47 | !! * Substitutions |
---|
| 48 | # include "do_loop_substitute.h90" |
---|
[14179] | 49 | # include "domzgr_substitute.h90" |
---|
[3] | 50 | !!---------------------------------------------------------------------- |
---|
[9598] | 51 | !! NEMO/OCE 4.0 , NEMO Consortium (2018) |
---|
[888] | 52 | !! $Id$ |
---|
[10068] | 53 | !! Software governed by the CeCILL license (see ./LICENSE) |
---|
[359] | 54 | !!---------------------------------------------------------------------- |
---|
[3] | 55 | CONTAINS |
---|
| 56 | |
---|
[508] | 57 | SUBROUTINE rst_opn( kt ) |
---|
| 58 | !!--------------------------------------------------------------------- |
---|
| 59 | !! *** ROUTINE rst_opn *** |
---|
[14072] | 60 | !! |
---|
| 61 | !! ** Purpose : + initialization (should be read in the namelist) of nitrst |
---|
[508] | 62 | !! + open the restart when we are one time step before nitrst |
---|
| 63 | !! - restart header is defined when kt = nitrst-1 |
---|
| 64 | !! - restart data are written when kt = nitrst |
---|
| 65 | !! + define lrst_oce to .TRUE. when we need to define or write the restart |
---|
| 66 | !!---------------------------------------------------------------------- |
---|
| 67 | INTEGER, INTENT(in) :: kt ! ocean time-step |
---|
| 68 | !! |
---|
| 69 | CHARACTER(LEN=20) :: clkt ! ocean time-step deine as a character |
---|
[5341] | 70 | CHARACTER(LEN=50) :: clname ! ocean output restart file name |
---|
| 71 | CHARACTER(lc) :: clpath ! full path to ocean output restart file |
---|
[9367] | 72 | CHARACTER(LEN=52) :: clpname ! ocean output restart file name including prefix for AGRIF |
---|
[9535] | 73 | CHARACTER(LEN=256) :: clinfo ! info character |
---|
[508] | 74 | !!---------------------------------------------------------------------- |
---|
| 75 | ! |
---|
[783] | 76 | IF( kt == nit000 ) THEN ! default definitions |
---|
[14072] | 77 | lrst_oce = .FALSE. |
---|
[5341] | 78 | IF( ln_rst_list ) THEN |
---|
| 79 | nrst_lst = 1 |
---|
[11536] | 80 | nitrst = nn_stocklist( nrst_lst ) |
---|
[5341] | 81 | ELSE |
---|
| 82 | nitrst = nitend |
---|
| 83 | ENDIF |
---|
[508] | 84 | ENDIF |
---|
[14072] | 85 | |
---|
[11536] | 86 | IF( .NOT. ln_rst_list .AND. nn_stock == -1 ) RETURN ! we will never do any restart |
---|
[5341] | 87 | |
---|
| 88 | ! frequency-based restart dumping (nn_stock) |
---|
[14072] | 89 | IF( .NOT. ln_rst_list .AND. MOD( kt - 1, nn_stock ) == 0 ) THEN |
---|
[783] | 90 | ! we use kt - 1 and not kt - nit000 to keep the same periodicity from the beginning of the experiment |
---|
[11536] | 91 | nitrst = kt + nn_stock - 1 ! define the next value of nitrst for restart writing |
---|
[783] | 92 | IF( nitrst > nitend ) nitrst = nitend ! make sure we write a restart at the end of the run |
---|
| 93 | ENDIF |
---|
| 94 | ! to get better performances with NetCDF format: |
---|
| 95 | ! we open and define the ocean restart file one time step before writing the data (-> at nitrst - 1) |
---|
| 96 | ! except if we write ocean restart files every time step or if an ocean restart file was writen at nitend - 1 |
---|
[11536] | 97 | IF( kt == nitrst - 1 .OR. nn_stock == 1 .OR. ( kt == nitend .AND. .NOT. lrst_oce ) ) THEN |
---|
[14072] | 98 | IF( nitrst <= nitend .AND. nitrst > 0 ) THEN |
---|
[5341] | 99 | ! beware of the format used to write kt (default is i8.8, that should be large enough...) |
---|
| 100 | IF( nitrst > 999999999 ) THEN ; WRITE(clkt, * ) nitrst |
---|
| 101 | ELSE ; WRITE(clkt, '(i8.8)') nitrst |
---|
[611] | 102 | ENDIF |
---|
[5341] | 103 | ! create the file |
---|
| 104 | clname = TRIM(cexper)//"_"//TRIM(ADJUSTL(clkt))//"_"//TRIM(cn_ocerst_out) |
---|
| 105 | clpath = TRIM(cn_ocerst_outdir) |
---|
| 106 | IF( clpath(LEN_TRIM(clpath):) /= '/' ) clpath = TRIM(clpath) // '/' |
---|
| 107 | IF(lwp) THEN |
---|
| 108 | WRITE(numout,*) |
---|
[9367] | 109 | IF(.NOT.lwxios) THEN |
---|
[10425] | 110 | WRITE(numout,*) ' open ocean restart NetCDF file: ',TRIM(clpath)//TRIM(clname) |
---|
[9367] | 111 | IF ( snc4set%luse ) WRITE(numout,*) ' opened for NetCDF4 chunking and compression' |
---|
| 112 | IF( kt == nitrst - 1 ) THEN ; WRITE(numout,*) ' kt = nitrst - 1 = ', kt |
---|
| 113 | ELSE ; WRITE(numout,*) ' kt = ' , kt |
---|
| 114 | ENDIF |
---|
[5341] | 115 | ENDIF |
---|
| 116 | ENDIF |
---|
| 117 | ! |
---|
[9367] | 118 | IF(.NOT.lwxios) THEN |
---|
[10425] | 119 | CALL iom_open( TRIM(clpath)//TRIM(clname), numrow, ldwrt = .TRUE. ) |
---|
[9367] | 120 | ELSE |
---|
[14239] | 121 | #if defined key_xios |
---|
[13970] | 122 | cw_ocerst_cxt = "rstw_"//TRIM(ADJUSTL(clkt)) |
---|
[9367] | 123 | IF( TRIM(Agrif_CFixed()) == '0' ) THEN |
---|
| 124 | clpname = clname |
---|
| 125 | ELSE |
---|
[14072] | 126 | clpname = TRIM(Agrif_CFixed())//"_"//clname |
---|
[9367] | 127 | ENDIF |
---|
[13970] | 128 | numrow = iom_xios_setid(TRIM(clpath)//TRIM(clpname)) |
---|
| 129 | CALL iom_init( cw_ocerst_cxt, kdid = numrow, ld_closedef = .false. ) |
---|
[9367] | 130 | CALL iom_swap( cxios_context ) |
---|
[9535] | 131 | #else |
---|
| 132 | clinfo = 'Can not use XIOS in rst_opn' |
---|
| 133 | CALL ctl_stop(TRIM(clinfo)) |
---|
| 134 | #endif |
---|
[9367] | 135 | ENDIF |
---|
[5341] | 136 | lrst_oce = .TRUE. |
---|
[611] | 137 | ENDIF |
---|
[508] | 138 | ENDIF |
---|
| 139 | ! |
---|
| 140 | END SUBROUTINE rst_opn |
---|
| 141 | |
---|
| 142 | |
---|
[12377] | 143 | SUBROUTINE rst_write( kt, Kbb, Kmm ) |
---|
[3] | 144 | !!--------------------------------------------------------------------- |
---|
| 145 | !! *** ROUTINE rstwrite *** |
---|
[14072] | 146 | !! |
---|
[10425] | 147 | !! ** Purpose : Write restart fields in NetCDF format |
---|
[3] | 148 | !! |
---|
[508] | 149 | !! ** Method : Write in numrow when kt == nitrst in NetCDF |
---|
[2528] | 150 | !! file, save fields which are necessary for restart |
---|
[14053] | 151 | !! |
---|
| 152 | !! NB: ssh is written here (rst_write) |
---|
[14139] | 153 | !! but is read or set in rst_read_ssh |
---|
[3] | 154 | !!---------------------------------------------------------------------- |
---|
[12377] | 155 | INTEGER, INTENT(in) :: kt ! ocean time-step |
---|
| 156 | INTEGER, INTENT(in) :: Kbb, Kmm ! ocean time level indices |
---|
[3] | 157 | !!---------------------------------------------------------------------- |
---|
[14139] | 158 | ! |
---|
| 159 | CALL iom_rstput( kt, nitrst, numrow, 'rdt' , rn_Dt ) ! dynamics time step |
---|
| 160 | ! |
---|
| 161 | IF( .NOT.lwxios ) CALL iom_delay_rst( 'WRITE', 'OCE', numrow ) ! save only ocean delayed global communication variables |
---|
| 162 | ! |
---|
| 163 | IF( .NOT.ln_diurnal_only ) THEN |
---|
| 164 | CALL iom_rstput( kt, nitrst, numrow, 'sshb' , ssh(:,: ,Kbb) ) ! before fields |
---|
| 165 | CALL iom_rstput( kt, nitrst, numrow, 'ub' , uu(:,:,: ,Kbb) ) |
---|
| 166 | CALL iom_rstput( kt, nitrst, numrow, 'vb' , vv(:,:,: ,Kbb) ) |
---|
| 167 | IF( .NOT.lk_SWE ) THEN |
---|
| 168 | CALL iom_rstput( kt, nitrst, numrow, 'tb' , ts(:,:,:,jp_tem,Kbb) ) |
---|
| 169 | CALL iom_rstput( kt, nitrst, numrow, 'sb' , ts(:,:,:,jp_sal,Kbb) ) |
---|
| 170 | ENDIF |
---|
| 171 | ! |
---|
[14179] | 172 | #if ! defined key_RK3 |
---|
[14139] | 173 | CALL iom_rstput( kt, nitrst, numrow, 'sshn' , ssh(:,: ,Kmm) ) ! now fields |
---|
| 174 | CALL iom_rstput( kt, nitrst, numrow, 'un' , uu(:,:,: ,Kmm) ) |
---|
| 175 | CALL iom_rstput( kt, nitrst, numrow, 'vn' , vv(:,:,: ,Kmm) ) |
---|
| 176 | IF( .NOT.lk_SWE ) THEN |
---|
| 177 | CALL iom_rstput( kt, nitrst, numrow, 'tn' , ts(:,:,:,jp_tem,Kmm) ) |
---|
| 178 | CALL iom_rstput( kt, nitrst, numrow, 'sn' , ts(:,:,:,jp_sal,Kmm) ) |
---|
| 179 | CALL iom_rstput( kt, nitrst, numrow, 'rhop', rhop ) |
---|
| 180 | ENDIF |
---|
[14179] | 181 | #endif |
---|
[6140] | 182 | ENDIF |
---|
[14072] | 183 | |
---|
[14139] | 184 | IF( ln_diurnal ) CALL iom_rstput( kt, nitrst, numrow, 'Dsst', x_dsst ) |
---|
[508] | 185 | IF( kt == nitrst ) THEN |
---|
[14139] | 186 | IF( .NOT.lwxios ) THEN |
---|
[9367] | 187 | CALL iom_close( numrow ) ! close the restart file (only at last time step) |
---|
| 188 | ELSE |
---|
[13970] | 189 | CALL iom_context_finalize( cw_ocerst_cxt ) |
---|
| 190 | iom_file(numrow)%nfid = 0 |
---|
| 191 | numrow = 0 |
---|
[9367] | 192 | ENDIF |
---|
[4990] | 193 | !!gm IF( .NOT. lk_trdmld ) lrst_oce = .FALSE. |
---|
| 194 | !!gm not sure what to do here ===>>> ask to Sebastian |
---|
| 195 | lrst_oce = .FALSE. |
---|
[14139] | 196 | IF( ln_rst_list ) THEN |
---|
| 197 | nrst_lst = MIN(nrst_lst + 1, SIZE(nn_stocklist,1)) |
---|
| 198 | nitrst = nn_stocklist( nrst_lst ) |
---|
| 199 | ENDIF |
---|
[3] | 200 | ENDIF |
---|
[508] | 201 | ! |
---|
[3] | 202 | END SUBROUTINE rst_write |
---|
| 203 | |
---|
[4990] | 204 | |
---|
[4292] | 205 | SUBROUTINE rst_read_open |
---|
[14072] | 206 | !!---------------------------------------------------------------------- |
---|
[4292] | 207 | !! *** ROUTINE rst_read_open *** |
---|
[14072] | 208 | !! |
---|
[10425] | 209 | !! ** Purpose : Open read files for NetCDF restart |
---|
[14072] | 210 | !! |
---|
[4292] | 211 | !! ** Method : Use a non-zero, positive value of numror to assess whether or not |
---|
| 212 | !! the file has already been opened |
---|
| 213 | !!---------------------------------------------------------------------- |
---|
[13970] | 214 | LOGICAL :: llok |
---|
| 215 | CHARACTER(len=lc) :: clpath ! full path to ocean output restart file |
---|
| 216 | CHARACTER(len=lc+2) :: clpname ! file name including agrif prefix |
---|
[4292] | 217 | !!---------------------------------------------------------------------- |
---|
[4990] | 218 | ! |
---|
| 219 | IF( numror <= 0 ) THEN |
---|
[4292] | 220 | IF(lwp) THEN ! Contol prints |
---|
| 221 | WRITE(numout,*) |
---|
[10425] | 222 | WRITE(numout,*) 'rst_read : read oce NetCDF restart file' |
---|
[4292] | 223 | IF ( snc4set%luse ) WRITE(numout,*) 'rst_read : configured with NetCDF4 support' |
---|
| 224 | WRITE(numout,*) '~~~~~~~~' |
---|
| 225 | ENDIF |
---|
[9367] | 226 | lxios_sini = .FALSE. |
---|
[5341] | 227 | clpath = TRIM(cn_ocerst_indir) |
---|
| 228 | IF( clpath(LEN_TRIM(clpath):) /= '/' ) clpath = TRIM(clpath) // '/' |
---|
[10425] | 229 | CALL iom_open( TRIM(clpath)//cn_ocerst_in, numror ) |
---|
[9367] | 230 | ! are we using XIOS to read the data? Part above will have to modified once XIOS |
---|
| 231 | ! can handle checking if variable is in the restart file (there will be no need to open |
---|
| 232 | ! restart) |
---|
[13970] | 233 | lrxios = lrxios.AND.lxios_sini |
---|
| 234 | |
---|
[9367] | 235 | IF( lrxios) THEN |
---|
[13970] | 236 | cr_ocerst_cxt = 'oce_rst' |
---|
| 237 | IF(lwp) WRITE(numout,*) 'Enable restart reading by XIOS' |
---|
| 238 | ! IF( TRIM(Agrif_CFixed()) == '0' ) THEN |
---|
| 239 | ! clpname = cn_ocerst_in |
---|
| 240 | ! ELSE |
---|
[14072] | 241 | ! clpname = TRIM(Agrif_CFixed())//"_"//cn_ocerst_in |
---|
[13970] | 242 | ! ENDIF |
---|
| 243 | CALL iom_init( cr_ocerst_cxt, kdid = numror, ld_closedef = .TRUE. ) |
---|
| 244 | CALL iom_swap( cxios_context ) |
---|
[9367] | 245 | ENDIF |
---|
[13970] | 246 | |
---|
[4292] | 247 | ENDIF |
---|
[9367] | 248 | |
---|
[4292] | 249 | END SUBROUTINE rst_read_open |
---|
| 250 | |
---|
[5836] | 251 | |
---|
[12377] | 252 | SUBROUTINE rst_read( Kbb, Kmm ) |
---|
[14072] | 253 | !!---------------------------------------------------------------------- |
---|
[3] | 254 | !! *** ROUTINE rst_read *** |
---|
[14072] | 255 | !! |
---|
[14053] | 256 | !! ** Purpose : Read velocity and T-S fields in the restart file |
---|
[14072] | 257 | !! |
---|
[14053] | 258 | !! ** Method : Read in restart.nc fields which are necessary for restart |
---|
| 259 | !! |
---|
| 260 | !! NB: restart file openned in DOM/domain.F90:dom_init |
---|
| 261 | !! before field in restart tested in DOM/domain.F90:dom_init |
---|
| 262 | !! (sshb) |
---|
| 263 | !! |
---|
[14139] | 264 | !! NB: ssh is read or set in rst_read_ssh |
---|
[3] | 265 | !!---------------------------------------------------------------------- |
---|
[14139] | 266 | INTEGER , INTENT(in) :: Kbb, Kmm ! ocean time level indices |
---|
[4292] | 267 | INTEGER :: jk |
---|
[9367] | 268 | REAL(wp), DIMENSION(jpi, jpj, jpk) :: w3d |
---|
[14179] | 269 | REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) :: zgdept ! 3D workspace for QCO |
---|
[3] | 270 | !!---------------------------------------------------------------------- |
---|
[14053] | 271 | ! |
---|
[14139] | 272 | IF(.NOT.lrxios ) CALL iom_delay_rst( 'READ', 'OCE', numror ) ! read only ocean delayed global communication variables |
---|
[14053] | 273 | ! |
---|
[14072] | 274 | ! !* Diurnal DSST |
---|
| 275 | IF( ln_diurnal ) CALL iom_get( numror, jpdom_auto, 'Dsst' , x_dsst ) |
---|
[14139] | 276 | IF( ln_diurnal_only ) THEN |
---|
[6140] | 277 | IF(lwp) WRITE( numout, * ) & |
---|
[14072] | 278 | & "rst_read:- ln_diurnal_only set, setting rhop=rho0" |
---|
[12489] | 279 | rhop = rho0 |
---|
[14072] | 280 | CALL iom_get( numror, jpdom_auto, 'tn' , w3d ) |
---|
[12377] | 281 | ts(:,:,1,jp_tem,Kmm) = w3d(:,:,1) |
---|
[14072] | 282 | RETURN |
---|
| 283 | ENDIF |
---|
[14053] | 284 | ! |
---|
[14179] | 285 | #if defined key_RK3 |
---|
| 286 | ! !* Read Kbb fields (NB: in RK3 Kmm = Kbb = Nbb) |
---|
| 287 | IF(lwp) WRITE(numout,*) ' Kbb u, v and T-S fields read in the restart file' |
---|
| 288 | CALL iom_get( numror, jpdom_auto, 'ub' , uu(:,:,: ,Kbb), cd_type = 'U', psgn = -1._wp ) |
---|
| 289 | CALL iom_get( numror, jpdom_auto, 'vb' , vv(:,:,: ,Kbb), cd_type = 'V', psgn = -1._wp ) |
---|
| 290 | IF( .NOT.lk_SWE ) THEN |
---|
| 291 | CALL iom_get( numror, jpdom_auto, 'tb', ts(:,:,:,jp_tem,Kbb) ) |
---|
| 292 | CALL iom_get( numror, jpdom_auto, 'sb', ts(:,:,:,jp_sal,Kbb) ) |
---|
| 293 | ENDIF |
---|
| 294 | #else |
---|
| 295 | ! !* Read Kmm fields (MLF only) |
---|
[14053] | 296 | IF(lwp) WRITE(numout,*) ' Kmm u, v and T-S fields read in the restart file' |
---|
[14139] | 297 | CALL iom_get( numror, jpdom_auto, 'un' , uu(:,:,: ,Kmm), cd_type = 'U', psgn = -1._wp ) |
---|
| 298 | CALL iom_get( numror, jpdom_auto, 'vn' , vv(:,:,: ,Kmm), cd_type = 'V', psgn = -1._wp ) |
---|
| 299 | IF( .NOT.lk_SWE ) THEN |
---|
| 300 | CALL iom_get( numror, jpdom_auto, 'tn', ts(:,:,:,jp_tem,Kmm) ) |
---|
| 301 | CALL iom_get( numror, jpdom_auto, 'sn', ts(:,:,:,jp_sal,Kmm) ) |
---|
| 302 | ENDIF |
---|
[14053] | 303 | ! |
---|
[14179] | 304 | IF( l_1st_euler ) THEN !* Euler restart (MLF only) |
---|
[14053] | 305 | IF(lwp) WRITE(numout,*) ' Kbb u, v and T-S fields set to Kmm values' |
---|
[14139] | 306 | uu(:,:,: ,Kbb) = uu(:,:,: ,Kmm) ! all before fields set to now values |
---|
[14053] | 307 | vv(:,:,: ,Kbb) = vv(:,:,: ,Kmm) |
---|
[14139] | 308 | IF( .NOT.lk_SWE ) ts(:,:,:,:,Kbb) = ts(:,:,:,:,Kmm) |
---|
| 309 | ! |
---|
[14179] | 310 | ELSE !* Leap frog restart (MLF only) |
---|
[14053] | 311 | IF(lwp) WRITE(numout,*) ' Kbb u, v and T-S fields read in the restart file' |
---|
[14139] | 312 | CALL iom_get( numror, jpdom_auto, 'ub' , uu(:,:,: ,Kbb), cd_type = 'U', psgn = -1._wp ) |
---|
| 313 | CALL iom_get( numror, jpdom_auto, 'vb' , vv(:,:,: ,Kbb), cd_type = 'V', psgn = -1._wp ) |
---|
| 314 | IF( .NOT.lk_SWE ) THEN |
---|
| 315 | CALL iom_get( numror, jpdom_auto, 'tb', ts(:,:,:,jp_tem,Kbb) ) |
---|
| 316 | CALL iom_get( numror, jpdom_auto, 'sb', ts(:,:,:,jp_sal,Kbb) ) |
---|
| 317 | ENDIF |
---|
[3680] | 318 | ENDIF |
---|
[14179] | 319 | #endif |
---|
[3680] | 320 | ! |
---|
[14139] | 321 | IF( .NOT.lk_SWE ) THEN |
---|
| 322 | IF( iom_varid( numror, 'rhop', ldstop = .FALSE. ) > 0 ) THEN |
---|
| 323 | CALL iom_get( numror, jpdom_auto, 'rhop' , rhop ) ! now potential density |
---|
| 324 | ELSE |
---|
[14179] | 325 | #if defined key_qco |
---|
| 326 | ALLOCATE( zgdept(jpi,jpj,jpk) ) |
---|
| 327 | DO jk = 1, jpk |
---|
| 328 | zgdept(:,:,jk) = gdept(:,:,jk,Kmm) |
---|
| 329 | END DO |
---|
| 330 | CALL eos( ts(:,:,:,:,Kmm), rhd, rhop, zgdept ) |
---|
| 331 | DEALLOCATE( zgdept ) |
---|
| 332 | #else |
---|
[14139] | 333 | CALL eos( ts(:,:,:,:,Kmm), rhd, rhop, gdept(:,:,:,Kmm) ) |
---|
[14179] | 334 | #endif |
---|
[14139] | 335 | ENDIF |
---|
[3680] | 336 | ENDIF |
---|
[2528] | 337 | ! |
---|
[508] | 338 | END SUBROUTINE rst_read |
---|
[473] | 339 | |
---|
[14139] | 340 | |
---|
| 341 | SUBROUTINE rst_read_ssh( Kbb, Kmm, Kaa ) |
---|
| 342 | !!--------------------------------------------------------------------- |
---|
| 343 | !! *** ROUTINE rst_read_ssh *** |
---|
| 344 | !! |
---|
| 345 | !! ** Purpose : ssh initialization of the sea surface height (ssh) |
---|
| 346 | !! |
---|
| 347 | !! ** Method : set ssh from restart or read configuration, or user_def |
---|
| 348 | !! * ln_rstart = T |
---|
| 349 | !! USE of IOM library to read ssh in the restart file |
---|
| 350 | !! Leap-Frog: Kbb and Kmm are read except for l_1st_euler=T |
---|
| 351 | !! |
---|
| 352 | !! * otherwise |
---|
| 353 | !! call user defined ssh or |
---|
| 354 | !! set to -ssh_ref in wet and drying case with domcfg.nc |
---|
| 355 | !! |
---|
| 356 | !! NB: ssh_b/n are written by restart.F90 |
---|
| 357 | !!---------------------------------------------------------------------- |
---|
| 358 | INTEGER, INTENT(in) :: Kbb, Kmm, Kaa ! ocean time level indices |
---|
| 359 | ! |
---|
| 360 | INTEGER :: ji, jj, jk |
---|
| 361 | !!---------------------------------------------------------------------- |
---|
| 362 | ! |
---|
| 363 | IF(lwp) THEN |
---|
| 364 | WRITE(numout,*) |
---|
| 365 | WRITE(numout,*) 'rst_read_ssh : ssh initialization' |
---|
| 366 | WRITE(numout,*) '~~~~~~~~~~~~ ' |
---|
| 367 | ENDIF |
---|
| 368 | ! |
---|
| 369 | ! !=============================! |
---|
| 370 | IF( ln_rstart ) THEN !== Read the restart file ==! |
---|
| 371 | ! !=============================! |
---|
| 372 | ! |
---|
[14179] | 373 | #if defined key_RK3 |
---|
| 374 | ! !* RK3: Read ssh at Kbb |
---|
[14139] | 375 | IF(lwp) WRITE(numout,*) |
---|
[14179] | 376 | IF(lwp) WRITE(numout,*) ' Kbb sea surface height read in the restart file' |
---|
| 377 | CALL iom_get( numror, jpdom_auto, 'sshb' , ssh(:,:,Kbb) ) |
---|
| 378 | ! |
---|
| 379 | ! !* RK3: Set ssh at Kmm for AGRIF |
---|
| 380 | ssh(:,:,Kmm) = 0._wp |
---|
| 381 | #else |
---|
| 382 | ! !* MLF: Read ssh at Kmm |
---|
| 383 | IF(lwp) WRITE(numout,*) |
---|
[14139] | 384 | IF(lwp) WRITE(numout,*) ' Kmm sea surface height read in the restart file' |
---|
| 385 | CALL iom_get( numror, jpdom_auto, 'sshn' , ssh(:,:,Kmm) ) |
---|
| 386 | ! |
---|
[14179] | 387 | IF( l_1st_euler ) THEN !* MLF: Euler at first time-step |
---|
[14139] | 388 | IF(lwp) WRITE(numout,*) |
---|
| 389 | IF(lwp) WRITE(numout,*) ' Euler first time step : ssh(Kbb) = ssh(Kmm)' |
---|
| 390 | ssh(:,:,Kbb) = ssh(:,:,Kmm) |
---|
| 391 | ! |
---|
[14179] | 392 | ELSE !* MLF: read ssh at Kbb |
---|
[14139] | 393 | IF(lwp) WRITE(numout,*) |
---|
| 394 | IF(lwp) WRITE(numout,*) ' Kbb sea surface height read in the restart file' |
---|
| 395 | CALL iom_get( numror, jpdom_auto, 'sshb', ssh(:,:,Kbb) ) |
---|
| 396 | ENDIF |
---|
[14179] | 397 | #endif |
---|
[14139] | 398 | ! !============================! |
---|
| 399 | ELSE !== Initialize at "rest" ==! |
---|
| 400 | ! !============================! |
---|
| 401 | ! |
---|
| 402 | IF(lwp) WRITE(numout,*) |
---|
| 403 | IF(lwp) WRITE(numout,*) ' initialization at rest' |
---|
| 404 | ! |
---|
| 405 | IF( ll_wd ) THEN !* wet and dry |
---|
| 406 | ! |
---|
| 407 | IF( ln_read_cfg ) THEN ! read configuration : ssh_ref is read in domain_cfg file |
---|
| 408 | !!st why ssh is not masked : i.e. ssh(:,:,Kmm) = -ssh_ref*ssmask(:,:), |
---|
| 409 | !!st since at the 1st time step lbclnk will be applied on ssh at Kaa but not initially at Kbb and Kmm |
---|
| 410 | ssh(:,:,Kbb) = -ssh_ref |
---|
| 411 | ! |
---|
[14834] | 412 | DO_2D( nn_hls, nn_hls, nn_hls, nn_hls ) |
---|
[14139] | 413 | IF( ht_0(ji,jj)-ssh_ref < rn_wdmin1 ) THEN ! if total depth is less than min depth |
---|
| 414 | ssh(ji,jj,Kbb) = rn_wdmin1 - ht_0(ji,jj) |
---|
| 415 | ENDIF |
---|
| 416 | END_2D |
---|
| 417 | ELSE ! user define configuration case |
---|
| 418 | CALL usr_def_istate_ssh( tmask, ssh(:,:,Kbb) ) |
---|
| 419 | ENDIF |
---|
| 420 | ! |
---|
| 421 | ELSE !* user defined configuration |
---|
| 422 | CALL usr_def_istate_ssh( tmask, ssh(:,:,Kbb) ) |
---|
| 423 | ! |
---|
| 424 | ENDIF |
---|
| 425 | ! |
---|
[14179] | 426 | #if defined key_RK3 |
---|
| 427 | ssh(:,:,Kmm) = 0._wp !* RK3: set Kmm to 0 for AGRIF |
---|
| 428 | #else |
---|
| 429 | ssh(:,:,Kmm) = ssh(:,:,Kbb) !* MLF: set now values from to before ones |
---|
| 430 | #endif |
---|
[14139] | 431 | ENDIF |
---|
| 432 | ! |
---|
[14145] | 433 | ! !==========================! |
---|
[14179] | 434 | ssh(:,:,Kaa) = 0._wp !== Set to 0 for AGRIF ==! |
---|
[14145] | 435 | ! !==========================! |
---|
| 436 | ! |
---|
[14139] | 437 | END SUBROUTINE rst_read_ssh |
---|
| 438 | |
---|
[3] | 439 | !!===================================================================== |
---|
| 440 | END MODULE restart |
---|