1 MODULE module_kma2netcdf_interface
3 use module_kma_wave2grid
7 USE module_driver_constants
9 use module_kma_wave2grid
11 ! implicit none !shc-wei
15 SUBROUTINE kma2netcdf_interface ( grid
, config_flags
)
17 ! IMPLICIT NONE !shc-wei
20 TYPE (grid_config_rec_type
) :: config_flags
21 TYPE(domain
), TARGET
:: grid
23 INTEGER :: sm31
, em31
, sm32
, em32
, sm33
, em33
33 call kma2netcdf_solver( grid
, config_flags
&
35 #
include "actual_args.inc"
39 end SUBROUTINE kma2netcdf_interface
42 SUBROUTINE kma2netcdf_solver( grid
, config_flags
&
43 #
include "dummy_args.inc"
46 ! IMPLICIT NONE !shc-wei
49 TYPE (grid_config_rec_type
) :: config_flags
50 TYPE(domain
), TARGET
:: grid
51 ! Definitions of dummy arguments to solve
53 #
include "dummy_decl.inc"
55 real, allocatable
:: q(:,:,:)
56 Integer :: my_proc_id
, ierr
57 Integer :: ii
, jj
,landmask_T213(428,215)
58 real :: sfc_T213(428,215)
59 !---------------------------------------------------------------------------
60 INTEGER :: ids
,ide
, jds
,jde
, kds
,kde
! domain dims.
61 INTEGER :: ims
,ime
, jms
,jme
, kms
,kme
! memory dims.
62 INTEGER :: ips
,ipe
, jps
,jpe
, kps
,kpe
! patch dims.
63 INTEGER :: its
,ite
, jts
,jte
, kts
,kte
! Tile dims.
65 INTEGER :: IGRD
, JGRD
, KGRD
, JCAP
, KMAX
, INTVL
66 !rizvi add ------------------------------------------------------------------
67 NAMELIST /kma2netcdf_parm
/ IGRD
, JGRD
, KGRD
, JCAP
, KMAX
, INTVL
69 READ (111, NML
= kma2netcdf_parm
, ERR
= 8000)
71 write(unit
=*, fmt
='(A,5(1x,/,5x,A,i6))')'kma2netcdf_parm namelist read: ',&
72 'IGRD= ',IGRD
,'JGRD= ',JGRD
,'KGRD= ',KGRD
,'JCAP = ',JCAP
,'KMAX= ',KMAX
,'INTVL= ',INTVL
85 JOUT
=(JMAX
-1)/INTVL
+1
91 MNWAV
=MEND1
*(MEND1
+1)/2
94 !rizvi add ------------------------------------------------------------------
95 CALL model_to_grid_config_rec ( grid
%id
, model_config_rec
, config_flags
)
97 call copy_dims( grid
, xp
, &
98 ids
, ide
, jds
, jde
, kds
, kde
, &
99 ims
, ime
, jms
, jme
, kms
, kme
, &
100 ips
, ipe
, jps
, jpe
, kps
, kpe
)
101 !--Compute these starting and stopping locations for each tile and number of tiles.
103 CALL set_tiles ( grid
, ids
, ide
, jds
, jde
, ips
, ipe
, jps
, jpe
)
105 call copy_tile_dims( grid
, xp
, its
, ite
, jts
, jte
, kts
, kte
)
107 allocate (q(ims
:ime
,jms
:jme
,kms
:kme
))
111 call W2GCONV(IGRD
, JGRD
, KGRD
, JCAP
, KMAX
, INTVL
, &
112 DPHI
, LMAX
, KLMAX
, MEND1
, NEND1
, JEND1
, IMAXG
, JMAXG
, &
113 IMAX
, IOUT
, JMAX
, JOUT
, IMX
, JOUTHF
, JMXGHF
, KMX2
, LMX2
, MNWAV
, &
114 ht
, psfc
, t_2
, u_2
, v_2
, q
, KMA_A
, KMA_B
, &
115 xp
%ims
, xp
%jms
, xp
%kms
, xp
%ime
, xp
%jme
, xp
%kme
,&
116 xp
%ids
, xp
%jds
, xp
%kds
, xp
%ide
, xp
%jde
, xp
%kde
,&
117 xp
%its
, xp
%jts
, xp
%kts
, xp
%ite
, xp
%jte
, xp
%kte
)
119 call W2GCONV(IGRD
, JGRD
, KGRD
, JCAP
, KMAX
, INTVL
, &
120 DPHI
, LMAX
, KLMAX
, MEND1
, NEND1
, JEND1
, IMAXG
, JMAXG
, &
121 IMAX
, IOUT
, JMAX
, JOUT
, IMX
, JOUTHF
, JMXGHF
, KMX2
, LMX2
, MNWAV
, &
122 ht(ims
,jms
),psfc(ims
,jms
),t_2(ims
,jms
,kms
),&
123 u_2(ims
,jms
,kms
), v_2(ims
,jms
,kms
), q(ims
,jms
,kms
),&
124 KMA_A(kms
),KMA_B(kms
), ims
, jms
, kms
, ime
, jme
, kme
, &
125 ids
, jds
, kds
, ide
, jde
, kde
, &
126 its
, jts
, kts
, ite
, jte
, kte
)
129 ! convert KMA pressure which is in hPa into Psacal in grid-array
130 psfc(its
:ite
,jts
:jte
) = 100. * psfc(its
:ite
,jts
:jte
)
134 call MPI_COMM_RANK( MPI_COMM_WORLD
, my_proc_id
, ierr
)
139 moist(ims
:ime
,jms
:jme
,kms
:kme
,P_qv
) = q(ims
:ime
,jms
:jme
,kms
:kme
)
141 ! Load landmask from KMA-original land mask for T213
142 if( JCAP
== 213 ) then
143 open( UNIT
= 151, file
= 'KMA_landmask_428_215', status
= 'old')
145 read(151,'(428i1)', err
=9000) (landmask_T213(ii
,jj
),ii
=1,428)
148 landmask(its
:ite
,jj
) = landmask_T213(its
:ite
,jde
-jj
+1)
150 write(unit
=*, fmt
='(A)')'read successfully landmask'
152 ! Load U10 at T213 (428x215) resolution
153 open( UNIT
= 151, file
= 'nwpgr_UUUU.2007020100', status
= 'old')
154 read(151,'(10e20.10)', err
=9000) sfc_T213
156 u10(its
:ite
,jj
) = sfc_T213(its
:ite
,jde
-jj
+1)
158 write(unit
=*, fmt
='(A)')'read successfully U10'
160 ! Load V10 at T213 (428x215) resolution
161 open( UNIT
= 151, file
= 'nwpgr_VVVV.2007020100', status
= 'old')
162 read(151,'(10e20.10)', err
=9000) sfc_T213
164 v10(its
:ite
,jj
) = sfc_T213(its
:ite
,jde
-jj
+1)
166 write(unit
=*, fmt
='(A)')'read successfully V10'
168 ! Load T2 at T213 (428x215) resolution
169 open( UNIT
= 151, file
= 'nwpgr_TTTT.2007020100', status
= 'old')
170 read(151,'(10e20.10)', err
=9000) sfc_T213
172 t2(its
:ite
,jj
) = sfc_T213(its
:ite
,jde
-jj
+1)
174 write(unit
=*, fmt
='(A)')'read successfully T2'
176 ! Load Q2 at T213 (428x215) resolution
177 open( UNIT
= 151, file
= 'nwpgr_QQQQ.2007020100', status
= 'old')
178 read(151,'(10e20.10)', err
=9000) sfc_T213
180 q2(its
:ite
,jj
) = sfc_T213(its
:ite
,jde
-jj
+1)
182 write(unit
=*, fmt
='(A)')'read successfully Q2'
184 ! Load SST at T213 (428x215) resolution
185 open( UNIT
= 151, file
= 'nwpgr_SSTT.2007020100', status
= 'old')
186 read(151,'(10e20.10)', err
=9000) sfc_T213
188 sst(its
:ite
,jj
) = sfc_T213(its
:ite
,jde
-jj
+1)
190 write(unit
=*, fmt
='(A)')'read successfully SST'
194 write(unit
=*, fmt
='(A,i3)')'Surface data is not available for T',JCAP
197 write(unit
=*, fmt
='(A)')'Job done for kma2netcdf_solver'
199 8000 write(unit
=*, fmt
='(A)')'read error on namelist unit 111'
201 9000 write(unit
=*, fmt
='(A)')'read error on unit 151'
203 END SUBROUTINE kma2netcdf_solver
205 SUBROUTINE copy_dims(grid
, xp
, &
206 ids
, ide
, jds
, jde
, kds
, kde
, &
207 ims
, ime
, jms
, jme
, kms
, kme
, &
208 ips
, ipe
, jps
, jpe
, kps
, kpe
)
209 !------------------------------------------------------------------------------
210 ! PURPOSE: Copy dimensioning information from grid structure.
212 !------------------------------------------------------------------------------
215 TYPE(domain
), INTENT(IN
) :: grid
216 TYPE (xpose_type
),INTENT(INOUT
) :: xp
! Transpose variables.
218 INTEGER, INTENT(OUT
) :: ids
,ide
, jds
,jde
, kds
,kde
! domain dims.
219 INTEGER, INTENT(OUT
) :: ims
,ime
, jms
,jme
, kms
,kme
! memory dims.
220 INTEGER, INTENT(OUT
) :: ips
,ipe
, jps
,jpe
, kps
,kpe
! patch dims.
222 !--De-reference dimension information stored in the grid data structure.
245 !--Indices for yz decomposition
248 xp
%idex
= grid
%ed31
- 1
250 xp
%jdex
= grid
%ed32
- 1
252 xp
%kdex
= grid
%ed33
- 1
275 !--Indices for xz decomposition
278 xp
%idey
= grid
%ed31
- 1
280 xp
%jdey
= grid
%ed32
- 1
282 xp
%kdey
= grid
%ed33
- 1
305 if(ipe
> ide
) ipe
= ide
306 if(jpe
> jde
) jpe
= jde
307 if(kpe
> kde
) kpe
= kde
309 ! Indices for yz decomposition
311 if(xp
%itex
> ide
) xp
%itex
= ide
312 if(xp
%jtex
> jde
) xp
%jtex
= jde
313 if(xp
%ktex
> kde
) xp
%ktex
= kde
315 if(xp
%ipex
> ide
) xp
%ipex
= ide
316 if(xp
%jpex
> jde
) xp
%jpex
= jde
317 if(xp
%kpex
> kde
) xp
%kpex
= kde
319 ! Indices for xz decomposition
321 if(xp
%itey
> ide
) xp
%itey
= ide
322 if(xp
%jtey
> jde
) xp
%jtey
= jde
323 if(xp
%ktey
> kde
) xp
%ktey
= kde
325 if(xp
%ipey
> ide
) xp
%ipey
= ide
326 if(xp
%jpey
> jde
) xp
%jpey
= jde
327 if(xp
%kpey
> kde
) xp
%kpey
= kde
329 ! Copy xpose dimensions from grid structure to xp structure.
331 !--Indices for xy decomposition
354 END SUBROUTINE copy_dims
356 SUBROUTINE copy_tile_dims( grid
, xp
, its
, ite
, jts
, jte
, kts
, kte
)
358 !------------------------------------------------------------------------------
359 ! PURPOSE: Copy tile dimensions from grid structure.
361 !------------------------------------------------------------------------------
364 TYPE(domain
), INTENT(IN
) :: grid
365 TYPE (xpose_type
),INTENT(INOUT
) :: xp
! Transpose variables.
366 INTEGER, INTENT(OUT
) :: its
,ite
, jts
,jte
, kts
,kte
! tile dims.
368 INTEGER :: ij
! Loop counter
370 ! De-reference tile indices stored in the grid data structure.
372 DO ij
= 1 , grid
%num_tiles
373 its
= grid
%i_start(ij
)
375 jts
= grid
%j_start(ij
)
387 if(xp
%ite
> xp
%ide
) xp
%ite
= xp
%ide
388 if(xp
%jte
> xp
%jde
) xp
%jte
= xp
%jde
389 if(xp
%kte
> xp
%kde
) xp
%kte
= xp
%kde
391 if(ite
> xp
%ide
) ite
= xp
%ide
392 if(jte
> xp
%jde
) jte
= xp
%jde
393 if(kte
> xp
%kde
) kte
= xp
%kde
395 write(unit
=*, fmt
='(/)')
396 write(unit
=*, fmt
='(A,i3,A,5x,3(i3,A,i3,5x))') 'Tile ',ij
, &
397 ' size:', its
,':',ite
, jts
,':',jte
, kts
,':',kte
399 END SUBROUTINE copy_tile_dims
401 END MODULE module_kma2netcdf_interface