1 !---------------------------------------------------------------------------
4 ! Author: Wei Huang huangwei@ucar.edu
7 !---------------------------------------------------------------------------
9 !---------------------------------------------------------------------------
24 integer(i4) :: nprocs, myrank
25 integer :: ids, ide, jds, jde, kds, kde, &
26 ims, ime, jms, jme, kms, kme, &
27 its, ite, jts, jte, kts, kte
31 subroutine allocHandle(DataHandle,DH,Status)
33 include 'wrf_status_codes.h'
34 integer ,intent(out) :: DataHandle
35 type(wrf_data_handle),pointer :: DH
36 integer ,intent(out) :: Status
40 do i=1,WrfDataHandleMax
41 if(WrfDataHandles(i)%Free) then
42 DH => WrfDataHandles(i)
45 DH%vartype(n) = NOT_LAND_SOIL_VAR
49 if(i==WrfDataHandleMax) then
50 Status = WRF_WARN_TOO_MANY_FILES
51 write(msg,*) 'Warning TOO MANY FILES in ',__FILE__,', line', __LINE__
52 call wrf_debug ( WARN , TRIM(msg))
53 write(msg,*) 'Did you call ext_pio_ioinit?'
54 call wrf_debug ( WARN , TRIM(msg))
60 DH%first_operation = .TRUE.
61 DH%CurrentVariable = 0
63 end subroutine allocHandle
65 subroutine deallocHandle(DataHandle, Status)
67 include 'wrf_status_codes.h'
68 integer ,intent(in) :: DataHandle
69 integer ,intent(out) :: Status
70 type(wrf_data_handle),pointer :: DH
74 IF ( DataHandle .GE. 1 .AND. DataHandle .LE. WrfDataHandleMax ) THEN
75 if(.NOT. WrfDataHandles(DataHandle)%Free) then
76 DH => WrfDataHandles(DataHandle)
80 !deallocate(DH%iosystem)
83 end subroutine deallocHandle
85 subroutine GetDH(DataHandle,DH,Status)
87 include 'wrf_status_codes.h'
88 integer ,intent(in) :: DataHandle
89 type(wrf_data_handle) ,pointer :: DH
90 integer ,intent(out) :: Status
92 if(DataHandle < 1 .or. DataHandle > WrfDataHandleMax) then
93 Status = WRF_WARN_BAD_DATA_HANDLE
96 DH => WrfDataHandles(DataHandle)
98 Status = WRF_WARN_BAD_DATA_HANDLE
105 subroutine DateCheck(Date,Status)
107 include 'wrf_status_codes.h'
108 character*(*) ,intent(in) :: Date
109 integer ,intent(out) :: Status
111 if(len(Date) /= DateStrLen) then
112 Status = WRF_WARN_DATESTR_BAD_LENGTH
117 end subroutine DateCheck
119 subroutine GetName(Element,Var,Name,Status)
121 include 'wrf_status_codes.h'
122 character*(*) ,intent(in) :: Element
123 character*(*) ,intent(in) :: Var
124 character*(*) ,intent(out) :: Name
125 integer ,intent(out) :: Status
126 character (VarNameLen) :: VarName
129 integer, parameter :: upper_to_lower =IACHAR('a')-IACHAR('A')
132 Name = 'MD___'//trim(Element)//VarName
135 if('A'<=c .and. c <='Z') Name(i:i)=achar(iachar(c)+upper_to_lower)
136 if(c=='-'.or.c==':') Name(i:i)='_'
140 end subroutine GetName
142 subroutine GetTimeIndex(IO,DataHandle,DateStr,TimeIndex,Status)
144 include 'wrf_status_codes.h'
145 character (*) ,intent(in) :: IO
146 integer ,intent(in) :: DataHandle
147 character*(*) ,intent(in) :: DateStr
148 integer ,intent(out) :: TimeIndex
149 integer ,intent(out) :: Status
150 type(wrf_data_handle) ,pointer :: DH
155 character(len=DateStrLen) :: tmpdatestr(1)
157 if(len(Datestr) == DateStrLen) then
160 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
161 write(unit=0, fmt='(3a)') 'IO: <', trim(IO), '>'
162 write(unit=0, fmt='(a,i3)') 'DataHandle = ', DataHandle
163 write(unit=0, fmt='(3a)') 'DateStr: <', trim(DateStr), '>'
164 write(unit=0, fmt='(a,i6,a,i6)') 'DateStrLen = ', DateStrLen, &
165 ' did not equal len(DateStr): ', len(DateStr)
166 Status = WRF_WARN_DATESTR_ERROR
167 write(msg,*) 'Warning DATE STRING ERROR in ',__FILE__,', line', __LINE__
168 call wrf_debug ( WARN , TRIM(msg))
172 DH => WrfDataHandles(DataHandle)
173 call DateCheck(DateStr,Status)
174 if(Status /= WRF_NO_ERR) then
175 Status = WRF_WARN_DATESTR_ERROR
176 write(msg,*) 'Warning DATE STRING ERROR in ',__FILE__,', line', __LINE__
177 call wrf_debug ( WARN , TRIM(msg))
180 if(IO == 'write') then
181 TimeIndex = DH%TimeIndex
182 if(TimeIndex <= 0) then
184 elseif(DateStr == DH%Times(TimeIndex)) then
188 TimeIndex = TimeIndex + 1
189 if(TimeIndex > MaxTimes) then
190 Status = WRF_WARN_TIME_EOF
191 write(msg,*) 'Warning TIME EOF in ',__FILE__,', line', __LINE__
192 call wrf_debug ( WARN , TRIM(msg))
196 DH%TimeIndex = TimeIndex
197 DH%Times(TimeIndex) = DateStr
199 VStart(2) = TimeIndex
200 VCount(1) = DateStrLen
202 !write(unit=0, fmt='(3a,i6)') 'DateStr: <', trim(DateStr), '>, TimeIndex =', TimeIndex
203 stat = pio_put_var(DH%file_handle, DH%vtime, VStart, VCount, tmpdatestr)
204 call netcdf_err(stat,Status)
205 if(Status /= WRF_NO_ERR) then
206 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__
207 call wrf_debug ( WARN , TRIM(msg))
210 !call pio_advanceframe(DH%vtime)
213 if(DH%Times(i)==DateStr) then
219 Status = WRF_WARN_TIME_NF
220 write(msg,*) 'Warning TIME ',DateStr,' NOT FOUND in ',__FILE__,', line', __LINE__
221 call wrf_debug ( WARN , TRIM(msg))
227 end subroutine GetTimeIndex
229 subroutine GetDim(MemoryOrder,NDim,Status)
231 include 'wrf_status_codes.h'
232 character*(*) ,intent(in) :: MemoryOrder
233 integer ,intent(out) :: NDim
234 integer ,intent(out) :: Status
235 character*3 :: MemOrd
237 call LowerCase(MemoryOrder,MemOrd)
239 case ('xyz','xzy','yxz','yzx','zxy','zyx','xsz','xez','ysz','yez')
241 case ('xy','yx','xs','xe','ys','ye')
245 case ('0') ! NDim=0 for scalars. TBH: 20060502
248 print *, 'memory order = ',MemOrd,' ',MemoryOrder
249 Status = WRF_WARN_BAD_MEMORYORDER
254 end subroutine GetDim
256 subroutine GetIndices(NDim,Start,End,i1,i2,j1,j2,k1,k2)
258 include 'wrf_status_codes.h'
259 integer ,intent(in) :: NDim
260 integer ,dimension(*),intent(in) :: Start,End
261 integer ,intent(out) :: i1,i2,j1,j2,k1,k2
269 if(NDim == 0) return ! NDim=0 for scalars. TBH: 20060502
279 end subroutine GetIndices
281 logical function ZeroLengthHorzDim(MemoryOrder,Vector,Status)
283 include 'wrf_status_codes.h'
284 character*(*) ,intent(in) :: MemoryOrder
285 integer,dimension(*) ,intent(in) :: Vector
286 integer ,intent(out) :: Status
288 integer,dimension(NVarDims) :: temp
289 character*3 :: MemOrd
292 call GetDim(MemoryOrder,NDim,Status)
293 temp(1:NDim) = Vector(1:NDim)
294 call LowerCase(MemoryOrder,MemOrd)
295 zero_length = .false.
297 case ('xsz','xez','ysz','yez','xs','xe','ys','ye','z','c')
300 continue ! NDim=0 for scalars. TBH: 20060502
302 zero_length = temp(1) .lt. 1 .or. temp(3) .lt. 1
303 case ('xy','yx','xyz','yxz')
304 zero_length = temp(1) .lt. 1 .or. temp(2) .lt. 1
306 zero_length = temp(2) .lt. 1 .or. temp(3) .lt. 1
308 Status = WRF_WARN_BAD_MEMORYORDER
309 ZeroLengthHorzDim = .true.
313 ZeroLengthHorzDim = zero_length
315 end function ZeroLengthHorzDim
317 subroutine ExtOrder(MemoryOrder,Vector,Status)
319 include 'wrf_status_codes.h'
320 character*(*) ,intent(in) :: MemoryOrder
321 integer,dimension(*) ,intent(inout) :: Vector
322 integer ,intent(out) :: Status
324 integer,dimension(NVarDims) :: temp
325 character*3 :: MemOrd
327 call GetDim(MemoryOrder,NDim,Status)
328 temp(1:NDim) = Vector(1:NDim)
329 call LowerCase(MemoryOrder,MemOrd)
332 case ('xyz','xsz','xez','ysz','yez','xy','xs','xe','ys','ye','z','c')
335 continue ! NDim=0 for scalars. TBH: 20060502
357 Status = WRF_WARN_BAD_MEMORYORDER
362 end subroutine ExtOrder
364 subroutine ExtOrderStr(MemoryOrder,Vector,ROVector,Status)
366 include 'wrf_status_codes.h'
367 character*(*) ,intent(in) :: MemoryOrder
368 character*(*),dimension(*) ,intent(in) :: Vector
369 character(80),dimension(NVarDims),intent(out) :: ROVector
370 integer ,intent(out) :: Status
372 character*3 :: MemOrd
374 call GetDim(MemoryOrder,NDim,Status)
375 ROVector(1:NDim) = Vector(1:NDim)
376 call LowerCase(MemoryOrder,MemOrd)
379 case ('xyz','xsz','xez','ysz','yez','xy','xs','xe','ys','ye','z','c')
382 continue ! NDim=0 for scalars. TBH: 20060502
384 ROVector(2) = Vector(3)
385 ROVector(3) = Vector(2)
387 ROVector(1) = Vector(2)
388 ROVector(2) = Vector(1)
390 ROVector(1) = Vector(3)
391 ROVector(2) = Vector(1)
392 ROVector(3) = Vector(2)
394 ROVector(1) = Vector(2)
395 ROVector(2) = Vector(3)
396 ROVector(3) = Vector(1)
398 ROVector(1) = Vector(3)
399 ROVector(3) = Vector(1)
401 ROVector(1) = Vector(2)
402 ROVector(2) = Vector(1)
404 Status = WRF_WARN_BAD_MEMORYORDER
409 end subroutine ExtOrderStr
412 subroutine LowerCase(MemoryOrder,MemOrd)
414 include 'wrf_status_codes.h'
415 character*(*) ,intent(in) :: MemoryOrder
416 character*(*) ,intent(out) :: MemOrd
418 integer ,parameter :: upper_to_lower =IACHAR('a')-IACHAR('A')
423 MemOrd(1:N) = MemoryOrder(1:N)
426 if('A'<=c .and. c <='Z') MemOrd(i:i)=achar(iachar(c)+upper_to_lower)
429 end subroutine LowerCase
431 subroutine UpperCase(MemoryOrder,MemOrd)
433 include 'wrf_status_codes.h'
434 character*(*) ,intent(in) :: MemoryOrder
435 character*(*) ,intent(out) :: MemOrd
437 integer ,parameter :: lower_to_upper =IACHAR('A')-IACHAR('a')
442 MemOrd(1:N) = MemoryOrder(1:N)
445 if('a'<=c .and. c <='z') MemOrd(i:i)=achar(iachar(c)+lower_to_upper)
448 end subroutine UpperCase
450 subroutine netcdf_err(err,Status)
452 include 'wrf_status_codes.h'
453 integer ,intent(in) :: err
454 integer ,intent(out) :: Status
455 character(len=80) :: errmsg
458 if(err == PIO_NOERR)then
461 write(msg,*) 'NetCDF error: ', 'from PIO'
462 call wrf_debug ( WARN , TRIM(msg))
463 Status = WRF_WARN_NETCDF
466 end subroutine netcdf_err
468 subroutine find_iodesc(DH,MemoryOrder,Stagger,FieldTYpe,whole)
470 type(wrf_data_handle), pointer :: DH
471 character*(*), intent(in) :: MemoryOrder
472 character*(*), intent(in) :: Stagger
473 integer, intent(in) :: FieldType
474 logical, intent(out) :: whole
475 character*3 :: MemOrd
477 integer ,parameter :: MaxUpperCase=IACHAR('Z')
481 call LowerCase(MemoryOrder,MemOrd)
482 call LowerCase(Stagger,Stag)
486 select case (FieldType)
490 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_u_real
492 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_v_real
494 if(LAND_CAT_VAR == DH%vartype(DH%CurrentVariable)) then
495 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_land_real
496 else if(SOIL_CAT_VAR == DH%vartype(DH%CurrentVariable)) then
497 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_soil_real
498 else if(SOIL_LAYERS_VAR == DH%vartype(DH%CurrentVariable)) then
499 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_soil_layers_real
500 else if(MDL_CPL_VAR == DH%vartype(DH%CurrentVariable)) then
501 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_mdl_cpl_real
502 else if(ENSEMBLE_VAR == DH%vartype(DH%CurrentVariable)) then
503 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_ensemble_real
505 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_w_real
508 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_m_real
513 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_u_double
515 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_v_double
517 if(LAND_CAT_VAR == DH%vartype(DH%CurrentVariable)) then
518 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_land_double
519 else if(SOIL_CAT_VAR == DH%vartype(DH%CurrentVariable)) then
520 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_soil_double
521 else if(SOIL_LAYERS_VAR == DH%vartype(DH%CurrentVariable)) then
522 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_soil_layers_double
523 else if(MDL_CPL_VAR == DH%vartype(DH%CurrentVariable)) then
524 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_mdl_cpl_double
525 else if(ENSEMBLE_VAR == DH%vartype(DH%CurrentVariable)) then
526 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_ensemble_double
528 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_w_double
531 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_m_double
536 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_u_int
538 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_v_int
540 if(LAND_CAT_VAR == DH%vartype(DH%CurrentVariable)) then
541 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_land_int
542 else if(SOIL_CAT_VAR == DH%vartype(DH%CurrentVariable)) then
543 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_soil_int
544 else if(SOIL_LAYERS_VAR == DH%vartype(DH%CurrentVariable)) then
545 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_soil_layers_int
546 else if(MDL_CPL_VAR == DH%vartype(DH%CurrentVariable)) then
547 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_mdl_cpl_int
548 else if(ENSEMBLE_VAR == DH%vartype(DH%CurrentVariable)) then
549 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_ensemble_int
551 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_w_int
554 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_m_int
559 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_u_int
561 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_v_int
563 if(LAND_CAT_VAR == DH%vartype(DH%CurrentVariable)) then
564 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_land_int
565 else if(SOIL_CAT_VAR == DH%vartype(DH%CurrentVariable)) then
566 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_soil_int
567 else if(SOIL_LAYERS_VAR == DH%vartype(DH%CurrentVariable)) then
568 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_soil_layers_int
569 else if(MDL_CPL_VAR == DH%vartype(DH%CurrentVariable)) then
570 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_mdl_cpl_int
571 else if(ENSEMBLE_VAR == DH%vartype(DH%CurrentVariable)) then
572 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_ensemble_int
574 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_w_int
577 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_m_int
580 write(msg,*) 'Warning DATA TYPE NOT FOUND in ',__FILE__,', line', __LINE__
581 call wrf_debug ( WARN , TRIM(msg))
586 select case (FieldType)
590 DH%ioVar(DH%CurrentVariable) = DH%iodesc2d_u_real
592 DH%ioVar(DH%CurrentVariable) = DH%iodesc2d_v_real
594 DH%ioVar(DH%CurrentVariable) = DH%iodesc2d_m_real
599 DH%ioVar(DH%CurrentVariable) = DH%iodesc2d_u_double
601 DH%ioVar(DH%CurrentVariable) = DH%iodesc2d_v_double
603 DH%ioVar(DH%CurrentVariable) = DH%iodesc2d_m_double
608 DH%ioVar(DH%CurrentVariable) = DH%iodesc2d_u_int
610 DH%ioVar(DH%CurrentVariable) = DH%iodesc2d_v_int
612 DH%ioVar(DH%CurrentVariable) = DH%iodesc2d_m_int
617 DH%ioVar(DH%CurrentVariable) = DH%iodesc2d_u_int
619 DH%ioVar(DH%CurrentVariable) = DH%iodesc2d_v_int
621 DH%ioVar(DH%CurrentVariable) = DH%iodesc2d_m_int
624 write(msg,*) 'Warning DATA TYPE NOT FOUND in ',__FILE__,', line', __LINE__
625 call wrf_debug ( WARN , TRIM(msg))
630 DH%vartype(DH%CurrentVariable) = BDY_VAR
631 select case (FieldType)
635 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_xsz_u_real
637 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_xsz_v_real
639 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_xsz_w_real
641 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_xsz_m_real
646 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_xsz_u_double
648 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_xsz_v_double
650 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_xsz_w_double
652 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_xsz_m_double
657 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_xsz_u_int
659 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_xsz_v_int
661 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_xsz_w_int
663 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_xsz_m_int
668 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_xsz_u_int
670 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_xsz_v_int
672 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_xsz_w_int
674 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_xsz_m_int
677 write(msg,*) 'Warning DATA TYPE NOT FOUND in ',__FILE__,', line', __LINE__
678 call wrf_debug ( WARN , TRIM(msg))
683 DH%vartype(DH%CurrentVariable) = BDY_VAR
684 select case (FieldType)
688 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_xez_u_real
690 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_xez_v_real
692 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_xez_w_real
694 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_xez_m_real
699 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_xez_u_double
701 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_xez_v_double
703 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_xez_w_double
705 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_xez_m_double
710 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_xez_u_int
712 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_xez_v_int
714 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_xez_w_int
716 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_xez_m_int
721 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_xez_u_int
723 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_xez_v_int
725 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_xez_w_int
727 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_xez_m_int
730 write(msg,*) 'Warning DATA TYPE NOT FOUND in ',__FILE__,', line', __LINE__
731 call wrf_debug ( WARN , TRIM(msg))
736 DH%vartype(DH%CurrentVariable) = BDY_VAR
737 select case (FieldType)
741 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_ysz_u_real
743 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_ysz_v_real
745 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_ysz_w_real
747 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_ysz_m_real
752 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_ysz_u_double
754 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_ysz_v_double
756 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_ysz_w_double
758 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_ysz_m_double
763 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_ysz_u_int
765 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_ysz_v_int
767 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_ysz_w_int
769 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_ysz_m_int
774 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_ysz_u_int
776 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_ysz_v_int
778 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_ysz_w_int
780 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_ysz_m_int
783 write(msg,*) 'Warning DATA TYPE NOT FOUND in ',__FILE__,', line', __LINE__
784 call wrf_debug ( WARN , TRIM(msg))
789 DH%vartype(DH%CurrentVariable) = BDY_VAR
790 select case (FieldType)
794 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_yez_u_real
796 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_yez_v_real
798 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_yez_w_real
800 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_yez_m_real
805 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_yez_u_double
807 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_yez_v_double
809 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_yez_w_double
811 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_yez_m_double
816 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_yez_u_int
818 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_yez_v_int
820 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_yez_w_int
822 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_yez_m_int
827 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_yez_u_int
829 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_yez_v_int
831 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_yez_w_int
833 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_yez_m_int
836 write(msg,*) 'Warning DATA TYPE NOT FOUND in ',__FILE__,', line', __LINE__
837 call wrf_debug ( WARN , TRIM(msg))
842 DH%vartype(DH%CurrentVariable) = BDY_VAR
843 select case (FieldType)
845 DH%ioVar(DH%CurrentVariable) = DH%iodesc2d_xs_m_real
847 DH%ioVar(DH%CurrentVariable) = DH%iodesc2d_xs_m_double
849 DH%ioVar(DH%CurrentVariable) = DH%iodesc2d_xs_m_int
851 DH%ioVar(DH%CurrentVariable) = DH%iodesc2d_xs_m_int
853 write(msg,*) 'Warning DATA TYPE NOT FOUND in ',__FILE__,', line', __LINE__
854 call wrf_debug ( WARN , TRIM(msg))
859 DH%vartype(DH%CurrentVariable) = BDY_VAR
860 select case (FieldType)
862 DH%ioVar(DH%CurrentVariable) = DH%iodesc2d_xe_m_real
864 DH%ioVar(DH%CurrentVariable) = DH%iodesc2d_xe_m_double
866 DH%ioVar(DH%CurrentVariable) = DH%iodesc2d_xe_m_int
868 DH%ioVar(DH%CurrentVariable) = DH%iodesc2d_xe_m_int
870 write(msg,*) 'Warning DATA TYPE NOT FOUND in ',__FILE__,', line', __LINE__
871 call wrf_debug ( WARN , TRIM(msg))
876 DH%vartype(DH%CurrentVariable) = BDY_VAR
877 select case (FieldType)
879 DH%ioVar(DH%CurrentVariable) = DH%iodesc2d_ys_m_real
881 DH%ioVar(DH%CurrentVariable) = DH%iodesc2d_ys_m_double
883 DH%ioVar(DH%CurrentVariable) = DH%iodesc2d_ys_m_int
885 DH%ioVar(DH%CurrentVariable) = DH%iodesc2d_ys_m_int
887 write(msg,*) 'Warning DATA TYPE NOT FOUND in ',__FILE__,', line', __LINE__
888 call wrf_debug ( WARN , TRIM(msg))
893 DH%vartype(DH%CurrentVariable) = BDY_VAR
894 select case (FieldType)
896 DH%ioVar(DH%CurrentVariable) = DH%iodesc2d_ye_m_real
898 DH%ioVar(DH%CurrentVariable) = DH%iodesc2d_ye_m_double
900 DH%ioVar(DH%CurrentVariable) = DH%iodesc2d_ye_m_int
902 DH%ioVar(DH%CurrentVariable) = DH%iodesc2d_ye_m_int
904 write(msg,*) 'Warning DATA TYPE NOT FOUND in ',__FILE__,', line', __LINE__
905 call wrf_debug ( WARN , TRIM(msg))
912 if(ENSEMBLE_VAR == DH%vartype(DH%CurrentVariable)) then
913 select case (FieldType)
915 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_ensemble_real
917 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_ensemble_double
919 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_ensemble_int
921 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_ensemble_int
923 write(msg,*) 'Warning DO NOT KNOW HOW TO HANDLE this FieldType in ',__FILE__,', line', __LINE__
924 call wrf_debug ( WARN , TRIM(msg))
925 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_m_real
928 write(msg,*) 'Warning DO NOT KNOW HOW TO HANDLE THIS VAR KIND in ',__FILE__,', line', __LINE__
929 call wrf_debug ( WARN , TRIM(msg))
930 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_w_double
933 write(msg,*) 'Warning DO NOT KNOW HOW TO HANDLE THIS STAG in ',__FILE__,', line', __LINE__
934 call wrf_debug ( WARN , TRIM(msg))
935 DH%ioVar(DH%CurrentVariable) = DH%iodesc3d_m_real
941 if(ENSEMBLE_VAR == DH%vartype(DH%CurrentVariable)) then
945 select case (FieldType)
947 DH%ioVar(DH%CurrentVariable) = DH%iodesc1d_real
949 DH%ioVar(DH%CurrentVariable) = DH%iodesc1d_double
951 DH%ioVar(DH%CurrentVariable) = DH%iodesc1d_int
953 DH%ioVar(DH%CurrentVariable) = DH%iodesc1d_int
955 write(msg,*) 'Warning DATA TYPE NOT FOUND in ',__FILE__,', line', __LINE__
956 call wrf_debug ( WARN , TRIM(msg))
961 end subroutine find_iodesc
963 logical function is_boundary(MemoryOrder)
967 character*(*), intent(in) :: MemoryOrder
970 character*3 :: MemOrd
974 call LowerCase(MemoryOrder,MemOrd)
977 case ('xsz', 'xez', 'ysz', 'yez')
979 case ('xs', 'xe', 'ys', 'ye')
986 end function is_boundary
988 subroutine FieldIO(IO,DataHandle,DateStr,Dimens,Starts,Counts,Length,MemoryOrder, &
989 Stagger,FieldType,Field,Status)
991 include 'wrf_status_codes.h'
992 character (*) ,intent(in) :: IO
993 integer ,intent(in) :: DataHandle
994 character*(*) ,intent(in) :: DateStr
995 integer,dimension(NVarDims),intent(inout) :: Dimens
996 integer,dimension(NVarDims),intent(inout) :: Starts
997 integer,dimension(NVarDims),intent(inout) :: Counts
998 integer,dimension(NVarDims),intent(in) :: Length
999 character*(*) ,intent(in) :: MemoryOrder
1000 character*(*) ,intent(in) :: Stagger
1001 integer ,intent(in) :: FieldType
1002 integer,dimension(*) ,intent(inout) :: Field
1003 integer ,intent(out) :: Status
1004 integer :: TimeIndex
1005 logical :: whole, isbdy
1007 integer :: fldsize, datasize
1009 type(wrf_data_handle) ,pointer :: DH
1010 integer(KIND=PIO_OFFSET) :: pioidx
1012 DH => WrfDataHandles(DataHandle)
1013 call GetTimeIndex(IO,DataHandle,DateStr,TimeIndex,Status)
1014 if(Status /= WRF_NO_ERR) then
1015 write(msg,*) 'Warning in ',__FILE__,', line', __LINE__
1016 call wrf_debug ( WARN , TRIM(msg))
1017 write(msg,*) ' Bad time index for DateStr = ',DateStr
1018 call wrf_debug ( WARN , TRIM(msg))
1021 call GetDim(MemoryOrder,NDim,Status)
1026 fldsize = fldsize * Length(n)
1027 datasize = datasize * Counts(n)
1030 Starts(NDim+1) = TimeIndex
1033 call find_iodesc(DH,MemoryOrder,Stagger,FieldTYpe,whole)
1034 isbdy = is_boundary(MemoryOrder)
1035 !isbdy = BDY_VAR == DH%vartype(DH%CurrentVariable)
1038 call pio_setframe(DH%descVar(DH%CurrentVariable), pioidx)
1039 !DH%descVar(DH%CurrentVariable)%rec = TimeIndex
1041 !write(unit=0, fmt='(3a,i6)') 'File: ', __FILE__, ', line: ', __LINE__
1042 !write(unit=0, fmt='(3a,l8)') 'IO = ', trim(IO), ', whole = ', whole
1043 !write(unit=0, fmt='(4a)') 'MemoryOrder = ', trim(MemoryOrder), ', Stagger = ', trim(Stagger)
1044 !write(unit=0, fmt='(a,i4,a,i3)') 'DH%vartype(', DH%CurrentVariable, ') = ', DH%vartype(DH%CurrentVariable)
1046 !if(whole .and. (ENSEMBLE_VAR == DH%vartype(DH%CurrentVariable))) then
1050 select case (FieldType)
1052 if(isbdy .and. (IO == 'read')) then
1053 Dimens(NDim+1) = TimeIndex
1054 call read_bdy_RealFieldIO(DH,NDim,Dimens,Starts,Counts,Field,Status)
1056 call ext_pio_RealFieldIO(whole,IO,DH,Starts,Counts,fldsize,datasize,Field,Status)
1059 if(isbdy .and. (IO == 'read')) then
1060 Dimens(NDim+1) = TimeIndex
1061 call read_bdy_DoubleFieldIO(DH,NDim,Dimens,Starts,Counts,Field,Status)
1063 call ext_pio_DoubleFieldIO(whole,IO,DH,Starts,Counts,fldsize,datasize,Field,Status)
1066 call ext_pio_IntFieldIO(whole,IO,DH,Starts,Counts,fldsize,datasize,Field,Status)
1068 call ext_pio_LogicalFieldIO(whole,IO,DH,Starts,Counts,fldsize,datasize,Field,Status)
1070 Status = WRF_WARN_DATA_TYPE_NOT_FOUND
1071 write(msg,*) 'Warning DATA TYPE NOT FOUND in ',__FILE__,', line', __LINE__
1072 call wrf_debug ( WARN , TRIM(msg))
1077 end subroutine FieldIO
1079 subroutine FieldBDY(IO,DataHandle,DateStr,NDim,Domains, &
1080 MemoryStart,MemoryEnd,PatchStart,PatchEnd, &
1081 FieldType,Field,Status)
1083 include 'wrf_status_codes.h'
1084 character (*) ,intent(in) :: IO
1085 integer ,intent(in) :: DataHandle,NDim
1086 character*(*) ,intent(in) :: DateStr
1087 integer,dimension(*) ,intent(inout) :: Domains
1088 integer,dimension(*) ,intent(in) :: MemoryStart, MemoryEnd
1089 integer,dimension(*) ,intent(in) :: PatchStart, PatchEnd
1090 integer ,intent(in) :: FieldType
1091 integer,dimension(*) ,intent(inout) :: Field
1092 integer ,intent(out) :: Status
1093 integer :: TimeIndex
1094 type(wrf_data_handle) ,pointer :: DH
1095 integer(KIND=PIO_OFFSET) :: pioidx
1097 DH => WrfDataHandles(DataHandle)
1098 call GetTimeIndex(IO,DataHandle,DateStr,TimeIndex,Status)
1099 if(Status /= WRF_NO_ERR) then
1100 write(msg,*) 'Warning in ',__FILE__,', line', __LINE__
1101 call wrf_debug ( WARN , TRIM(msg))
1102 write(msg,*) ' Bad time index for DateStr = ',DateStr
1103 call wrf_debug ( WARN , TRIM(msg))
1108 call pio_setframe(DH%descVar(DH%CurrentVariable), pioidx)
1109 !DH%descVar(DH%CurrentVariable)%rec = TimeIndex
1110 Domains(NDim+1) = TimeIndex
1112 select case (FieldType)
1114 call read_bdy_RealFieldIO(DH,NDim,Domains,MemoryStart,MemoryEnd,PatchStart,PatchEnd,Field,Status)
1116 call read_bdy_DoubleFieldIO(DH,NDim,Domains,MemoryStart,MemoryEnd,PatchStart,PatchEnd,Field,Status)
1118 Status = WRF_WARN_DATA_TYPE_NOT_FOUND
1119 write(msg,*) 'Warning DATA TYPE NOT FOUND in ',__FILE__,', line', __LINE__
1120 call wrf_debug ( WARN , TRIM(msg))
1125 end subroutine FieldBDY
1127 ! Returns .TRUE. iff it is OK to write time-independent domain metadata to the
1128 ! file referenced by DataHandle. If DataHandle is invalid, .FALSE. is
1130 LOGICAL FUNCTION ncd_ok_to_put_dom_ti( DataHandle )
1132 include 'wrf_status_codes.h'
1133 INTEGER, INTENT(IN) :: DataHandle
1134 CHARACTER*80 :: fname
1135 INTEGER :: filestate
1137 LOGICAL :: dryrun, retval
1138 call ext_pio_inquire_filename( DataHandle, fname, filestate, Status )
1139 IF ( Status /= WRF_NO_ERR ) THEN
1140 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__, &
1142 call wrf_debug ( WARN , TRIM(msg) )
1145 dryrun = ( filestate .EQ. WRF_FILE_OPENED_NOT_COMMITTED )
1148 ncd_ok_to_put_dom_ti = retval
1150 END FUNCTION ncd_ok_to_put_dom_ti
1152 ! Returns .TRUE. iff it is OK to read time-independent domain metadata from the
1153 ! file referenced by DataHandle. If DataHandle is invalid, .FALSE. is
1155 LOGICAL FUNCTION ncd_ok_to_get_dom_ti( DataHandle )
1157 include 'wrf_status_codes.h'
1158 INTEGER, INTENT(IN) :: DataHandle
1159 CHARACTER*80 :: fname
1160 INTEGER :: filestate
1162 LOGICAL :: dryrun, retval
1163 call ext_pio_inquire_filename( DataHandle, fname, filestate, Status )
1164 IF ( Status /= WRF_NO_ERR ) THEN
1165 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__, &
1167 call wrf_debug ( WARN , TRIM(msg) )
1170 dryrun = ( filestate .EQ. WRF_FILE_OPENED_NOT_COMMITTED )
1171 retval = .NOT. dryrun
1173 ncd_ok_to_get_dom_ti = retval
1175 END FUNCTION ncd_ok_to_get_dom_ti
1177 subroutine initialize_pio(grid, DH)
1180 type(domain) :: grid
1181 type(wrf_data_handle), pointer :: DH
1184 integer(i4) :: communicator, pioprocs, piostart, piostride, pioshift
1186 communicator = grid%communicator
1188 if(.not. associated(DH%iosystem)) then
1189 allocate(DH%iosystem)
1194 !call pio_setdebuglevel(1)
1196 call mpi_comm_size(communicator, nprocs, ierr)
1197 call mpi_comm_rank(communicator, myrank, ierr)
1199 if(grid%pioprocs > nprocs) then
1200 !Force pioprocs to be nprocs.
1202 else if(grid%pioprocs < 1) then
1203 !Force pioprocs to be 1.
1206 pioprocs = grid%pioprocs
1209 piostride = nprocs / grid%pioprocs
1211 if((grid%pioprocs * piostride) < nprocs) then
1212 !We expect that: nprocs = piostride * grid%pioprocs
1213 piostride = piostride + 1
1216 if(piostride /= grid%piostride) then
1217 !We expect that user's piostride equals what we calculated here.
1218 !If not, override it.
1219 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
1220 write(unit=0, fmt='(a,i6)') 'Calculated piostride = ', piostride, &
1221 'User provided piostride = ', grid%piostride
1224 if(grid%pioshift < 0) then
1225 !pioshift can from 0, but can not less than 0, usually, we
1226 if(grid%piostride > 1) then
1231 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
1232 write(unit=0, fmt='(a,i6)') 'PIO has forced pioshift to: ', pioshift
1233 else if(grid%pioshift >= grid%piostride) then
1234 !pioshift can not large then piostride
1235 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
1236 write(unit=0, fmt='(a,i6)') 'User provided a pioshift of: ', grid%pioshift
1237 if(grid%piostride > 1) then
1242 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
1243 write(unit=0, fmt='(a,i6)') 'PIO has forced pioshift to: ', pioshift
1245 pioshift = grid%pioshift
1248 if(grid%piostart < 0) then
1249 !Force piostart from 0
1250 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
1251 write(unit=0, fmt='(a,i6)') 'User provided a piostart of: ', grid%piostart
1252 write(unit=0, fmt='(a,i6)') 'PIO has forced piosstart to: ', 0
1255 piostart = grid%piostart
1258 !write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
1259 !write(unit=0, fmt='(2(a,i6))') 'nprocs = ', nprocs, ', myrank = ', myrank
1260 !write(unit=0, fmt='(4(a,i6))') 'pioprocs = ', pioprocs, &
1261 ! ', piostride = ', piostride, &
1262 ! ', piostart = ', piostart, &
1263 ! ', pioshift = ', pioshift
1265 !call PIO_init to initiate iosystem
1266 !call PIO_init(my_rank, MPI_COMM_WORLD, 4, 0, 4, PIO_rearr_box, iosystem, 1)
1267 !call PIO_init(myrank, MPI_COMM_WORLD, pioprocs, &
1269 call PIO_init(myrank, communicator, pioprocs, &
1270 piostart, piostride, &
1271 PIO_rearr_box, DH%iosystem, pioshift)
1276 DH%piostart = piostart
1277 DH%pioshift = pioshift
1278 DH%pioprocs = pioprocs
1279 DH%piostride = piostride
1281 call get_ijk_from_grid(grid, &
1282 ids, ide, jds, jde, kds, kde, &
1283 ims, ime, jms, jme, kms, kme, &
1284 its, ite, jts, jte, kts, kte)
1286 end subroutine initialize_pio
1288 subroutine define_pio_iodesc(grid, DH)
1291 type(domain) :: grid
1292 type(wrf_data_handle), pointer :: DH
1294 integer(i4) :: communicator, myrank
1295 integer(i4) :: iostat
1297 integer(kind=PIO_Offset), &
1298 dimension((ime - ims + 1) * (jme - jms + 1) * (kme - kms + 1)) &
1300 integer(kind=PIO_Offset), &
1301 dimension((ime - ims + 1) * (jme - jms + 1) * grid%num_land_cat) &
1303 integer(kind=PIO_Offset), &
1304 dimension((ime - ims + 1) * (jme - jms + 1) * grid%num_soil_cat) &
1306 integer(kind=PIO_Offset), &
1307 dimension((ime - ims + 1) * (jme - jms + 1) * grid%num_soil_layers) &
1308 :: compdof_3d_soil_layers
1309 integer(kind=PIO_Offset), &
1310 dimension((ime - ims + 1) * (jme - jms + 1) * grid%num_ext_model_couple_dom) &
1311 :: compdof_3d_mdl_cpl
1312 integer(kind=PIO_Offset), &
1313 dimension((ime - ims + 1) * (jme - jms + 1) * grid%ensdim) &
1314 :: compdof_3d_ensemble
1315 integer(kind=PIO_Offset), &
1316 dimension((jme - jms + 1) * (kme - kms + 1) * grid%spec_bdy_width ) &
1317 :: compdof_3d_xsz, compdof_3d_xez
1318 integer(kind=PIO_Offset), &
1319 dimension((ime - ims + 1) * (kme - kms + 1) * grid%spec_bdy_width ) &
1320 :: compdof_3d_ysz, compdof_3d_yez
1321 integer(kind=PIO_Offset), &
1322 dimension((jme - jms + 1) * grid%spec_bdy_width ) &
1323 :: compdof_2d_xs, compdof_2d_xe
1324 integer(kind=PIO_Offset), &
1325 dimension((ime - ims + 1) * grid%spec_bdy_width ) &
1326 :: compdof_2d_ys, compdof_2d_ye
1327 integer(kind=PIO_Offset), &
1328 dimension((ime - ims + 1) * (jme - jms + 1)) &
1330 integer :: dims3d(3), dims2d(2), dims2di(3)
1331 integer :: dims3d_xb(3), dims2d_xb(2)
1332 integer :: dims3d_yb(3), dims2d_yb(2)
1333 integer :: dims3d_land(3), dims3d_soil(3), dims3d_soil_layers(3)
1334 integer :: dims3d_mdl_cpl(3)
1335 integer :: dims3d_ensemble(3)
1336 integer :: lite, ljte, lkte
1337 integer :: i, j, k, n, npos
1339 DH%first_operation = .false.
1340 communicator = grid%communicator
1343 !--For MASS variables
1352 if(lite > dims3d(1)) lite = dims3d(1)
1353 if(ljte > dims3d(2)) ljte = dims3d(2)
1354 if(lkte > dims3d(3)) lkte = dims3d(3)
1356 dims3d_land(1) = dims3d(1)
1357 dims3d_land(2) = dims3d(2)
1358 dims3d_land(3) = grid%num_land_cat
1360 dims3d_soil(1) = dims3d(1)
1361 dims3d_soil(2) = dims3d(2)
1362 dims3d_soil(3) = grid%num_soil_cat
1364 dims3d_soil_layers(1) = dims3d(1)
1365 dims3d_soil_layers(2) = dims3d(2)
1366 dims3d_soil_layers(3) = grid%num_soil_layers
1368 dims3d_mdl_cpl(1) = dims3d(1)
1369 dims3d_mdl_cpl(2) = dims3d(2)
1370 dims3d_mdl_cpl(3) = grid%num_ext_model_couple_dom
1372 dims3d_ensemble(1) = dims3d(1)
1373 dims3d_ensemble(2) = dims3d(2)
1374 dims3d_ensemble(3) = grid%ensdim
1376 dims2d(1) = dims3d(1)
1377 dims2d(2) = dims3d(2)
1379 dims2di(1) = dims3d(1)
1380 dims2di(2) = dims3d(2)
1383 dims3d_xb(1) = dims3d(2)
1384 dims3d_xb(2) = dims3d(3)
1385 dims3d_xb(3) = grid%spec_bdy_width
1387 dims3d_yb(1) = dims3d(1)
1388 dims3d_yb(2) = dims3d(3)
1389 dims3d_yb(3) = grid%spec_bdy_width
1391 dims2d_xb(1) = dims2d(2)
1392 dims2d_xb(2) = grid%spec_bdy_width
1394 dims2d_yb(1) = dims2d(1)
1395 dims2d_yb(2) = grid%spec_bdy_width
1397 !write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
1398 !write(unit=0, fmt='(a, 6i6)') 'dims2d = ', dims2d
1399 !write(unit=0, fmt='(a, 6i6)') 'dims3d = ', dims3d
1400 !write(unit=0, fmt='(a, 6i6)') 'dims3d_land = ', dims3d_land
1401 !write(unit=0, fmt='(a, 6i6)') 'dims3d_soil = ', dims3d_soil
1402 !write(unit=0, fmt='(a, 6i6)') 'grid%num_land_cat = ', grid%num_land_cat
1403 !write(unit=0, fmt='(a, 6i6)') 'grid%num_soil_cat = ', grid%num_soil_cat
1404 !write(unit=0, fmt='(a, 6i6)') 'grid%num_soil_layers = ', grid%num_soil_layers
1405 !write(unit=0, fmt='(a, 6i6)') 'grid%num_ext_model_couple_dom = ', grid%num_ext_model_couple_dom
1406 !write(unit=0, fmt='(a, 6i6)') 'grid%spec_bdy_width = ', grid%spec_bdy_width
1410 npos = (i - ims + 1) + (ime - ims + 1) * (j - jms)
1411 compdof_2d(npos) = 0
1416 npos = (i - ims + 1) + (ime - ims + 1) * (k - kms + (kme - kms + 1) * (j - jms))
1417 compdof_3d(npos) = 0
1421 do k = 1, dims3d_land(3)
1423 npos = (i - ims + 1) + (ime - ims + 1) * (k - 1 + dims3d_land(3) * (j - jms))
1424 compdof_3d_land(npos) = 0
1428 do k = 1, dims3d_soil(3)
1430 npos = (i - ims + 1) + (ime - ims + 1) * (k - 1 + dims3d_soil(3) * (j - jms))
1431 compdof_3d_soil(npos) = 0
1435 do k = 1, dims3d_soil_layers(3)
1437 npos = (i - ims + 1) + (ime - ims + 1) * (k - 1 + dims3d_soil_layers(3) * (j - jms))
1438 compdof_3d_soil_layers(npos) = 0
1442 do k = 1, dims3d_mdl_cpl(3)
1444 npos = (i - ims + 1) + (ime - ims + 1) * (k - 1 + dims3d_mdl_cpl(3) * (j - jms))
1445 compdof_3d_mdl_cpl(npos) = 0
1450 do n = 1, grid%spec_bdy_width
1452 npos = i - ims + 1 + (ime - ims + 1) * (n - 1)
1453 compdof_2d_ys(npos) = 0
1454 compdof_2d_ye(npos) = 0
1458 npos = j - jms + 1 + (jme - jms + 1) * (n - 1)
1459 compdof_2d_xs(npos) = 0
1460 compdof_2d_xe(npos) = 0
1465 npos = i - ims + 1 + (ime - ims + 1) * (k - kms + (kme - kms + 1) * (n - 1))
1466 compdof_3d_ysz(npos) = 0
1467 compdof_3d_yez(npos) = 0
1473 npos = j - jms + 1 + (jme - jms + 1) * (k - kms + (kme - kms + 1) * (n - 1))
1474 compdof_3d_xsz(npos) = 0
1475 compdof_3d_xez(npos) = 0
1482 npos = (i - ims + 1) + (ime - ims + 1) * (j - jms)
1483 compdof_2d(npos) = i + dims2d(1) * (j - 1)
1488 npos = (i - ims + 1) + (ime - ims + 1) * (k - kms + (kme - kms + 1) * (j - jms))
1489 compdof_3d(npos) = i + dims3d(1) * (j - 1 + dims3d(2) * (k - 1))
1493 do k = 1, dims3d_land(3)
1495 npos = (i - ims + 1) + (ime - ims + 1) * (k - 1 + dims3d_land(3) * (j - jms))
1496 compdof_3d_land(npos) = i + dims3d_land(1) * (j - 1 + dims3d_land(2) * (k - 1))
1500 do k = 1, dims3d_soil(3)
1502 npos = (i - ims + 1) + (ime - ims + 1) * (k - 1 + dims3d_soil(3) * (j - jms))
1503 compdof_3d_soil(npos) = i + dims3d_soil(1) * (j - 1 + dims3d_soil(2) * (k - 1))
1507 do k = 1, dims3d_soil_layers(3)
1509 npos = (i - ims + 1) + (ime - ims + 1) * (k - 1 + dims3d_soil_layers(3) * (j - jms))
1510 compdof_3d_soil_layers(npos) = i + dims3d_soil_layers(1) * (j - 1 + dims3d_soil_layers(2) * (k - 1))
1514 do k = 1, dims3d_mdl_cpl(3)
1516 npos = (i - ims + 1) + (ime - ims + 1) * (k - 1 + dims3d_mdl_cpl(3) * (j - jms))
1517 compdof_3d_mdl_cpl(npos) = i + dims3d_mdl_cpl(1) * (j - 1 + dims3d_mdl_cpl(2) * (k - 1))
1522 do k = 1, dims3d_ensemble(3)
1525 npos = (i - ims + 1) + (ime - ims + 1) * (j - jms + (jme - jms + 1) * (k - 1))
1526 compdof_3d_ensemble(npos) = 0
1532 npos = (i - ims + 1) + (ime - ims + 1) * (j - jms + (jme - jms + 1) * (k - 1))
1533 compdof_3d_ensemble(npos) = i + dims3d_ensemble(1) * (j - 1 + dims3d_ensemble(2) * (k - 1))
1538 !write(unit=0, fmt='(3a,i6)') 'File: ', __FILE__, ', line: ', __LINE__
1539 !write(unit=0, fmt='(4x,a,i6)') 'npos = ', npos
1540 !write(unit=0, fmt='(4x,a,i16)') 'compdof_3d_ensemble(npos) = ', compdof_3d_ensemble(npos)
1543 do n = 1, grid%spec_bdy_width
1545 npos = j - jms + 1 + (jme - jms + 1) * (n - 1)
1546 compdof_2d_xs(npos) = j + dims2d_xb(1) * (n - 1)
1552 do n = 1, grid%spec_bdy_width
1554 npos = i - ims + 1 + (ime - ims + 1) * (n - 1)
1555 compdof_2d_ys(npos) = i + dims2d_yb(1) * (n - 1)
1560 if(dims2d(1) == lite) then
1561 do n = 1, grid%spec_bdy_width
1563 npos = j - jms + 1 + (jme - jms + 1) * (n - 1)
1564 compdof_2d_xe(npos) = j + dims2d_xb(1) * (n - 1)
1569 if(dims2d(2) == ljte) then
1570 do n = 1, grid%spec_bdy_width
1572 npos = i - ims + 1 + (ime - ims + 1) * (n - 1)
1573 compdof_2d_ye(npos) = i + dims2d_yb(1) * (n - 1)
1579 do n = 1, grid%spec_bdy_width
1582 npos = j - jms + 1 + (jme - jms + 1) * (k - kms + (kme - kms + 1) * (n - 1))
1583 compdof_3d_xsz(npos) = j + dims3d_xb(1) * (k - 1 + dims3d_xb(2) * (n - 1))
1590 do n = 1, grid%spec_bdy_width
1593 npos = i - ims + 1 + (ime - ims + 1) * (k - kms + (kme - kms + 1) * (n - 1))
1594 compdof_3d_ysz(npos) = i + dims3d_yb(1) * (k - 1 + dims3d_yb(2) * (n - 1))
1600 if(dims2d(1) == lite) then
1601 do n = 1, grid%spec_bdy_width
1604 npos = j - jms + 1 + (jme - jms + 1) * (k - kms + (kme - kms + 1) * (n - 1))
1605 compdof_3d_xez(npos) = j + dims3d_xb(1) * (k - 1 + dims3d_xb(2) * (n - 1))
1611 if(dims2d(2) == ljte) then
1612 do n = 1, grid%spec_bdy_width
1615 npos = i - ims + 1 + (ime - ims + 1) * (k - kms + (kme - kms + 1) * (n - 1))
1616 compdof_3d_yez(npos) = i + dims3d_yb(1) * (k - 1 + dims3d_yb(2) * (n - 1))
1622 !--call init_decomp in order to setup the IO decomposition with PIO
1623 !call pio_setdebuglevel(1)
1625 call PIO_initdecomp(DH%iosystem, PIO_int, dims3d, compdof_3d, DH%iodesc3d_m_int)
1626 call PIO_initdecomp(DH%iosystem, PIO_real, dims3d, compdof_3d, DH%iodesc3d_m_real)
1627 call PIO_initdecomp(DH%iosystem, PIO_double, dims3d, compdof_3d, DH%iodesc3d_m_double)
1629 call PIO_initdecomp(DH%iosystem, PIO_int, dims3d_land, compdof_3d_land, DH%iodesc3d_land_int)
1630 call PIO_initdecomp(DH%iosystem, PIO_real, dims3d_land, compdof_3d_land, DH%iodesc3d_land_real)
1631 call PIO_initdecomp(DH%iosystem, PIO_double, dims3d_land, compdof_3d_land, DH%iodesc3d_land_double)
1633 call PIO_initdecomp(DH%iosystem, PIO_int, dims3d_soil, compdof_3d_soil, DH%iodesc3d_soil_int)
1634 call PIO_initdecomp(DH%iosystem, PIO_real, dims3d_soil, compdof_3d_soil, DH%iodesc3d_soil_real)
1635 call PIO_initdecomp(DH%iosystem, PIO_double, dims3d_soil, compdof_3d_soil, DH%iodesc3d_soil_double)
1637 call PIO_initdecomp(DH%iosystem, PIO_int, dims3d_soil_layers, compdof_3d_soil_layers, DH%iodesc3d_soil_layers_int)
1638 call PIO_initdecomp(DH%iosystem, PIO_real, dims3d_soil_layers, compdof_3d_soil_layers, DH%iodesc3d_soil_layers_real)
1639 call PIO_initdecomp(DH%iosystem, PIO_double, dims3d_soil_layers, compdof_3d_soil_layers, DH%iodesc3d_soil_layers_double)
1641 call PIO_initdecomp(DH%iosystem, PIO_int, dims3d_mdl_cpl, compdof_3d_mdl_cpl, DH%iodesc3d_mdl_cpl_int)
1642 call PIO_initdecomp(DH%iosystem, PIO_real, dims3d_mdl_cpl, compdof_3d_mdl_cpl, DH%iodesc3d_mdl_cpl_real)
1643 call PIO_initdecomp(DH%iosystem, PIO_double, dims3d_mdl_cpl, compdof_3d_mdl_cpl, DH%iodesc3d_mdl_cpl_double)
1645 !call pio_setdebuglevel(1)
1646 call PIO_initdecomp(DH%iosystem, PIO_int, dims3d_ensemble, compdof_3d_ensemble, DH%iodesc3d_ensemble_int)
1647 call PIO_initdecomp(DH%iosystem, PIO_real, dims3d_ensemble, compdof_3d_ensemble, DH%iodesc3d_ensemble_real)
1648 call PIO_initdecomp(DH%iosystem, PIO_double, dims3d_ensemble, compdof_3d_ensemble, DH%iodesc3d_ensemble_double)
1649 !call pio_setdebuglevel(0)
1652 call PIO_initdecomp(DH%iosystem, PIO_int, dims2d, compdof_2d, DH%iodesc2d_m_int)
1654 call PIO_initdecomp(DH%iosystem, PIO_int, dims2di, compdof_2d, DH%iodesc2d_m_int)
1656 call PIO_initdecomp(DH%iosystem, PIO_real, dims2d, compdof_2d, DH%iodesc2d_m_real)
1657 call PIO_initdecomp(DH%iosystem, PIO_double, dims2d, compdof_2d, DH%iodesc2d_m_double)
1659 call PIO_initdecomp(DH%iosystem, PIO_int, dims3d_xb, compdof_3d_xsz, DH%iodesc3d_xsz_m_int)
1660 call PIO_initdecomp(DH%iosystem, PIO_real, dims3d_xb, compdof_3d_xsz, DH%iodesc3d_xsz_m_real)
1661 call PIO_initdecomp(DH%iosystem, PIO_double, dims3d_xb, compdof_3d_xsz, DH%iodesc3d_xsz_m_double)
1663 call PIO_initdecomp(DH%iosystem, PIO_int, dims3d_xb, compdof_3d_xez, DH%iodesc3d_xez_m_int)
1664 call PIO_initdecomp(DH%iosystem, PIO_real, dims3d_xb, compdof_3d_xez, DH%iodesc3d_xez_m_real)
1665 call PIO_initdecomp(DH%iosystem, PIO_double, dims3d_xb, compdof_3d_xez, DH%iodesc3d_xez_m_double)
1667 call PIO_initdecomp(DH%iosystem, PIO_int, dims3d_yb, compdof_3d_ysz, DH%iodesc3d_ysz_m_int)
1668 call PIO_initdecomp(DH%iosystem, PIO_real, dims3d_yb, compdof_3d_ysz, DH%iodesc3d_ysz_m_real)
1669 call PIO_initdecomp(DH%iosystem, PIO_double, dims3d_yb, compdof_3d_ysz, DH%iodesc3d_ysz_m_double)
1671 call PIO_initdecomp(DH%iosystem, PIO_int, dims3d_yb, compdof_3d_yez, DH%iodesc3d_yez_m_int)
1672 call PIO_initdecomp(DH%iosystem, PIO_real, dims3d_yb, compdof_3d_yez, DH%iodesc3d_yez_m_real)
1673 call PIO_initdecomp(DH%iosystem, PIO_double, dims3d_yb, compdof_3d_yez, DH%iodesc3d_yez_m_double)
1675 call PIO_initdecomp(DH%iosystem, PIO_int, dims2d_xb, compdof_2d_xs, DH%iodesc2d_xs_m_int)
1676 call PIO_initdecomp(DH%iosystem, PIO_real, dims2d_xb, compdof_2d_xs, DH%iodesc2d_xs_m_real)
1677 call PIO_initdecomp(DH%iosystem, PIO_double, dims2d_xb, compdof_2d_xs, DH%iodesc2d_xs_m_double)
1679 call PIO_initdecomp(DH%iosystem, PIO_int, dims2d_xb, compdof_2d_xe, DH%iodesc2d_xe_m_int)
1680 call PIO_initdecomp(DH%iosystem, PIO_real, dims2d_xb, compdof_2d_xe, DH%iodesc2d_xe_m_real)
1681 call PIO_initdecomp(DH%iosystem, PIO_double, dims2d_xb, compdof_2d_xe, DH%iodesc2d_xe_m_double)
1683 call PIO_initdecomp(DH%iosystem, PIO_int, dims2d_yb, compdof_2d_ys, DH%iodesc2d_ys_m_int)
1684 call PIO_initdecomp(DH%iosystem, PIO_real, dims2d_yb, compdof_2d_ys, DH%iodesc2d_ys_m_real)
1685 call PIO_initdecomp(DH%iosystem, PIO_double, dims2d_yb, compdof_2d_ys, DH%iodesc2d_ys_m_double)
1687 call PIO_initdecomp(DH%iosystem, PIO_int, dims2d_yb, compdof_2d_ye, DH%iodesc2d_ye_m_int)
1688 call PIO_initdecomp(DH%iosystem, PIO_real, dims2d_yb, compdof_2d_ye, DH%iodesc2d_ye_m_real)
1689 call PIO_initdecomp(DH%iosystem, PIO_double, dims2d_yb, compdof_2d_ye, DH%iodesc2d_ye_m_double)
1691 !--For X-STAG variables
1700 if(lite > dims3d(1)) lite = dims3d(1)
1701 if(ljte > dims3d(2)) ljte = dims3d(2)
1702 if(lkte > dims3d(3)) lkte = dims3d(3)
1704 dims2d(1) = dims3d(1)
1705 dims2d(2) = dims3d(2)
1707 dims3d_xb(1) = dims3d(2)
1708 dims3d_xb(2) = dims3d(3)
1709 dims3d_xb(3) = grid%spec_bdy_width
1711 dims3d_yb(1) = dims3d(1)
1712 dims3d_yb(2) = dims3d(3)
1713 dims3d_yb(3) = grid%spec_bdy_width
1720 npos = (i - ims + 1) + (ime - ims + 1) * (j - jms)
1721 compdof_2d(npos) = 0
1726 npos = (i - ims + 1) + (ime - ims + 1) * (k - kms + (kme - kms + 1) * (j - jms))
1727 compdof_3d(npos) = 0
1732 do n = 1, grid%spec_bdy_width
1735 npos = i - ims + 1 + (ime - ims + 1) * (k - kms + (kme - kms + 1) * (n - 1))
1736 compdof_3d_ysz(npos) = 0
1737 compdof_3d_yez(npos) = 0
1743 npos = j - jms + 1 + (jme - jms + 1) * (k - kms + (kme - kms + 1) * (n - 1))
1744 compdof_3d_xsz(npos) = 0
1745 compdof_3d_xez(npos) = 0
1752 npos = (i - ims + 1) + (ime - ims + 1) * (j - jms)
1753 compdof_2d(npos) = i + dims2d(1) * (j - 1)
1758 npos = (i - ims + 1) + (ime - ims + 1) * (k - kms + (kme - kms + 1) * (j - jms))
1759 compdof_3d(npos) = i + dims3d(1) * (j - 1 + dims3d(2) * (k - 1))
1765 do n = 1, grid%spec_bdy_width
1768 npos = j - jms + 1 + (jme - jms + 1) * (k - kms + (kme - kms + 1) * (n - 1))
1769 compdof_3d_xsz(npos) = j + dims3d_xb(1) * (k - 1 + dims3d_xb(2) * (n - 1))
1776 do n = 1, grid%spec_bdy_width
1779 npos = i - ims + 1 + (ime - ims + 1) * (k - kms + (kme - kms + 1) * (n - 1))
1780 compdof_3d_ysz(npos) = i + dims3d_yb(1) * (k - 1 + dims3d_yb(2) * (n - 1))
1786 if(dims3d(1) == lite) then
1787 do n = 1, grid%spec_bdy_width
1790 npos = j - jms + 1 + (jme - jms + 1) * (k - kms + (kme - kms + 1) * (n - 1))
1791 compdof_3d_xez(npos) = j + dims3d_xb(1) * (k - 1 + dims3d_xb(2) * (n - 1))
1797 if(dims3d(2) == ljte) then
1798 do n = 1, grid%spec_bdy_width
1801 npos = i - ims + 1 + (ime - ims + 1) * (k - kms + (kme - kms + 1) * (n - 1))
1802 compdof_3d_yez(npos) = i + dims3d_yb(1) * (k - 1 + dims3d_yb(2) * (n - 1))
1808 !--call init_decomp in order to setup the IO decomposition with PIO
1809 call PIO_initdecomp(DH%iosystem, PIO_double, dims3d, compdof_3d, DH%iodesc3d_u_double)
1810 call PIO_initdecomp(DH%iosystem, PIO_real, dims3d, compdof_3d, DH%iodesc3d_u_real)
1811 call PIO_initdecomp(DH%iosystem, PIO_int, dims3d, compdof_3d, DH%iodesc3d_u_int)
1813 call PIO_initdecomp(DH%iosystem, PIO_double, dims2d, compdof_2d, DH%iodesc2d_u_double)
1814 call PIO_initdecomp(DH%iosystem, PIO_real, dims2d, compdof_2d, DH%iodesc2d_u_real)
1815 call PIO_initdecomp(DH%iosystem, PIO_int, dims2d, compdof_2d, DH%iodesc2d_u_int)
1817 call PIO_initdecomp(DH%iosystem, PIO_int, dims3d_xb, compdof_3d_xsz, DH%iodesc3d_xsz_u_int)
1818 call PIO_initdecomp(DH%iosystem, PIO_real, dims3d_xb, compdof_3d_xsz, DH%iodesc3d_xsz_u_real)
1819 call PIO_initdecomp(DH%iosystem, PIO_double, dims3d_xb, compdof_3d_xsz, DH%iodesc3d_xsz_u_double)
1821 call PIO_initdecomp(DH%iosystem, PIO_int, dims3d_xb, compdof_3d_xez, DH%iodesc3d_xez_u_int)
1822 call PIO_initdecomp(DH%iosystem, PIO_real, dims3d_xb, compdof_3d_xez, DH%iodesc3d_xez_u_real)
1823 call PIO_initdecomp(DH%iosystem, PIO_double, dims3d_xb, compdof_3d_xez, DH%iodesc3d_xez_u_double)
1825 call PIO_initdecomp(DH%iosystem, PIO_int, dims3d_yb, compdof_3d_ysz, DH%iodesc3d_ysz_u_int)
1826 call PIO_initdecomp(DH%iosystem, PIO_real, dims3d_yb, compdof_3d_ysz, DH%iodesc3d_ysz_u_real)
1827 call PIO_initdecomp(DH%iosystem, PIO_double, dims3d_yb, compdof_3d_ysz, DH%iodesc3d_ysz_u_double)
1829 call PIO_initdecomp(DH%iosystem, PIO_int, dims3d_yb, compdof_3d_yez, DH%iodesc3d_yez_u_int)
1830 call PIO_initdecomp(DH%iosystem, PIO_real, dims3d_yb, compdof_3d_yez, DH%iodesc3d_yez_u_real)
1831 call PIO_initdecomp(DH%iosystem, PIO_double, dims3d_yb, compdof_3d_yez, DH%iodesc3d_yez_u_double)
1833 !--For Y-STAG variables
1842 if(lite > dims3d(1)) lite = dims3d(1)
1843 if(ljte > dims3d(2)) ljte = dims3d(2)
1844 if(lkte > dims3d(3)) lkte = dims3d(3)
1846 dims2d(1) = dims3d(1)
1847 dims2d(2) = dims3d(2)
1849 dims3d_xb(1) = dims3d(2)
1850 dims3d_xb(2) = dims3d(3)
1851 dims3d_xb(3) = grid%spec_bdy_width
1853 dims3d_yb(1) = dims3d(1)
1854 dims3d_yb(2) = dims3d(3)
1855 dims3d_yb(3) = grid%spec_bdy_width
1862 npos = (i - ims + 1) + (ime - ims + 1) * (j - jms)
1863 compdof_2d(npos) = 0
1868 npos = (i - ims + 1) + (ime - ims + 1) * (k - kms + (kme - kms + 1) * (j - jms))
1869 compdof_3d(npos) = 0
1874 do n = 1, grid%spec_bdy_width
1877 npos = i - ims + 1 + (ime - ims + 1) * (k - kms + (kme - kms + 1) * (n - 1))
1878 compdof_3d_ysz(npos) = 0
1879 compdof_3d_yez(npos) = 0
1885 npos = j - jms + 1 + (jme - jms + 1) * (k - kms + (kme - kms + 1) * (n - 1))
1886 compdof_3d_xsz(npos) = 0
1887 compdof_3d_xez(npos) = 0
1894 npos = (i - ims + 1) + (ime - ims + 1) * (j - jms)
1895 compdof_2d(npos) = i + dims2d(1) * (j - 1)
1900 npos = (i - ims + 1) + (ime - ims + 1) * (k - kms + (kme - kms + 1) * (j - jms))
1901 compdof_3d(npos) = i + dims3d(1) * (j - 1 + dims3d(2) * (k - 1))
1907 do n = 1, grid%spec_bdy_width
1910 npos = j - jms + 1 + (jme - jms + 1) * (k - kms + (kme - kms + 1) * (n - 1))
1911 compdof_3d_xsz(npos) = j + dims3d_xb(1) * (k - 1 + dims3d_xb(2) * (n - 1))
1918 do n = 1, grid%spec_bdy_width
1921 npos = i - ims + 1 + (ime - ims + 1) * (k - kms + (kme - kms + 1) * (n - 1))
1922 compdof_3d_ysz(npos) = i + dims3d_yb(1) * (k - 1 + dims3d_yb(2) * (n - 1))
1928 if(dims3d(1) == lite) then
1929 do n = 1, grid%spec_bdy_width
1932 npos = j - jms + 1 + (jme - jms + 1) * (k - kms + (kme - kms + 1) * (n - 1))
1933 compdof_3d_xez(npos) = j + dims3d_xb(1) * (k - 1 + dims3d_xb(2) * (n - 1))
1939 if(dims3d(2) == ljte) then
1940 do n = 1, grid%spec_bdy_width
1943 npos = i - ims + 1 + (ime - ims + 1) * (k - kms + (kme - kms + 1) * (n - 1))
1944 compdof_3d_yez(npos) = i + dims3d_yb(1) * (k - 1 + dims3d_yb(2) * (n - 1))
1950 !--call init_decomp in order to setup the IO decomposition with PIO
1951 call PIO_initdecomp(DH%iosystem, PIO_double, dims3d, compdof_3d, DH%iodesc3d_v_double)
1952 call PIO_initdecomp(DH%iosystem, PIO_real, dims3d, compdof_3d, DH%iodesc3d_v_real)
1953 call PIO_initdecomp(DH%iosystem, PIO_int, dims3d, compdof_3d, DH%iodesc3d_v_int)
1955 call PIO_initdecomp(DH%iosystem, PIO_double, dims2d, compdof_2d, DH%iodesc2d_v_double)
1956 call PIO_initdecomp(DH%iosystem, PIO_real, dims2d, compdof_2d, DH%iodesc2d_v_real)
1957 call PIO_initdecomp(DH%iosystem, PIO_int, dims2d, compdof_2d, DH%iodesc2d_v_int)
1959 call PIO_initdecomp(DH%iosystem, PIO_int, dims3d_xb, compdof_3d_xsz, DH%iodesc3d_xsz_v_int)
1960 call PIO_initdecomp(DH%iosystem, PIO_real, dims3d_xb, compdof_3d_xsz, DH%iodesc3d_xsz_v_real)
1961 call PIO_initdecomp(DH%iosystem, PIO_double, dims3d_xb, compdof_3d_xsz, DH%iodesc3d_xsz_v_double)
1963 call PIO_initdecomp(DH%iosystem, PIO_int, dims3d_xb, compdof_3d_xez, DH%iodesc3d_xez_v_int)
1964 call PIO_initdecomp(DH%iosystem, PIO_real, dims3d_xb, compdof_3d_xez, DH%iodesc3d_xez_v_real)
1965 call PIO_initdecomp(DH%iosystem, PIO_double, dims3d_xb, compdof_3d_xez, DH%iodesc3d_xez_v_double)
1967 call PIO_initdecomp(DH%iosystem, PIO_int, dims3d_yb, compdof_3d_ysz, DH%iodesc3d_ysz_v_int)
1968 call PIO_initdecomp(DH%iosystem, PIO_real, dims3d_yb, compdof_3d_ysz, DH%iodesc3d_ysz_v_real)
1969 call PIO_initdecomp(DH%iosystem, PIO_double, dims3d_yb, compdof_3d_ysz, DH%iodesc3d_ysz_v_double)
1971 call PIO_initdecomp(DH%iosystem, PIO_int, dims3d_yb, compdof_3d_yez, DH%iodesc3d_yez_v_int)
1972 call PIO_initdecomp(DH%iosystem, PIO_real, dims3d_yb, compdof_3d_yez, DH%iodesc3d_yez_v_real)
1973 call PIO_initdecomp(DH%iosystem, PIO_double, dims3d_yb, compdof_3d_yez, DH%iodesc3d_yez_v_double)
1975 !--For Z-STAG variables
1980 dims2d(1) = dims3d(1)
1981 dims2d(2) = dims3d(2)
1983 dims3d_xb(1) = dims3d(2)
1984 dims3d_xb(2) = dims3d(3)
1985 dims3d_xb(3) = grid%spec_bdy_width
1987 dims3d_yb(1) = dims3d(1)
1988 dims3d_yb(2) = dims3d(3)
1989 dims3d_yb(3) = grid%spec_bdy_width
1995 if(lite > dims3d(1)) lite = dims3d(1)
1996 if(ljte > dims3d(2)) ljte = dims3d(2)
1997 if(lkte > dims3d(3)) lkte = dims3d(3)
2004 npos = (i - ims + 1) + (ime - ims + 1) * (k - kms + (kme - kms + 1) * (j - jms))
2005 compdof_3d(npos) = 0
2010 do n = 1, grid%spec_bdy_width
2013 npos = i - ims + 1 + (ime - ims + 1) * (k - kms + (kme - kms + 1) * (n - 1))
2014 compdof_3d_ysz(npos) = 0
2015 compdof_3d_yez(npos) = 0
2021 npos = j - jms + 1 + (jme - jms + 1) * (k - kms + (kme - kms + 1) * (n - 1))
2022 compdof_3d_xsz(npos) = 0
2023 compdof_3d_xez(npos) = 0
2031 npos = (i - ims + 1) + (ime - ims + 1) * (k - kms + (kme - kms + 1) * (j - jms))
2032 compdof_3d(npos) = i + dims3d(1) * (j - 1 + dims3d(2) * (k - 1))
2038 do n = 1, grid%spec_bdy_width
2041 npos = j - jms + 1 + (jme - jms + 1) * (k - kms + (kme - kms + 1) * (n - 1))
2042 compdof_3d_xsz(npos) = j + dims3d_xb(1) * (k - 1 + dims3d_xb(2) * (n - 1))
2049 do n = 1, grid%spec_bdy_width
2052 npos = i - ims + 1 + (ime - ims + 1) * (k - kms + (kme - kms + 1) * (n - 1))
2053 compdof_3d_ysz(npos) = i + dims3d_yb(1) * (k - 1 + dims3d_yb(2) * (n - 1))
2059 if(dims3d(1) == lite) then
2060 do n = 1, grid%spec_bdy_width
2063 npos = j - jms + 1 + (jme - jms + 1) * (k - kms + (kme - kms + 1) * (n - 1))
2064 compdof_3d_xez(npos) = j + dims3d_xb(1) * (k - 1 + dims3d_xb(2) * (n - 1))
2070 if(dims3d(2) == ljte) then
2071 do n = 1, grid%spec_bdy_width
2074 npos = i - ims + 1 + (ime - ims + 1) * (k - kms + (kme - kms + 1) * (n - 1))
2075 compdof_3d_yez(npos) = i + dims3d_yb(1) * (k - 1 + dims3d_yb(2) * (n - 1))
2081 !--call init_decomp in order to setup the IO decomposition with PIO
2082 call PIO_initdecomp(DH%iosystem, PIO_double, dims3d, compdof_3d, DH%iodesc3d_w_double)
2083 call PIO_initdecomp(DH%iosystem, PIO_real, dims3d, compdof_3d, DH%iodesc3d_w_real)
2084 call PIO_initdecomp(DH%iosystem, PIO_int, dims3d, compdof_3d, DH%iodesc3d_w_int)
2086 call PIO_initdecomp(DH%iosystem, PIO_int, dims3d_xb, compdof_3d_xsz, DH%iodesc3d_xsz_w_int)
2087 call PIO_initdecomp(DH%iosystem, PIO_real, dims3d_xb, compdof_3d_xsz, DH%iodesc3d_xsz_w_real)
2088 call PIO_initdecomp(DH%iosystem, PIO_double, dims3d_xb, compdof_3d_xsz, DH%iodesc3d_xsz_w_double)
2090 call PIO_initdecomp(DH%iosystem, PIO_int, dims3d_xb, compdof_3d_xez, DH%iodesc3d_xez_w_int)
2091 call PIO_initdecomp(DH%iosystem, PIO_real, dims3d_xb, compdof_3d_xez, DH%iodesc3d_xez_w_real)
2092 call PIO_initdecomp(DH%iosystem, PIO_double, dims3d_xb, compdof_3d_xez, DH%iodesc3d_xez_w_double)
2094 call PIO_initdecomp(DH%iosystem, PIO_int, dims3d_yb, compdof_3d_ysz, DH%iodesc3d_ysz_w_int)
2095 call PIO_initdecomp(DH%iosystem, PIO_real, dims3d_yb, compdof_3d_ysz, DH%iodesc3d_ysz_w_real)
2096 call PIO_initdecomp(DH%iosystem, PIO_double, dims3d_yb, compdof_3d_ysz, DH%iodesc3d_ysz_w_double)
2098 call PIO_initdecomp(DH%iosystem, PIO_int, dims3d_yb, compdof_3d_yez, DH%iodesc3d_yez_w_int)
2099 call PIO_initdecomp(DH%iosystem, PIO_real, dims3d_yb, compdof_3d_yez, DH%iodesc3d_yez_w_real)
2100 call PIO_initdecomp(DH%iosystem, PIO_double, dims3d_yb, compdof_3d_yez, DH%iodesc3d_yez_w_double)
2102 end subroutine define_pio_iodesc
2104 subroutine reorder (MemoryOrder,MemO)
2106 include 'wrf_status_codes.h'
2107 character*(*) ,intent(in) :: MemoryOrder
2108 character*3 ,intent(out) :: MemO
2109 character*3 :: MemOrd
2110 integer :: N,i,i1,i2,i3
2113 N = len_trim(MemoryOrder)
2115 call lowercase(MemoryOrder,MemOrd)
2116 ! never invert the boundary codes
2117 select case ( MemOrd )
2118 case ( 'xsz','xez','ysz','yez' )
2126 if(ichar(MemOrd(i:i)) < ichar(MemOrd(i1:i1))) I1 = i
2127 if(ichar(MemOrd(i:i)) > ichar(MemOrd(i3:i3))) I3 = i
2134 MemO(1:1) = MemoryOrder(i1:i1)
2135 MemO(2:2) = MemoryOrder(i2:i2)
2136 if(N == 3) MemO(3:3) = MemoryOrder(i3:i3)
2137 if(MemOrd(i1:i1) == 's' .or. MemOrd(i1:i1) == 'e') then
2138 MemO(1:N-1) = MemO(2:N)
2139 MemO(N:N ) = MemoryOrder(i1:i1)
2142 end subroutine reorder
2144 end module pio_routines