- Timestamp:
- 2019-04-05T16:01:32+02:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
NEMO/branches/UKMO/dev_r10037_GPU/src/OCE/ICB/icbrst.F90
r9950 r10843 25 25 USE netcdf ! netcdf routines for IO 26 26 USE iom 27 USE ioipsl, ONLY : ju2ymds ! for calendar 27 28 USE icb_oce ! define iceberg arrays 28 29 USE icbutl ! iceberg utility routines … … 46 47 !! NEMO/OCE 4.0 , NEMO Consortium (2018) 47 48 !! $Id$ 48 !! Software governed by the CeCILL licen ce (./LICENSE)49 !! Software governed by the CeCILL license (see ./LICENSE) 49 50 !!---------------------------------------------------------------------- 50 51 CONTAINS … … 60 61 INTEGER :: idim, ivar, iatt 61 62 INTEGER :: jn, iunlim_dim, ibergs_in_file 62 INTEGER :: ii, ij,iclass63 INTEGER :: ii, ij, iclass, ibase_err, imax_icb 63 64 REAL(wp), DIMENSION(nkounts) :: zdata 64 65 LOGICAL :: ll_found_restart … … 77 78 CALL iom_open( TRIM(cl_path)//cl_filename, ncid ) 78 79 80 imax_icb = 0 79 81 IF( iom_file(ncid)%iduld .GE. 0) THEN 80 82 … … 96 98 CALL iom_get( ncid, jpdom_unknown, 'number' , zdata(:) , ktime=jn, kstart=(/1/), kcount=(/nkounts/) ) 97 99 localberg%number(:) = INT(zdata(:)) 100 imax_icb = MAX( imax_icb, INT(zdata(1)) ) 98 101 CALL iom_get( ncid, 'mass_scaling' , localberg%mass_scaling, ktime=jn ) 99 102 CALL iom_get( ncid, 'lon' , localpt%lon , ktime=jn ) … … 129 132 CALL iom_get( ncid, jpdom_unknown, 'kount' , zdata(:) ) 130 133 num_bergs(:) = INT(zdata(:)) 131 132 ! Sanity check 134 ! Close file 135 CALL iom_close( ncid ) 136 ! 137 138 ! Sanity checks 133 139 jn = icb_utl_count() 134 140 IF ( lwp .AND. nn_verbose_level >= 0 ) & … … 142 148 & ' bergs in the restart file and', jn,' bergs have been read' 143 149 ! 144 ! Finish up 145 CALL iom_close( ncid ) 150 ! Confirm that all areas have a suitable base for assigning new iceberg 151 ! numbers. This will not be the case if restarting from a collated dataset 152 ! (even if using the same processor decomposition) 153 ! 154 ibase_err = 0 155 IF( num_bergs(1) < 0 .AND. num_bergs(1) /= narea - jpnij ) THEN 156 ! If this area has never calved a new berg then the base should be 157 ! set to narea - jpnij. If it is negative but something else then 158 ! a new base will be needed to guarantee unique, future iceberg numbers 159 ibase_err = 1 160 ELSEIF( MOD( num_bergs(1) - narea , jpnij ) /= 0 ) THEN 161 ! If this area has a base which is not in the set {narea + N*jpnij} 162 ! for positive integers N then a new base will be needed to guarantee 163 ! unique, future iceberg numbers 164 ibase_err = 1 165 ENDIF 166 IF( lk_mpp ) THEN 167 CALL mpp_sum(ibase_err) 168 ENDIF 169 IF( ibase_err > 0 ) THEN 170 ! 171 ! A new base is needed. The only secure solution is to set bases such that 172 ! all future icebergs numbers will be greater than the current global maximum 173 IF( lk_mpp ) THEN 174 CALL mpp_max(imax_icb) 175 ENDIF 176 num_bergs(1) = imax_icb - jpnij + narea 177 ENDIF 146 178 ! 147 179 IF( lwp .AND. nn_verbose_level >= 0 ) WRITE(numout,'(a)') 'icebergs, icb_rst_read: completed' … … 159 191 INTEGER :: jn ! dummy loop index 160 192 INTEGER :: ix_dim, iy_dim, ik_dim, in_dim 161 CHARACTER(len=256) :: cl_path 162 CHARACTER(len=256) :: cl_filename 193 INTEGER :: iyear, imonth, iday 194 REAL (wp) :: zsec 195 REAL (wp) :: zfjulday 196 CHARACTER(len=256) :: cl_path 197 CHARACTER(len=256) :: cl_filename 198 CHARACTER(LEN=20) :: clkt ! ocean time-step deine as a character 163 199 TYPE(iceberg), POINTER :: this 164 200 TYPE(point) , POINTER :: pt … … 175 211 cl_path = TRIM(cn_ocerst_outdir) 176 212 IF( cl_path(LEN_TRIM(cl_path):) /= '/' ) cl_path = TRIM(cl_path) // '/' 213 IF ( ln_rstdate ) THEN 214 zfjulday = fjulday + rdt / rday 215 IF( ABS(zfjulday - REAL(NINT(zfjulday),wp)) < 0.1 / rday ) zfjulday = REAL(NINT(zfjulday),wp) ! avoid truncation error 216 CALL ju2ymds( zfjulday, iyear, imonth, iday, zsec ) 217 WRITE(clkt, '(i4.4,2i2.2)') iyear, imonth, iday 218 ELSE 219 IF( kt > 999999999 ) THEN ; WRITE(clkt, * ) kt 220 ELSE ; WRITE(clkt, '(i8.8)') kt 221 ENDIF 222 ENDIF 177 223 IF( lk_mpp ) THEN 178 WRITE(cl_filename,'(A,"_icebergs_", I8.8,"_restart_",I4.4,".nc")') TRIM(cexper), kt, narea-1224 WRITE(cl_filename,'(A,"_icebergs_",A,"_restart_",I4.4,".nc")') TRIM(cexper), TRIM(ADJUSTL(clkt)), narea-1 179 225 ELSE 180 WRITE(cl_filename,'(A,"_icebergs_", I8.8,"_restart.nc")') TRIM(cexper), kt226 WRITE(cl_filename,'(A,"_icebergs_",A,"_restart.nc")') TRIM(cexper), TRIM(ADJUSTL(clkt)) 181 227 ENDIF 182 228 IF ( lwp .AND. nn_verbose_level >= 0) WRITE(numout,'(2a)') 'icebergs, write_restart: creating ', &
Note: See TracChangeset
for help on using the changeset viewer.