<div style="line-height:1.7;color:#000000;font-size:14px;font-family:Arial"><div>Hi, all,</div><div><br /></div><div><div style="line-height: 1.7;">I am trying to use nfmpi_get_vara_all to get variable values from a CDF-1 file with pnetcdf 1.6.1 and mpi 3. </div><div style="line-height: 1.7;">There is a problem that I am not able to solve though I already spent three days trying to figure out what it was on earth.</div><div style="line-height: 1.7;"><br /></div><div style="line-height: 1.7;">The error message is "Overflow when type cast to 4-byte integer."  Here is my code. It is also attached.</div></div><div style="line-height: 1.7;"><br /></div><div style="line-height: 1.7;"><br /></div><div style="line-height: 23.8px;">program trypnetcdf</div><div style="line-height: 23.8px;">  2 </div><div style="line-height: 23.8px;">  3 use pnetcdf ! Replace nf_ functions with nfmpi_ functions. Huo, 28/08/2016</div><div style="line-height: 23.8px;">  4 use module_mpp_land, only: io_id, global_nx, global_ny, my_id, mpp_land_sync,MPP_LAND_PAR_INI, mpp_land_init, getLocalXY</div><div style="line-height: 23.8px;">  5 </div><div style="line-height: 23.8px;">  6 implicit none</div><div style="line-height: 23.8px;">  7 </div><div style="line-height: 23.8px;">  8 include 'mpif.h'</div><div style="line-height: 23.8px;">  9 </div><div style="line-height: 23.8px;"> 10 integer ::  i, j</div><div style="line-height: 23.8px;"> 11 integer ::  ix_tmp, jx_tmp</div><div style="line-height: 23.8px;"> 12 integer :: ierr</div><div style="line-height: 23.8px;"> 13 integer                              ::  xstart, xend, ystart, yend</div><div style="line-height: 23.8px;"> 14 real, ALLOCATABLE, DIMENSION(:,:)    ::  IVGTYP    ! vegetation type</div><div style="line-height: 23.8px;"> 15 character(len=256) :: hrldas_constants_file</div><div style="line-height: 23.8px;"> 16 </div><div style="line-height: 23.8px;"> 17 call  MPP_LAND_INIT()</div><div style="line-height: 23.8px;"> 18 ix_tmp = 1600</div><div style="line-height: 23.8px;"> 19 jx_tmp =1040</div><div style="line-height: 23.8px;"> 20 </div><div style="line-height: 23.8px;"> 21 call MPP_LAND_PAR_INI(1,ix_tmp,jx_tmp,1)</div><div style="line-height: 23.8px;"> 22 call getLocalXY(ix_tmp,jx_tmp,xstart,ystart,xend,yend)</div><div style="line-height: 23.8px;"> 23 </div><div style="line-height: 23.8px;"> 24 </div><div style="line-height: 23.8px;"> 25 hrldas_constants_file="/HOME/gcess_weigong_1/WORKSPACE/CLDASIN/2008010101.LDASIN_DOMAIN0"</div><div style="line-height: 23.8px;"> 26 </div><div style="line-height: 23.8px;"> 27 ALLOCATE ( IVGTYP    (XSTART:XEND,YSTART:YEND) )    ! vegetation type</div><div style="line-height: 23.8px;"> 28 </div><div style="line-height: 23.8px;"> 29 call get_ivgtyp(trim(hrldas_constants_file), xstart, xend, ystart, yend, ivgtyp, "PSFC")</div><div style="line-height: 23.8px;"> 30 </div><div style="line-height: 23.8px;"> 31 </div><div style="line-height: 23.8px;"> 32 call MPI_COMM_RANK(MPI_COMM_WORLD, my_id, ierr) ! Huo, 29/08/2016</div><div style="line-height: 23.8px;"> 33 if (ierr /= MPI_SUCCESS) stop "MPI_COMM_RANK"</div><div style="line-height: 23.8px;"> 34 </div><div style="line-height: 23.8px;"> 35 if(my_id == 0) then</div><div style="line-height: 23.8px;"> 36     print *, 'xstart = ',xstart,'xend = ',xend,'ystart = ',ystart,'yend = ',yend</div><div style="line-height: 23.8px;"> 37     do i = xstart, xend</div><div style="line-height: 23.8px;"> 38         do j = ystart, yend</div><div style="line-height: 23.8px;"> 39             print *, ivgtyp(i,j)</div><div style="line-height: 23.8px;"> 40         end do</div><div style="line-height: 23.8px;"> 41     end do</div><div style="line-height: 23.8px;"> 42 endif</div><div style="line-height: 23.8px;"> 43 </div><div style="line-height: 23.8px;"> 44 contains</div><div style="line-height: 23.8px;"> 45 </div><div style="line-height: 23.8px;"> 46 subroutine get_ivgtyp(flnm, xstart, xend, ystart, yend, array, varname)</div><div style="line-height: 23.8px;"> 47 implicit none</div><div style="line-height: 23.8px;"> 48 character(len=*),                             intent(in):: flnm</div><div style="line-height: 23.8px;"> 49 integer                      ,                intent(in):: xstart, xend, ystart, yend</div><div style="line-height: 23.8px;"> 50 real, dimension(xstart:xend,ystart:yend),     intent(out):: array</div><div style="line-height: 23.8px;"> 51 character(len=*),                             intent(in):: varname</div><div style="line-height: 23.8px;"> 52 integer(KIND=MPI_OFFSET_KIND),dimension(2)              ::startxy, countxy</div><div style="line-height: 23.8px;"> 53 integer :: ierr, ncid, varid</div><div style="line-height: 23.8px;"> 54 </div><div style="line-height: 23.8px;"> 55 startxy=(/xstart,ystart/)</div><div style="line-height: 23.8px;"> 56 countxy=(/xend-xstart+1, yend-ystart+1/)</div><div style="line-height: 23.8px;"> 57 </div><div style="line-height: 23.8px;"> 58 if(my_id == 0) then</div><div style="line-height: 23.8px;"> 59 print *, xstart, xend, ystart, yend</div><div style="line-height: 23.8px;"> 60 endif</div><div style="line-height: 23.8px;"> 61 </div><div style="line-height: 23.8px;"> 62 ierr = nfmpi_open(MPI_COMM_WORLD, trim(flnm), NF_NOWRITE, MPI_INFO_NULL, ncid)</div><div style="line-height: 23.8px;"> 63 if (ierr /= 0) stop "NFMPI_OPEN"</div><div style="line-height: 23.8px;"> 64 ierr = nfmpi_inq_varid(ncid, varname, varid)</div><div style="line-height: 23.8px;"> 65 if (ierr /= 0) stop "NFMPI_INQ_VARID"</div><div style="line-height: 23.8px;"> 66 </div><div style="line-height: 23.8px;"> 67 !ierr = nfmpi_get_vara_int_all(ncid, varid, (/xstart,ystart/), (/xend-xstart+1, yend-ystart+1/), array) ! 06/09/2016, Huo.</div><div style="line-height: 23.8px;"> 68 ierr = nfmpi_get_vara_real_all(ncid, varid, startxy, countxy, array) ! 06/09/2016, Huo.</div><div style="line-height: 23.8px;"> 69 print *, ierr</div><div style="line-height: 23.8px;"> 70 if (ierr /= 0) stop "NFMPI_GET_VARA_INT_ALL"</div><div style="line-height: 23.8px;"> 71 </div><div style="line-height: 23.8px;"> 72 ierr=nfmpi_close(ncid)</div><div style="line-height: 23.8px;"> 73 if (ierr /= 0) stop "NFMPI_CLOSE"</div><div style="line-height: 23.8px;"> 74 </div><div style="line-height: 23.8px;"> 75 end subroutine get_ivgtyp</div><div style="line-height: 23.8px;"> 76 </div><div style="line-height: 23.8px;"> 77 end program trypnetcdf</div><br /><br /><br /><div  style="position:relative;zoom:1">--<br /><div><span style="TEXT-TRANSFORM: none; BACKGROUND-COLOR: rgb(255,255,255); TEXT-INDENT: 0px; DISPLAY: inline !important; FONT: 16px/27px Calibri; WHITE-SPACE: normal; FLOAT: none; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px; -webkit-text-stroke-width: 0px">Xueli Huo, </span></div>
<div><span style="TEXT-TRANSFORM: none; BACKGROUND-COLOR: rgb(255,255,255); TEXT-INDENT: 0px; DISPLAY: inline !important; FONT: 16px/27px Calibri; WHITE-SPACE: normal; FLOAT: none; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px; -webkit-text-stroke-width: 0px">College of Global Change and Earth System Science</span><br style="TEXT-TRANSFORM: none; BACKGROUND-COLOR: rgb(255,255,255); TEXT-INDENT: 0px; FONT: 16px/27px Calibri; WHITE-SPACE: normal; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px; -webkit-text-stroke-width: 0px" /><span style="TEXT-TRANSFORM: none; BACKGROUND-COLOR: rgb(255,255,255); TEXT-INDENT: 0px; DISPLAY: inline !important; FONT: 16px/27px Calibri; WHITE-SPACE: normal; FLOAT: none; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px; -webkit-text-stroke-width: 0px">Beijing Normal Unviersity</span></div>
<div><span style="TEXT-TRANSFORM: none; BACKGROUND-COLOR: rgb(255,255,255); TEXT-INDENT: 0px; DISPLAY: inline !important; FONT: 16px/27px Calibri; WHITE-SPACE: normal; FLOAT: none; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px; -webkit-text-stroke-width: 0px">Xinjiekouwai Street, No 19</span></div>
<div><span style="TEXT-TRANSFORM: none; BACKGROUND-COLOR: rgb(255,255,255); TEXT-INDENT: 0px; DISPLAY: inline !important; FONT: 16px/27px Calibri; WHITE-SPACE: normal; FLOAT: none; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px; -webkit-text-stroke-width: 0px">Haidian District </span><br style="TEXT-TRANSFORM: none; BACKGROUND-COLOR: rgb(255,255,255); TEXT-INDENT: 0px; FONT: 16px/27px Calibri; WHITE-SPACE: normal; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px; -webkit-text-stroke-width: 0px" /><span style="TEXT-TRANSFORM: none; BACKGROUND-COLOR: rgb(255,255,255); TEXT-INDENT: 0px; DISPLAY: inline !important; FONT: 16px/27px Calibri; WHITE-SPACE: normal; FLOAT: none; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px; -webkit-text-stroke-width: 0px">Beijing, 100875, China</span><br style="TEXT-TRANSFORM: none; BACKGROUND-COLOR: rgb(255,255,255); TEXT-INDENT: 0px; FONT: 16px/27px Calibri; WHITE-SPACE: normal; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px; -webkit-text-stroke-width: 0px" /></div><div style="clear:both"></div></div></div><br>