Re:Re: Overflow when type cast to 4-byte integer" using nfmpi_get_vara_int

Xueli Huo 201531490002 at mail.bnu.edu.cn
Sun Sep 18 00:00:04 CDT 2016


Hi, Wei-keng,<br/><br/>I am so sorry for  making a mistake there. The dimension of var is 3, not 2. <br/>It's OK for nfmpi_get_vara_real_all in pnetcdf-1.6.1. <br/><br/>Thanks so much for your warm-hearted help.<br/><br/>Xueli
At 2016-09-16 23:18:05, Wei-keng Liao <wkliao at eecs.northwestern.edu> wrote:
>Hi, Xueli
>
>Could you print the values of startxy and countxy before calling
>nfmpi_get_vara_real_all? I suspect their values are too large,
>based on the error message you got.
>
>
>Wei-keng
>
>On Sep 14, 2016, at 8:42 PM, Xueli Huo wrote:
>
>> Hi, all,
>> 
>> 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. 
>> 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.
>> 
>> The error message is "Overflow when type cast to 4-byte integer."  Here is my code. It is also attached.
>> 
>> 
>> program trypnetcdf
>>   2 
>>   3 use pnetcdf ! Replace nf_ functions with nfmpi_ functions. Huo, 28/08/2016
>>   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
>>   5 
>>   6 implicit none
>>   7 
>>   8 include 'mpif.h'
>>   9 
>>  10 integer ::  i, j
>>  11 integer ::  ix_tmp, jx_tmp
>>  12 integer :: ierr
>>  13 integer                              ::  xstart, xend, ystart, yend
>>  14 real, ALLOCATABLE, DIMENSION(:,:)    ::  IVGTYP    ! vegetation type
>>  15 character(len=256) :: hrldas_constants_file
>>  16 
>>  17 call  MPP_LAND_INIT()
>>  18 ix_tmp = 1600
>>  19 jx_tmp =1040
>>  20 
>>  21 call MPP_LAND_PAR_INI(1,ix_tmp,jx_tmp,1)
>>  22 call getLocalXY(ix_tmp,jx_tmp,xstart,ystart,xend,yend)
>>  23 
>>  24 
>>  25 hrldas_constants_file="/HOME/gcess_weigong_1/WORKSPACE/CLDASIN/2008010101.LDASIN_DOMAIN0"
>>  26 
>>  27 ALLOCATE ( IVGTYP    (XSTART:XEND,YSTART:YEND) )    ! vegetation type
>>  28 
>>  29 call get_ivgtyp(trim(hrldas_constants_file), xstart, xend, ystart, yend, ivgtyp, "PSFC")
>>  30 
>>  31 
>>  32 call MPI_COMM_RANK(MPI_COMM_WORLD, my_id, ierr) ! Huo, 29/08/2016
>>  33 if (ierr /= MPI_SUCCESS) stop "MPI_COMM_RANK"
>>  34 
>>  35 if(my_id == 0) then
>>  36     print *, 'xstart = ',xstart,'xend = ',xend,'ystart = ',ystart,'yend = ',yend
>>  37     do i = xstart, xend
>>  38         do j = ystart, yend
>>  39             print *, ivgtyp(i,j)
>>  40         end do
>>  41     end do
>>  42 endif
>>  43 
>>  44 contains
>>  45 
>>  46 subroutine get_ivgtyp(flnm, xstart, xend, ystart, yend, array, varname)
>>  47 implicit none
>>  48 character(len=*),                             intent(in):: flnm
>>  49 integer                      ,                intent(in):: xstart, xend, ystart, yend
>>  50 real, dimension(xstart:xend,ystart:yend),     intent(out):: array
>>  51 character(len=*),                             intent(in):: varname
>>  52 integer(KIND=MPI_OFFSET_KIND),dimension(2)              ::startxy, countxy
>>  53 integer :: ierr, ncid, varid
>>  54 
>>  55 startxy=(/xstart,ystart/)
>>  56 countxy=(/xend-xstart+1, yend-ystart+1/)
>>  57 
>>  58 if(my_id == 0) then
>>  59 print *, xstart, xend, ystart, yend
>>  60 endif
>>  61 
>>  62 ierr = nfmpi_open(MPI_COMM_WORLD, trim(flnm), NF_NOWRITE, MPI_INFO_NULL, ncid)
>>  63 if (ierr /= 0) stop "NFMPI_OPEN"
>>  64 ierr = nfmpi_inq_varid(ncid, varname, varid)
>>  65 if (ierr /= 0) stop "NFMPI_INQ_VARID"
>>  66 
>>  67 !ierr = nfmpi_get_vara_int_all(ncid, varid, (/xstart,ystart/), (/xend-xstart+1, yend-ystart+1/), array) ! 06/09/2016, Huo.
>>  68 ierr = nfmpi_get_vara_real_all(ncid, varid, startxy, countxy, array) ! 06/09/2016, Huo.
>>  69 print *, ierr
>>  70 if (ierr /= 0) stop "NFMPI_GET_VARA_INT_ALL"
>>  71 
>>  72 ierr=nfmpi_close(ncid)
>>  73 if (ierr /= 0) stop "NFMPI_CLOSE"
>>  74 
>>  75 end subroutine get_ivgtyp
>>  76 
>>  77 end program trypnetcdf
>> 
>> 
>> 
>> --
>> Xueli Huo,
>> College of Global Change and Earth System Science
>> Beijing Normal Unviersity
>> Xinjiekouwai Street, No 19
>> Haidian District 
>> Beijing, 100875, China
>> 
>> <trypnetcdf.F>
>




More information about the parallel-netcdf mailing list