Changeset 10338
- Timestamp:
- 2018-11-19T17:40:09+01:00 (6 years ago)
- Location:
- utils/tools/REBUILD_NEMO
- Files:
-
- 3 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
utils/tools/REBUILD_NEMO/rebuild_nemo
r9048 r10338 10 10 echo " ************" 11 11 echo 12 echo " usage: ${0##*/} [-l - t -c -m -n] filebase ndomain [rebuild dimensions]"12 echo " usage: ${0##*/} [-l -p -s -m -n -r -d -x -y -z -t -c] filebase ndomain [rebuild dimensions]" 13 13 echo 14 echo " flags: -l 15 echo " - tnum use num threads"16 echo " - c num split 4D vars into time chuncksof size num"14 echo " flags: -l arch submit to compute node" 15 echo " -p num use num threads" 16 echo " -s num split 4D vars into time slice of size num" 17 17 echo " -m force masking of global arrays (zero if no mdi)" 18 echo " -d deflate_level deflate level for output files (key_netcdf4 only)"19 18 echo " -n namelist full path to namelist file to be created (otherwise default nam_rebuild+_process_id is used)" 20 19 echo " -r memory Memory to request on compute node including units (Default = 10Gb)" 20 echo "" 21 echo " key_netcdf4 only " 22 echo " -d deflate_level deflate level for output files" 23 echo " -x chunksize along x " 24 echo " -y chunksize along y " 25 echo " -z chunksize along z " 26 echo " -t chunksize along t " 27 echo " -c total size of the chunk cache " 21 28 echo 22 29 exit 1 23 30 } 24 31 25 while getopts c:n:t:d:r:lm opt32 while getopts l:p:s:n:r:d:x:y:z:t:c:m opt 26 33 do 27 34 case ${opt} in 28 35 l) 29 36 BATCH="yes" 30 BATCH_CMD="qsub" 31 ARCH="XC40_METO" 32 echo "Submitting job to compute node" 37 ARCH=${OPTARG} 33 38 ;; 34 t)39 p) 35 40 OMP_NUM_THREADS=${OPTARG} 36 41 ;; 37 c)38 N CHUNKSIZE=${OPTARG}42 s) 43 NSLICESIZE=${OPTARG} 39 44 ;; 40 45 m) 41 46 NMASK="TRUE" 42 echo "mask" 47 echo "" 48 echo "output is mask using netcdf missing value (_Fillvalue attribute) or 0 if missing value not in the netcdf." 49 echo "" 43 50 ;; 44 51 d) … … 50 57 r) 51 58 MEMORY=${OPTARG} 59 ;; 60 x) 61 NXCHUNK=${OPTARG} 62 ;; 63 y) 64 NYCHUNK=${OPTARG} 65 ;; 66 z) 67 NZCHUNK=${OPTARG} 68 ;; 69 t) 70 NTCHUNK=${OPTARG} 71 ;; 72 c) 73 CHUNKSIZE=${OPTARG} 52 74 ;; 53 75 esac … … 72 94 nopen=$(ulimit -n) 73 95 if [[ $ndomain -gt $nopen ]] ; then 74 nopen=$((ndomain+ 2))96 nopen=$((ndomain+4)) # +2 failed !!! 75 97 fi 76 98 … … 90 112 echo ${dims} >> $nam_rebuild 91 113 fi 92 if [[ -n ${NC HUNKSIZE} ]] ; then93 echo " n chunksize=${NCHUNKSIZE}" >> $nam_rebuild114 if [[ -n ${NCSLICESIZE} ]] ; then 115 echo " nslicesize=${NCSLICESIZE}" >> $nam_rebuild 94 116 fi 95 117 if [[ -n ${NMASK} ]] ; then … … 99 121 echo " deflate_level=${DEFLATE}" >> $nam_rebuild 100 122 fi 123 if [[ -n ${NXCHUNK} ]] ; then 124 echo " nc4_xchunk=${NXCHUNK}" >> $nam_rebuild 125 fi 126 if [[ -n ${NYCHUNK} ]] ; then 127 echo " nc4_ychunk=${NYCHUNK}" >> $nam_rebuild 128 fi 129 if [[ -n ${NZCHUNK} ]] ; then 130 echo " nc4_zchunk=${NZCHUNK}" >> $nam_rebuild 131 fi 132 if [[ -n ${NTCHUNK} ]] ; then 133 echo " nc4_tchunk=${NTCHUNK}" >> $nam_rebuild 134 fi 135 if [[ -n ${CHUNKSIZE} ]] ; then 136 echo " fchunksize=${CHUNKSIZE}" >> $nam_rebuild 137 fi 138 139 101 140 102 141 echo "/" >> $nam_rebuild 103 142 104 143 if [[ ${BATCH} == "yes" ]] ; then 144 145 template_dir=${script_dir}/BATCH_TEMPLATES/ 146 param_file=${template_dir}/param_${ARCH} 147 if [ ! -f $param_file ]; then 148 echo '' 149 echo "E R R O R: $param_file is missing, stop 42" 150 echo '' 151 echo "check your arch name or add one $param_file file in BATCH_TEMPLATES" 152 echo '' 153 exit 42 154 fi 155 . $param_file 156 105 157 batch_file=rebuild_nemo_batch_${ARCH} 158 if [ ! -f ${template_dir}/${batch_file} ]; then 159 echo '' 160 echo "E R R O R: $batch_file is missing, stop 42" 161 echo '' 162 echo "check your arch name or add one $batch_file file in BATCH_TEMPLATES" 163 echo '' 164 exit 42 165 fi 106 166 107 167 #Create a modified local copy of the batch submission file 108 168 #The process ID is appended to the end of the file name so it is unique 109 cat ${ script_dir}/BATCH_TEMPLATES/${batch_file} | sed -e"s/NTHREADS/${OMP_NUM_THREADS}/" \169 cat ${template_dir}/${batch_file} | sed -e"s/NTHREADS/${OMP_NUM_THREADS}/" \ 110 170 -e"s/MEMORY/${MEMORY}/" \ 111 171 -e"s:INDIR:${script_dir}:" \ … … 114 174 115 175 #Submit the job 176 echo "Submitting job to compute node" 116 177 $BATCH_CMD ${batch_file}_$$.sh 117 178 -
utils/tools/REBUILD_NEMO/src/rebuild_nemo.F90
r9048 r10338 1 1 PROGRAM rebuild_nemo 2 2 #define key_netcdf4 3 3 !!========================================================================= 4 4 !! *** rebuild_nemo *** … … 14 14 !! * works for 1,2,3 and 4d arrays or types for all valid NetCDF types 15 15 !! * utilises OMP shared memory parallelisation where applicable 16 !! * time ' chunking' for lower memory use16 !! * time 'slicing' for lower memory use 17 17 !! (only for 4D vars with unlimited dimension) 18 18 !! 19 19 !! Ed Blockley - August 2011 20 20 !! (based on original code by Matt Martin) 21 !! Julien Palmieri and Andrew Coward - September 2018 (add compression and chunking) 21 22 !! 22 23 !!------------------------------------------------------------------------- … … 38 39 !! and errors are written to numerr (default 0 - stderr). 39 40 !! 40 !! If time chunking is specified the code will use less memory but take a little longer.41 !! If time slicing is specified the code will use less memory but take a little longer. 41 42 !! It does this by breaking down the 4D input variables over their 4th dimension 42 43 !! (generally time) by way of a while loop. … … 66 67 CHARACTER(LEN=nf90_max_name), ALLOCATABLE :: filenames(:), indimnames(:) 67 68 CHARACTER(LEN=nf90_max_name), DIMENSION(2) :: dims 68 69 INTEGER :: ndomain, ifile, ndomain_file, nchunksize, deflate_level 69 CHARACTER(LEN=256) :: cnampath, cdimlst, cdim 70 CHARACTER(LEN=50) :: clibnc ! netcdf library version 71 72 INTEGER :: ndomain, ifile, ndomain_file, nslicesize, deflate_level 70 73 INTEGER :: ncid, outid, idim, istop 71 74 INTEGER :: natts, attid, xtype, varid, rbdims 72 75 INTEGER :: jv, ndims, nvars, dimlen, dimids(4) 73 76 INTEGER :: dimid, unlimitedDimId, di, dj, dr 74 INTEGER :: nmax_unlimited, nt, ntchunk 75 INTEGER :: chunksize = 3200000 77 INTEGER :: nmax_unlimited, nt, ntslice 78 INTEGER :: fchunksize = 32000000 ! NetCDF global file chunk cache size 79 INTEGER :: patchchunk ! NetCDF processor-domain file chunk cache size 76 80 INTEGER :: nthreads = 1 81 INTEGER :: chunkalg = 0 ! NetCDF4 variable chunking algorithm 82 ! Default variable chunksizes (typical ORCA025 83 ! recommendations which can be adjusted via namelist 84 ! or will be bounded if too large for domain.) 85 INTEGER :: nc4_xchunk = 206 ! Default x (longitude) variable chunk size 86 INTEGER :: nc4_ychunk = 135 ! Default y (latitude) variable chunk size 87 INTEGER :: nc4_zchunk = 1 ! Default z (depth) variable chunk size (almost always 1) 88 INTEGER :: nc4_tchunk = 1 ! Default t (time) variable chunk size (almost always 1) 77 89 INTEGER, ALLOCATABLE :: outdimids(:), outdimlens(:), indimlens(:), inncids(:) 90 INTEGER, ALLOCATABLE :: chunksizes(:) 78 91 INTEGER, ALLOCATABLE :: global_sizes(:), rebuild_dims(:) 79 92 INTEGER, DIMENSION(2) :: halo_start, halo_end, local_sizes 80 93 INTEGER, DIMENSION(2) :: idomain, jdomain, rdomain, start_pos 81 94 INTEGER :: ji, jj, jk, jl, jr 95 INTEGER :: nargs ! number of arguments 96 INTEGER, EXTERNAL :: iargc 82 97 83 98 REAL(sp) :: ValMin, ValMax, InMin, InMax, rmdi … … 149 164 REAL(dp), ALLOCATABLE, DIMENSION(:,:,:,:) :: globaldata_4d_dp 150 165 151 LOGICAL :: l_valid = .false.166 LOGICAL :: l_valid = .false. 152 167 LOGICAL :: l_noRebuild = .false. 153 LOGICAL :: l_findDims = .true. 154 LOGICAL :: l_maskout = .false. 155 156 NAMELIST/nam_rebuild/ filebase, ndomain, dims, nchunksize, l_maskout, deflate_level 168 LOGICAL :: l_findDims = .true. 169 LOGICAL :: l_maskout = .false. 170 LOGICAL :: l_namexist = .false. 171 172 NAMELIST/nam_rebuild/ filebase, ndomain, dims, nslicesize, l_maskout, deflate_level, & 173 & nc4_xchunk, nc4_ychunk, nc4_zchunk, nc4_tchunk, fchunksize 157 174 158 175 external :: getarg 159 integer, external :: iargc160 integer :: found_num_args = 0161 character(256) :: namelist_path162 176 163 177 !End of definitions … … 174 188 175 189 !-------------------------------------------------------------------------------- 190 !1.0 Check netcdf version for warning 191 clibnc = TRIM(nf90_inq_libvers()) 192 IF (ICHAR(clibnc(1:1)) <= 3) THEN 193 PRINT *, '==========================================================' 194 PRINT *, 'You are using old netcdf library (',TRIM(clibnc),').' 195 PRINT *, 'REBUILD_NEMO support of old netcdf library will end soon' 196 PRINT *, 'please consider moving to netcdf 4 or higher' 197 PRINT *, '==========================================================' 198 END IF 199 176 200 !1.1 Get the namelist path 177 !Determine the number of arguments on the command line 178 found_num_args=iargc() 179 !Check that the required argument is present, if it is not then set it to the default value: nam_rebuild 180 IF (found_num_args <= 0) THEN 181 WRITE(numout,*) 'Namelist path not supplied as command line argument. Using default, nam_rebuild.' 182 namelist_path='nam_rebuild' 183 ELSE IF (found_num_args == 1) THEN 184 CALL getarg(1, namelist_path) 185 ELSE 186 WRITE(numerr,*) 'ERROR! : Incorrect number of command line arguments. Please supply only' 187 WRITE(numerr,*) ' the path to the namelist file, or no arguments to use default value' 188 STOP 1 189 END IF 201 !Determine the number of arguments on the command line 202 nargs=iargc() 203 !Check that the required argument is present, if it is not then set it to the default value: nam_rebuild 204 IF (nargs == 0) THEN 205 WRITE(numout,*) 206 WRITE(numout,*) 'W A R N I N G : Namelist path not supplied as command line argument. Using default, nam_rebuild.' 207 cnampath='nam_rebuild' 208 ELSE IF (nargs == 1) THEN 209 CALL getarg(1, cnampath) 210 ELSE 211 WRITE(numerr,*) 'E R R O R ! : Incorrect number of command line arguments. Please supply only' 212 WRITE(numerr,*) ' the path to the namelist file, or no arguments to use default value' 213 STOP 1 214 END IF 215 216 ! check presence of namelist 217 INQUIRE(FILE=cnampath, EXIST=l_namexist) 218 IF (.NOT. l_namexist) THEN 219 WRITE(numout,*) 220 WRITE(numout,*) 'E R R O R : Namelist '//TRIM(cnampath)//' not present.' 221 STOP 42 222 END IF 190 223 191 224 !1.2 Read in the namelist 192 225 193 226 dims(:) = "" 194 n chunksize = 0227 nslicesize = 0 195 228 deflate_level = 0 196 OPEN( UNIT=numnam, FILE=TRIM( namelist_path), FORM='FORMATTED', STATUS='OLD' )229 OPEN( UNIT=numnam, FILE=TRIM(cnampath), FORM='FORMATTED', STATUS='OLD' ) 197 230 READ( numnam, nam_rebuild ) 198 231 CLOSE( numnam ) 199 232 IF( .NOT. ALL(dims(:) == "") ) l_findDims = .false. 200 201 !1. 1Set up the filenames and fileids233 234 !1.3 Set up the filenames and fileids 202 235 203 236 ALLOCATE(filenames(ndomain)) … … 227 260 228 261 !2.1 Set up the output file 229 !#if defined key_netcdf4230 CALL check_nf90( nf90_create( TRIM(filebase)//'.nc', nf90_netcdf4, outid, chunksize= chunksize ) )231 !#else232 ! CALL check_nf90( nf90_create( TRIM(filebase)//'.nc', nf90_64bit_offset, outid, chunksize=chunksize ) )233 !#endif262 #if defined key_netcdf4 263 CALL check_nf90( nf90_create( TRIM(filebase)//'.nc', nf90_netcdf4, outid, chunksize=fchunksize ) ) 264 #else 265 CALL check_nf90( nf90_create( TRIM(filebase)//'.nc', nf90_64bit_offset, outid, chunksize=fchunksize ) ) 266 #endif 234 267 235 268 !2.2 Set up dimensions in output file … … 291 324 outdimlens(idim) = dimlen 292 325 END DO 293 ! nmax_unlimited is only used for time- chunking so we set it to be at least 1 to326 ! nmax_unlimited is only used for time-slicing so we set it to be at least 1 to 294 327 ! account for files with no record dimension or zero length record dimension(!) 295 328 nmax_unlimited = max(nmax_unlimited,1) … … 340 373 CALL check_nf90( nf90_inquire_variable( ncid, jv, varname, xtype, ndims, dimids, natts ) ) 341 374 ALLOCATE(outdimids(ndims)) 342 DO idim = 1, ndims 343 outdimids(idim) = dimids(idim) 344 END DO 375 ALLOCATE(chunksizes(ndims)) 376 IF( ndims > 0 ) then 377 DO idim = 1, ndims 378 outdimids(idim) = dimids(idim) 379 chunksizes(idim) = outdimlens(dimids(idim)) 380 cdim='|'//TRIM(indimnames(dimids(idim)))//'|' 381 382 ! trick to find var in a list of suggestion (var0 and var1 : INDEX(|var0|var1|,|var|) 383 cdimlst='|x|x_grid_T|x_grid_U|x_grid_V|x_grid_W|' 384 if( INDEX(TRIM(cdimlst),TRIM(cdim)) > 0 ) & 385 & chunksizes(idim) = min(outdimlens(dimids(idim)), max(nc4_xchunk,1)) 386 387 cdimlst='|y|y_grid_T|y_grid_U|y_grid_V|y_grid_W|' 388 if( INDEX(TRIM(cdimlst),TRIM(cdim)) > 0 ) & 389 & chunksizes(idim) = min(outdimlens(dimids(idim)), max(nc4_ychunk,1)) 390 391 cdimlst='|z|deptht|depthu|depthv|depthw|depth|nav_lev|' 392 if( INDEX(TRIM(cdimlst),TRIM(cdim)) > 0 ) & 393 & chunksizes(idim) = min(outdimlens(dimids(idim)), max(nc4_zchunk,1)) 394 395 cdimlst='|t|time|time_counter|' 396 if( INDEX(TRIM(cdimlst),TRIM(cdim)) > 0 ) & 397 & chunksizes(idim) = min(outdimlens(dimids(idim)), max(nc4_tchunk,1)) 398 399 END DO 345 400 #if defined key_netcdf4 346 CALL check_nf90( nf90_def_var( outid, varname, xtype, outdimids, varid, & 347 deflate_level=deflate_level ) ) 401 CALL check_nf90( nf90_def_var( outid, varname, xtype, outdimids, varid, & 402 deflate_level=deflate_level ) ) 403 IF (l_verbose) WRITE(numout,*) 'Dims : ',ndims, outdimids(1:ndims) 404 IF (l_verbose) WRITE(numout,*) 'names : ',(TRIM(indimnames(dimids(idim)))//' ',idim=1,ndims) 405 IF (l_verbose) WRITE(numout,*) 'lens : ',(outdimlens(dimids(idim)),idim=1,ndims) 406 IF (l_verbose) WRITE(numout,*) 'Chunking: ',chunksizes 407 IF (l_verbose) WRITE(numout,*) 'Deflation : ',deflate_level 408 IF (l_verbose) WRITE(numout,*) 'Chunk algo: ',chunkalg 409 CALL check_nf90( nf90_def_var_chunking( outid, varid, chunkalg, & 410 & chunksizes ) ) 411 ELSE 412 CALL check_nf90( nf90_def_var( outid, varname, xtype, outdimids, varid ) ) 348 413 #else 349 414 CALL check_nf90( nf90_def_var( outid, varname, xtype, outdimids, varid ) ) 350 415 #endif 416 ENDIF 351 417 DEALLOCATE(outdimids) 418 DEALLOCATE(chunksizes) 352 419 IF (l_verbose) WRITE(numout,*) 'Defining variable '//TRIM(varname)//'...' 353 420 IF( natts > 0 ) THEN … … 375 442 376 443 IF (l_verbose) WRITE(numout,*) 'Opening input files...' 444 445 ! Set a file chunk cache size for the processor-domain files that scales with the number of processors 446 patchchunk = max(8192, fchunksize/ndomain) 447 448 ! open files 377 449 DO ifile = 2, ndomain 378 CALL check_nf90( nf90_open( TRIM(filenames(ifile)), nf90_share, ncid, chunksize= chunksize) )450 CALL check_nf90( nf90_open( TRIM(filenames(ifile)), nf90_share, ncid, chunksize=patchchunk ) ) 379 451 inncids(ifile) = ncid 380 452 END DO … … 388 460 istop = nf90_noerr 389 461 nt = 1 390 nt chunk= nmax_unlimited391 IF( n chunksize == 0 ) nchunksize = nmax_unlimited462 ntslice = nmax_unlimited 463 IF( nslicesize == 0 ) nslicesize = nmax_unlimited 392 464 393 465 !3.2 Inquire variable to find out name and how many dimensions it has … … 403 475 ENDIF 404 476 405 !3.2.0 start while loop for time chunking477 !3.2.0 start while loop for time slicing 406 478 407 479 DO WHILE( nt <= nmax_unlimited ) 408 480 409 481 IF( ndims > 3 ) THEN 410 nt chunk = MIN( nchunksize, nmax_unlimited + 1 - nt )482 ntslice = MIN( nslicesize, nmax_unlimited + 1 - nt ) 411 483 ENDIF 412 484 413 485 IF (l_noRebuild) THEN 414 486 415 IF( n chunksize == nmax_unlimited .OR. ndims <= 3 ) THEN487 IF( nslicesize == nmax_unlimited .OR. ndims <= 3 ) THEN 416 488 IF (l_verbose) WRITE(numout,*) 'Copying data from variable '//TRIM(varname)//'...' 417 489 ELSE 418 490 IF (l_verbose) WRITE(numout,'(A,I3,A,I3,A)') ' Copying data from variable ' & 419 & //TRIM(varname)//' for chunks ',nt,' to ',nt+ntchunk-1,' ...'491 & //TRIM(varname)//' for slices ',nt,' to ',nt+ntslice-1,' ...' 420 492 ENDIF 421 493 … … 519 591 CASE( NF90_BYTE ) 520 592 ALLOCATE(globaldata_4d_i1(indimlens(dimids(1)),indimlens(dimids(2)), & 521 & indimlens(dimids(3)),nt chunk))593 & indimlens(dimids(3)),ntslice)) 522 594 CALL check_nf90( nf90_get_var( ncid, jv, globaldata_4d_i1, start=(/1,1,1,nt/) ) ) 523 595 CASE( NF90_SHORT ) 524 596 ALLOCATE(globaldata_4d_i2(indimlens(dimids(1)),indimlens(dimids(2)), & 525 & indimlens(dimids(3)),nt chunk))597 & indimlens(dimids(3)),ntslice)) 526 598 CALL check_nf90( nf90_get_var( ncid, jv, globaldata_4d_i2, start=(/1,1,1,nt/) ) ) 527 599 CASE( NF90_INT ) 528 600 ALLOCATE(globaldata_4d_i4(indimlens(dimids(1)),indimlens(dimids(2)), & 529 & indimlens(dimids(3)),nt chunk))601 & indimlens(dimids(3)),ntslice)) 530 602 CALL check_nf90( nf90_get_var( ncid, jv, globaldata_4d_i4, start=(/1,1,1,nt/) ) ) 531 603 CASE( NF90_FLOAT ) 532 604 ALLOCATE(globaldata_4d_sp(indimlens(dimids(1)),indimlens(dimids(2)), & 533 & indimlens(dimids(3)),nt chunk))605 & indimlens(dimids(3)),ntslice)) 534 606 CALL check_nf90( nf90_get_var( ncid, jv, globaldata_4d_sp, start=(/1,1,1,nt/) ) ) 535 607 CASE( NF90_DOUBLE ) 536 608 ALLOCATE(globaldata_4d_dp(indimlens(dimids(1)),indimlens(dimids(2)), & 537 & indimlens(dimids(3)),nt chunk))609 & indimlens(dimids(3)),ntslice)) 538 610 CALL check_nf90( nf90_get_var( ncid, jv, globaldata_4d_dp, start=(/1,1,1,nt/) ) ) 539 611 CASE DEFAULT … … 548 620 !3.2.2 For variables that require rebuilding we need to read in from all ndomain files 549 621 ! Here we allocate global variables ahead of looping over files 550 IF( n chunksize == nmax_unlimited .OR. ndims <= 3 ) THEN622 IF( nslicesize == nmax_unlimited .OR. ndims <= 3 ) THEN 551 623 IF (l_verbose) WRITE(numout,*) 'Rebuilding data from variable '//TRIM(varname)//'...' 552 624 ELSE 553 625 IF (l_verbose) WRITE(numout,'(A,I3,A,I3,A)') ' Rebuilding data from variable ' & 554 & //TRIM(varname)//' for chunks ',nt,' to ',nt+ntchunk-1,' ...'626 & //TRIM(varname)//' for slices ',nt,' to ',nt+ntslice-1,' ...' 555 627 ENDIF 556 628 IF( ndims == 1 ) THEN … … 633 705 CASE( NF90_BYTE ) 634 706 ALLOCATE(globaldata_4d_i1(outdimlens(dimids(1)),outdimlens(dimids(2)), & 635 & outdimlens(dimids(3)),nt chunk))707 & outdimlens(dimids(3)),ntslice)) 636 708 IF (l_maskout) globaldata_4d_i1(:,:,:,:)=mdiVals(jv) 637 709 CASE( NF90_SHORT ) 638 710 ALLOCATE(globaldata_4d_i2(outdimlens(dimids(1)),outdimlens(dimids(2)), & 639 & outdimlens(dimids(3)),nt chunk))711 & outdimlens(dimids(3)),ntslice)) 640 712 IF (l_maskout) globaldata_4d_i2(:,:,:,:)=mdiVals(jv) 641 713 CASE( NF90_INT ) 642 714 ALLOCATE(globaldata_4d_i4(outdimlens(dimids(1)),outdimlens(dimids(2)), & 643 & outdimlens(dimids(3)),nt chunk))715 & outdimlens(dimids(3)),ntslice)) 644 716 IF (l_maskout) globaldata_4d_i4(:,:,:,:)=mdiVals(jv) 645 717 CASE( NF90_FLOAT ) 646 718 ALLOCATE(globaldata_4d_sp(outdimlens(dimids(1)),outdimlens(dimids(2)), & 647 & outdimlens(dimids(3)),nt chunk))719 & outdimlens(dimids(3)),ntslice)) 648 720 IF (l_maskout) globaldata_4d_sp(:,:,:,:)=mdiVals(jv) 649 721 CASE( NF90_DOUBLE ) 650 722 ALLOCATE(globaldata_4d_dp(outdimlens(dimids(1)),outdimlens(dimids(2)), & 651 & outdimlens(dimids(3)),nt chunk))723 & outdimlens(dimids(3)),ntslice)) 652 724 IF (l_maskout) globaldata_4d_dp(:,:,:,:)=mdiVals(jv) 653 725 CASE DEFAULT … … 670 742 !$OMP& localdata_1d_i1,localdata_2d_i1,localdata_3d_i1,localdata_4d_i1) & 671 743 !$OMP& SHARED(jv,nvars,varname,filenames,ValMin,ValMax,indimlens,outdimlens,rbdims, & 672 !$OMP& ndomain,outid, chunksize,istop,l_valid,nthreads,inncids,rebuild_dims,&744 !$OMP& ndomain,outid,fchunksize,istop,l_valid,nthreads,inncids,rebuild_dims, & 673 745 !$OMP& globaldata_1d_i2,globaldata_1d_i4,globaldata_1d_sp,globaldata_1d_dp, & 674 746 !$OMP& globaldata_2d_i2,globaldata_2d_i4,globaldata_2d_sp,globaldata_2d_dp, & … … 676 748 !$OMP& globaldata_4d_i2,globaldata_4d_i4,globaldata_4d_sp,globaldata_4d_dp, & 677 749 !$OMP& globaldata_1d_i1,globaldata_2d_i1,globaldata_3d_i1,globaldata_4d_i1, & 678 !$OMP& nt chunk,nt,nmax_unlimited,indimnames,dims)750 !$OMP& ntslice,nt,nmax_unlimited,indimnames,dims,patchchunk) 679 751 680 752 DO ifile = 1, ndomain … … 932 1004 CASE( NF90_BYTE ) 933 1005 ALLOCATE(localdata_4d_i1(local_sizes(di),local_sizes(dj), & 934 & indimlens(dimids(3)),nt chunk))1006 & indimlens(dimids(3)),ntslice)) 935 1007 CALL check_nf90( nf90_get_var( ncid, jv, localdata_4d_i1, start=(/1,1,1,nt/) ), istop ) 936 1008 !$OMP PARALLEL DEFAULT(NONE) PRIVATE(ji,jj,jk,jl) & 937 !$OMP& SHARED(idomain,jdomain,indimlens,dimids,start_pos,globaldata_4d_i1,localdata_4d_i1,di,dj,nt,nt chunk)938 DO jl = 1, nt chunk1009 !$OMP& SHARED(idomain,jdomain,indimlens,dimids,start_pos,globaldata_4d_i1,localdata_4d_i1,di,dj,nt,ntslice) 1010 DO jl = 1, ntslice 939 1011 !$OMP DO 940 1012 DO jk = 1, indimlens(dimids(3)) … … 951 1023 CASE( NF90_SHORT ) 952 1024 ALLOCATE(localdata_4d_i2(local_sizes(di),local_sizes(dj), & 953 & indimlens(dimids(3)),nt chunk))1025 & indimlens(dimids(3)),ntslice)) 954 1026 CALL check_nf90( nf90_get_var( ncid, jv, localdata_4d_i2, start=(/1,1,1,nt/) ), istop ) 955 1027 !$OMP PARALLEL DEFAULT(NONE) PRIVATE(ji,jj,jk,jl) & 956 !$OMP& SHARED(idomain,jdomain,indimlens,dimids,start_pos,globaldata_4d_i2,localdata_4d_i2,di,dj,nt,nt chunk)957 DO jl = 1, nt chunk1028 !$OMP& SHARED(idomain,jdomain,indimlens,dimids,start_pos,globaldata_4d_i2,localdata_4d_i2,di,dj,nt,ntslice) 1029 DO jl = 1, ntslice 958 1030 !$OMP DO 959 1031 DO jk = 1, indimlens(dimids(3)) … … 970 1042 CASE( NF90_INT ) 971 1043 ALLOCATE(localdata_4d_i4(local_sizes(di),local_sizes(dj), & 972 & indimlens(dimids(3)),nt chunk))1044 & indimlens(dimids(3)),ntslice)) 973 1045 CALL check_nf90( nf90_get_var( ncid, jv, localdata_4d_i4, start=(/1,1,1,nt/) ), istop ) 974 1046 !$OMP PARALLEL DEFAULT(NONE) PRIVATE(ji,jj,jk,jl) & 975 !$OMP& SHARED(idomain,jdomain,indimlens,dimids,start_pos,globaldata_4d_i4,localdata_4d_i4,di,dj,nt,nt chunk)976 DO jl = 1, nt chunk1047 !$OMP& SHARED(idomain,jdomain,indimlens,dimids,start_pos,globaldata_4d_i4,localdata_4d_i4,di,dj,nt,ntslice) 1048 DO jl = 1, ntslice 977 1049 !$OMP DO 978 1050 DO jk = 1, indimlens(dimids(3)) … … 989 1061 CASE( NF90_FLOAT ) 990 1062 ALLOCATE(localdata_4d_sp(local_sizes(di),local_sizes(dj), & 991 & indimlens(dimids(3)),nt chunk))1063 & indimlens(dimids(3)),ntslice)) 992 1064 CALL check_nf90( nf90_get_var( ncid, jv, localdata_4d_sp, start=(/1,1,1,nt/) ), istop ) 993 1065 !$OMP PARALLEL DEFAULT(NONE) PRIVATE(ji,jj,jk,jl) & 994 !$OMP& SHARED(idomain,jdomain,indimlens,dimids,start_pos,globaldata_4d_sp,localdata_4d_sp,di,dj,nt,nt chunk)995 DO jl = 1, nt chunk1066 !$OMP& SHARED(idomain,jdomain,indimlens,dimids,start_pos,globaldata_4d_sp,localdata_4d_sp,di,dj,nt,ntslice) 1067 DO jl = 1, ntslice 996 1068 !$OMP DO 997 1069 DO jk = 1, indimlens(dimids(3)) … … 1008 1080 CASE( NF90_DOUBLE ) 1009 1081 ALLOCATE(localdata_4d_dp(local_sizes(di),local_sizes(dj), & 1010 & indimlens(dimids(3)),nt chunk))1082 & indimlens(dimids(3)),ntslice)) 1011 1083 CALL check_nf90( nf90_get_var( ncid, jv, localdata_4d_dp, start=(/1,1,1,nt/) ), istop ) 1012 1084 !$OMP PARALLEL DEFAULT(NONE) PRIVATE(ji,jj,jk,jl) & 1013 !$OMP& SHARED(idomain,jdomain,indimlens,dimids,start_pos,globaldata_4d_dp,localdata_4d_dp,di,dj,nt,nt chunk)1014 DO jl = 1, nt chunk1085 !$OMP& SHARED(idomain,jdomain,indimlens,dimids,start_pos,globaldata_4d_dp,localdata_4d_dp,di,dj,nt,ntslice) 1086 DO jl = 1, ntslice 1015 1087 !$OMP DO 1016 1088 DO jk = 1, indimlens(dimids(3)) … … 1099 1171 CASE( NF90_DOUBLE ) 1100 1172 CALL check_nf90( nf90_put_var( outid, jv, globaldata_0d_dp ) ) 1173 CASE DEFAULT 1174 WRITE(numerr,*) '0d Unknown nf90 type: ', xtype 1175 STOP 4 1101 1176 END SELECT 1102 1177 … … 1119 1194 CALL check_nf90( nf90_put_var( outid, jv, globaldata_1d_dp ) ) 1120 1195 DEALLOCATE(globaldata_1d_dp) 1196 CASE DEFAULT 1197 WRITE(numerr,*) '1d Unknown nf90 type: ', xtype 1198 STOP 4 1121 1199 END SELECT 1122 1200 … … 1140 1218 DEALLOCATE(globaldata_2d_dp) 1141 1219 CASE DEFAULT 1142 WRITE(numerr,*) ' Unknown nf90 type: ', xtype1220 WRITE(numerr,*) '2d Unknown nf90 type: ', xtype 1143 1221 STOP 4 1144 1222 END SELECT … … 1163 1241 DEALLOCATE(globaldata_3d_dp) 1164 1242 CASE DEFAULT 1165 WRITE(numerr,*) ' Unknown nf90 type: ', xtype1243 WRITE(numerr,*) '3d Unknown nf90 type: ', xtype 1166 1244 STOP 4 1167 1245 END SELECT … … 1186 1264 DEALLOCATE(globaldata_4d_dp) 1187 1265 CASE DEFAULT 1188 WRITE(numerr,*) ' Unknown nf90 type: ', xtype1266 WRITE(numerr,*) '4d Unknown nf90 type: ', xtype 1189 1267 STOP 4 1190 1268 END SELECT 1269 ! why only for big data set, test the cost. 1270 CALL check_nf90( nf90_sync( outid ) ) ! flush buffers to disk after writing big 4D datasets 1191 1271 1192 1272 ENDIF 1193 1273 1194 nt = nt + nt chunk1274 nt = nt + ntslice 1195 1275 1196 1276 END DO ! WHILE loop … … 1237 1317 WRITE(numerr,*) "*** NEMO rebuild failed ***" 1238 1318 WRITE(numerr,*) 1239 STOP 41319 STOP 5 1240 1320 ENDIF 1241 1321 ENDIF
Note: See TracChangeset
for help on using the changeset viewer.