2subroutine getvariable(fileName,DateStr,dh,VarName,VarBuff,IM,JSTA_2L,JEND_2U,LM,IM1,JS,JE,LM1)
58 use wrf_io_flags_mod,
only: wrf_real, wrf_real8
59 use ctlblk_mod,
only: me, spval, submodelname
66 character(len=256) ,
intent(in) :: fileName
67 character(len=19) ,
intent(in) :: DateStr
68 integer ,
intent(in) :: dh
69 character(*) ,
intent(in) :: VarName
70 real,
intent(out) :: VarBuff(IM,JSTA_2L:JEND_2U,LM)
71 integer,
intent(in) :: IM,LM,JSTA_2L,JEND_2U
72 integer,
intent(in) :: IM1,LM1,JS,JE
74 integer :: WrfType,i,j,l,ll
75 integer,
dimension(4) :: start_index, end_index
76 character (len= 4) :: staggering
77 character (len= 3) :: ordering
78 character (len=80),
dimension(3) :: dimnames
79 real,
allocatable,
dimension(:,:,:,:) :: data
80 integer :: ierr,size,mype,idsize,ier
81 character(len=132) :: Stagger
86 call mpi_comm_rank(mpi_comm_world,mype,ier)
90 call ext_ncd_get_var_info(dh,trim(varname),ndim,ordering,stagger,start_index,end_index,wrftype,ierr)
92 if (me==0)
write(*,*)
'Error: ',ierr,trim(varname),
' not found in ',filename
96 allocate(
data (end_index(1), end_index(2), end_index(3), 1))
97 if( wrftype /= wrf_real .AND. wrftype /= wrf_real8 )
then
98 if (me==0)
write(*,*)
'Error: Not a real variable',wrftype
110 call ext_ncd_read_field(dh,datestr,trim(varname),
data,wrftype,0,0,0,ordering,&
111 staggering, dimnames , &
112 start_index,end_index, &
113 start_index,end_index, &
114 start_index,end_index, &
117 call mpi_bcast(
data,idsize,mpi_real,0,mpi_comm_world,ierr)
118 IF ( ierr /= 0 )
THEN
120 write(*,*)
'Error reading ',varname,
' from ',filename
121 write(*,*)
' ndim = ', ndim
122 write(*,*)
' end_index(1) ',end_index(1)
123 write(*,*)
' end_index(2) ',end_index(2)
124 write(*,*)
' end_index(3) ',end_index(3)
131 if (im1>end_index(1))
write(*,*)
'Err:',varname,
' IM1=',im1,&
132 ' but data dim=',end_index(1)
133 if (je>end_index(2))
write(*,*)
'Err:',varname,
' JE=',je,&
134 ' but data dim=',end_index(2)
135 if (lm1>end_index(3))
write(*,*)
'Err:',varname,
' LM1=',lm1,&
136 ' but data dim=',end_index(3)
138 write(*,*)
'Error: ndim = ',ndim
142 if (submodelname==
'MPAS')
then
144 call ext_ncd_get_var_ti_real(dh,
"_FillValue",trim(varname),fillvalue,1,outcount,ierr)
149 if (
data(i,j,ll,1) /= fillvalue)
then
150 varbuff(i,j,l)=
data(i,j,ll,1)
162 varbuff(i,j,l)=
data(i,j,ll,1)
172end subroutine getvariable