Changeset 14017 for NEMO/branches/2020/dev_r13648_ASINTER-04_laurent_bulk_ice/src/OCE/IOM/restart.F90
- Timestamp:
- 2020-12-02T16:32:24+01:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
NEMO/branches/2020/dev_r13648_ASINTER-04_laurent_bulk_ice/src/OCE/IOM/restart.F90
r13286 r14017 18 18 !! rst_read : read the ocean restart file 19 19 !!---------------------------------------------------------------------- 20 USE oce ! ocean dynamics and tracers 20 USE oce ! ocean dynamics and tracers 21 21 USE dom_oce ! ocean space and time domain 22 USE sbc_ice ! only lk_si3 22 USE sbc_ice ! only lk_si3 23 23 USE phycst ! physical constants 24 24 USE eosbn2 ! equation of state (eos bn2 routine) … … 48 48 !!--------------------------------------------------------------------- 49 49 !! *** ROUTINE rst_opn *** 50 !! 51 !! ** Purpose : + initialization (should be read in the namelist) of nitrst 50 !! 51 !! ** Purpose : + initialization (should be read in the namelist) of nitrst 52 52 !! + open the restart when we are one time step before nitrst 53 53 !! - restart header is defined when kt = nitrst-1 … … 65 65 ! 66 66 IF( kt == nit000 ) THEN ! default definitions 67 lrst_oce = .FALSE. 67 lrst_oce = .FALSE. 68 68 IF( ln_rst_list ) THEN 69 69 nrst_lst = 1 … … 73 73 ENDIF 74 74 ENDIF 75 75 76 76 IF( .NOT. ln_rst_list .AND. nn_stock == -1 ) RETURN ! we will never do any restart 77 77 78 78 ! frequency-based restart dumping (nn_stock) 79 IF( .NOT. ln_rst_list .AND. MOD( kt - 1, nn_stock ) == 0 ) THEN 79 IF( .NOT. ln_rst_list .AND. MOD( kt - 1, nn_stock ) == 0 ) THEN 80 80 ! we use kt - 1 and not kt - nit000 to keep the same periodicity from the beginning of the experiment 81 81 nitrst = kt + nn_stock - 1 ! define the next value of nitrst for restart writing … … 86 86 ! except if we write ocean restart files every time step or if an ocean restart file was writen at nitend - 1 87 87 IF( kt == nitrst - 1 .OR. nn_stock == 1 .OR. ( kt == nitend .AND. .NOT. lrst_oce ) ) THEN 88 IF( nitrst <= nitend .AND. nitrst > 0 ) THEN 88 IF( nitrst <= nitend .AND. nitrst > 0 ) THEN 89 89 ! beware of the format used to write kt (default is i8.8, that should be large enough...) 90 90 IF( nitrst > 999999999 ) THEN ; WRITE(clkt, * ) nitrst … … 110 110 ELSE 111 111 #if defined key_iomput 112 cw xios_context = "rstw_"//TRIM(ADJUSTL(clkt))112 cw_ocerst_cxt = "rstw_"//TRIM(ADJUSTL(clkt)) 113 113 IF( TRIM(Agrif_CFixed()) == '0' ) THEN 114 114 clpname = clname 115 115 ELSE 116 clpname = TRIM(Agrif_CFixed())//"_"//clname 116 clpname = TRIM(Agrif_CFixed())//"_"//clname 117 117 ENDIF 118 CALL iom_init( cwxios_context, TRIM(clpath)//TRIM(clpname), .false.)119 CALL xios_update_calendar(nitrst)118 numrow = iom_xios_setid(TRIM(clpath)//TRIM(clpname)) 119 CALL iom_init( cw_ocerst_cxt, kdid = numrow, ld_closedef = .false. ) 120 120 CALL iom_swap( cxios_context ) 121 121 #else … … 134 134 !!--------------------------------------------------------------------- 135 135 !! *** ROUTINE rstwrite *** 136 !! 136 !! 137 137 !! ** Purpose : Write restart fields in NetCDF format 138 138 !! … … 143 143 INTEGER, INTENT(in) :: Kbb, Kmm ! ocean time level indices 144 144 !!---------------------------------------------------------------------- 145 IF(lwxios) CALL iom_swap( cwxios_context ) 146 CALL iom_rstput( kt, nitrst, numrow, 'rdt' , rn_Dt , ldxios = lwxios) ! dynamics time step 147 CALL iom_delay_rst( 'WRITE', 'OCE', numrow ) ! save only ocean delayed global communication variables 145 CALL iom_rstput( kt, nitrst, numrow, 'rdt' , rn_Dt ) ! dynamics time step 146 IF(.NOT.lwxios) CALL iom_delay_rst( 'WRITE', 'OCE', numrow ) ! save only ocean delayed global communication variables 148 147 149 148 IF ( .NOT. ln_diurnal_only ) THEN 150 CALL iom_rstput( kt, nitrst, numrow, 'ub' , uu(:,:,: ,Kbb) , ldxios = lwxios) ! before fields151 CALL iom_rstput( kt, nitrst, numrow, 'vb' , vv(:,:,: ,Kbb) , ldxios = lwxios)152 CALL iom_rstput( kt, nitrst, numrow, 'tb' , ts(:,:,:,jp_tem,Kbb) , ldxios = lwxios)153 CALL iom_rstput( kt, nitrst, numrow, 'sb' , ts(:,:,:,jp_sal,Kbb) , ldxios = lwxios)154 CALL iom_rstput( kt, nitrst, numrow, 'sshb' , ssh(:,: ,Kbb), ldxios = lwxios)149 CALL iom_rstput( kt, nitrst, numrow, 'ub' , uu(:,:,: ,Kbb) ) ! before fields 150 CALL iom_rstput( kt, nitrst, numrow, 'vb' , vv(:,:,: ,Kbb) ) 151 CALL iom_rstput( kt, nitrst, numrow, 'tb' , ts(:,:,:,jp_tem,Kbb) ) 152 CALL iom_rstput( kt, nitrst, numrow, 'sb' , ts(:,:,:,jp_sal,Kbb) ) 153 CALL iom_rstput( kt, nitrst, numrow, 'sshb' , ssh(:,: ,Kbb)) 155 154 ! 156 CALL iom_rstput( kt, nitrst, numrow, 'un' , uu(:,:,: ,Kmm), ldxios = lwxios ) ! now fields 157 CALL iom_rstput( kt, nitrst, numrow, 'vn' , vv(:,:,: ,Kmm), ldxios = lwxios ) 158 CALL iom_rstput( kt, nitrst, numrow, 'tn' , ts(:,:,:,jp_tem,Kmm), ldxios = lwxios ) 159 CALL iom_rstput( kt, nitrst, numrow, 'sn' , ts(:,:,:,jp_sal,Kmm), ldxios = lwxios ) 160 CALL iom_rstput( kt, nitrst, numrow, 'sshn' ,ssh(:,: ,Kmm), ldxios = lwxios ) 161 CALL iom_rstput( kt, nitrst, numrow, 'rhop' , rhop, ldxios = lwxios ) 162 ENDIF 163 164 IF (ln_diurnal) CALL iom_rstput( kt, nitrst, numrow, 'Dsst', x_dsst, ldxios = lwxios ) 165 IF(lwxios) CALL iom_swap( cxios_context ) 155 CALL iom_rstput( kt, nitrst, numrow, 'un' , uu(:,:,: ,Kmm) ) ! now fields 156 CALL iom_rstput( kt, nitrst, numrow, 'vn' , vv(:,:,: ,Kmm) ) 157 CALL iom_rstput( kt, nitrst, numrow, 'tn' , ts(:,:,:,jp_tem,Kmm) ) 158 CALL iom_rstput( kt, nitrst, numrow, 'sn' , ts(:,:,:,jp_sal,Kmm) ) 159 CALL iom_rstput( kt, nitrst, numrow, 'sshn' , ssh(:,: ,Kmm)) 160 CALL iom_rstput( kt, nitrst, numrow, 'rhop' , rhop ) 161 ENDIF 162 163 IF (ln_diurnal) CALL iom_rstput( kt, nitrst, numrow, 'Dsst', x_dsst ) 166 164 IF( kt == nitrst ) THEN 167 165 IF(.NOT.lwxios) THEN 168 166 CALL iom_close( numrow ) ! close the restart file (only at last time step) 169 167 ELSE 170 CALL iom_context_finalize( cwxios_context ) 168 CALL iom_context_finalize( cw_ocerst_cxt ) 169 iom_file(numrow)%nfid = 0 170 numrow = 0 171 171 ENDIF 172 172 !!gm IF( .NOT. lk_trdmld ) lrst_oce = .FALSE. … … 183 183 184 184 SUBROUTINE rst_read_open 185 !!---------------------------------------------------------------------- 185 !!---------------------------------------------------------------------- 186 186 !! *** ROUTINE rst_read_open *** 187 !! 187 !! 188 188 !! ** Purpose : Open read files for NetCDF restart 189 !! 189 !! 190 190 !! ** Method : Use a non-zero, positive value of numror to assess whether or not 191 191 !! the file has already been opened 192 192 !!---------------------------------------------------------------------- 193 LOGICAL :: llok 194 CHARACTER(lc) :: clpath ! full path to ocean output restart file 193 LOGICAL :: llok 194 CHARACTER(len=lc) :: clpath ! full path to ocean output restart file 195 CHARACTER(len=lc+2) :: clpname ! file name including agrif prefix 195 196 !!---------------------------------------------------------------------- 196 197 ! … … 209 210 ! can handle checking if variable is in the restart file (there will be no need to open 210 211 ! restart) 211 IF(.NOT.lxios_set) lrxios = lrxios.AND.lxios_sini 212 lrxios = lrxios.AND.lxios_sini 213 212 214 IF( lrxios) THEN 213 crxios_context = 'nemo_rst' 214 IF( .NOT.lxios_set ) THEN 215 IF(lwp) WRITE(numout,*) 'Enable restart reading by XIOS' 216 CALL iom_init( crxios_context ) 217 lxios_set = .TRUE. 218 ENDIF 219 ENDIF 220 IF( TRIM(Agrif_CFixed()) /= '0' .AND. lrxios) THEN 221 CALL iom_init( crxios_context ) 222 IF(lwp) WRITE(numout,*) 'Enable restart reading by XIOS for AGRIF' 223 lxios_set = .TRUE. 224 ENDIF 215 cr_ocerst_cxt = 'oce_rst' 216 IF(lwp) WRITE(numout,*) 'Enable restart reading by XIOS' 217 ! IF( TRIM(Agrif_CFixed()) == '0' ) THEN 218 ! clpname = cn_ocerst_in 219 ! ELSE 220 ! clpname = TRIM(Agrif_CFixed())//"_"//cn_ocerst_in 221 ! ENDIF 222 CALL iom_init( cr_ocerst_cxt, kdid = numror, ld_closedef = .TRUE. ) 223 CALL iom_swap( cxios_context ) 224 ENDIF 225 225 226 ENDIF 226 227 … … 229 230 230 231 SUBROUTINE rst_read( Kbb, Kmm ) 231 !!---------------------------------------------------------------------- 232 !!---------------------------------------------------------------------- 232 233 !! *** ROUTINE rst_read *** 233 !! 234 !! 234 235 !! ** Purpose : Read files for NetCDF restart 235 !! 236 !! 236 237 !! ** Method : Read in restart.nc file fields which are necessary for restart 237 238 !!---------------------------------------------------------------------- … … 246 247 ! Check dynamics and tracer time-step consistency and force Euler restart if changed 247 248 IF( iom_varid( numror, 'rdt', ldstop = .FALSE. ) > 0 ) THEN 248 CALL iom_get( numror, 'rdt', zrdt , ldxios = lrxios)249 CALL iom_get( numror, 'rdt', zrdt ) 249 250 IF( zrdt /= rn_Dt ) THEN 250 251 IF(lwp) WRITE( numout,*) … … 256 257 ENDIF 257 258 258 CALL iom_delay_rst( 'READ', 'OCE', numror ) ! read only ocean delayed global communication variables259 260 ! Diurnal DSST 261 IF( ln_diurnal ) CALL iom_get( numror, jpdom_auto, 'Dsst' , x_dsst , ldxios = lrxios )262 IF ( ln_diurnal_only ) THEN 259 IF(.NOT.lrxios ) CALL iom_delay_rst( 'READ', 'OCE', numror ) ! read only ocean delayed global communication variables 260 261 ! Diurnal DSST 262 IF( ln_diurnal ) CALL iom_get( numror, jpdom_auto, 'Dsst' , x_dsst ) 263 IF ( ln_diurnal_only ) THEN 263 264 IF(lwp) WRITE( numout, * ) & 264 & "rst_read:- ln_diurnal_only set, setting rhop=rho0" 265 & "rst_read:- ln_diurnal_only set, setting rhop=rho0" 265 266 rhop = rho0 266 CALL iom_get( numror, jpdom_auto, 'tn' , w3d , ldxios = lrxios )267 CALL iom_get( numror, jpdom_auto, 'tn' , w3d ) 267 268 ts(:,:,1,jp_tem,Kmm) = w3d(:,:,1) 268 RETURN 269 ENDIF 270 269 RETURN 270 ENDIF 271 271 272 IF( iom_varid( numror, 'ub', ldstop = .FALSE. ) > 0 ) THEN 272 273 ! before fields 273 CALL iom_get( numror, jpdom_auto, 'ub' , uu(:,:,: ,Kbb), ldxios = lrxios,cd_type = 'U', psgn = -1._wp )274 CALL iom_get( numror, jpdom_auto, 'vb' , vv(:,:,: ,Kbb), ldxios = lrxios,cd_type = 'V', psgn = -1._wp )275 CALL iom_get( numror, jpdom_auto, 'tb' , ts(:,:,:,jp_tem,Kbb) , ldxios = lrxios)276 CALL iom_get( numror, jpdom_auto, 'sb' , ts(:,:,:,jp_sal,Kbb) , ldxios = lrxios)277 CALL iom_get( numror, jpdom_auto, 'sshb' ,ssh(:,: ,Kbb) , ldxios = lrxios)274 CALL iom_get( numror, jpdom_auto, 'ub' , uu(:,:,: ,Kbb), cd_type = 'U', psgn = -1._wp ) 275 CALL iom_get( numror, jpdom_auto, 'vb' , vv(:,:,: ,Kbb), cd_type = 'V', psgn = -1._wp ) 276 CALL iom_get( numror, jpdom_auto, 'tb' , ts(:,:,:,jp_tem,Kbb) ) 277 CALL iom_get( numror, jpdom_auto, 'sb' , ts(:,:,:,jp_sal,Kbb) ) 278 CALL iom_get( numror, jpdom_auto, 'sshb' ,ssh(:,: ,Kbb) ) 278 279 ELSE 279 280 l_1st_euler = .TRUE. ! before field not found, forced euler 1st time-step … … 281 282 ! 282 283 ! now fields 283 CALL iom_get( numror, jpdom_auto, 'un' , uu(:,:,: ,Kmm), ldxios = lrxios,cd_type = 'U', psgn = -1._wp )284 CALL iom_get( numror, jpdom_auto, 'vn' , vv(:,:,: ,Kmm), ldxios = lrxios,cd_type = 'V', psgn = -1._wp )285 CALL iom_get( numror, jpdom_auto, 'tn' , ts(:,:,:,jp_tem,Kmm) , ldxios = lrxios)286 CALL iom_get( numror, jpdom_auto, 'sn' , ts(:,:,:,jp_sal,Kmm) , ldxios = lrxios)287 CALL iom_get( numror, jpdom_auto, 'sshn' ,ssh(:,: ,Kmm) , ldxios = lrxios)284 CALL iom_get( numror, jpdom_auto, 'un' , uu(:,:,: ,Kmm), cd_type = 'U', psgn = -1._wp ) 285 CALL iom_get( numror, jpdom_auto, 'vn' , vv(:,:,: ,Kmm), cd_type = 'V', psgn = -1._wp ) 286 CALL iom_get( numror, jpdom_auto, 'tn' , ts(:,:,:,jp_tem,Kmm) ) 287 CALL iom_get( numror, jpdom_auto, 'sn' , ts(:,:,:,jp_sal,Kmm) ) 288 CALL iom_get( numror, jpdom_auto, 'sshn' ,ssh(:,: ,Kmm) ) 288 289 IF( iom_varid( numror, 'rhop', ldstop = .FALSE. ) > 0 ) THEN 289 CALL iom_get( numror, jpdom_auto, 'rhop' , rhop , ldxios = lrxios) ! now potential density290 CALL iom_get( numror, jpdom_auto, 'rhop' , rhop ) ! now potential density 290 291 ELSE 291 CALL eos( ts(:,:,:,:,Kmm), rhd, rhop, gdept(:,:,:,Kmm) ) 292 ENDIF 293 ! 294 IF( l_1st_euler ) THEN ! Euler restart 292 CALL eos( ts(:,:,:,:,Kmm), rhd, rhop, gdept(:,:,:,Kmm) ) 293 ENDIF 294 ! 295 IF( l_1st_euler ) THEN ! Euler restart 295 296 ts (:,:,:,:,Kbb) = ts (:,:,:,:,Kmm) ! all before fields set to now values 296 297 uu (:,:,: ,Kbb) = uu (:,:,: ,Kmm)
Note: See TracChangeset
for help on using the changeset viewer.