52 integer,
parameter :: grads_vars_limit = 1000
53 integer,
parameter :: num_item_list = 17
54 integer,
parameter :: num_item_list_atom = 17
55 integer,
parameter :: num_item_list_land = 11
56 integer,
parameter :: num_item_list_ocean = 9
57 logical :: data_available(num_item_list_atom,3)
58 character(len=H_SHORT) :: item_list_atom (num_item_list_atom)
59 character(len=H_SHORT) :: item_list_land (num_item_list_land)
60 character(len=H_SHORT) :: item_list_ocean(num_item_list_ocean)
61 data item_list_atom /
'lon',
'lat',
'plev',
'U',
'V',
'T',
'HGT',
'QV',
'RH',
'MSLP',
'PSFC',
'U10',
'V10',
'T2',
'Q2',
'RH2',
'TOPO' /
62 data item_list_land /
'lsmask',
'lon',
'lat',
'lon_sfc',
'lat_sfc',
'llev', &
63 'STEMP',
'SMOISVC',
'SMOISDS',
'SKINT',
'TOPO' /
64 data item_list_ocean /
'lsmask',
'lon',
'lat',
'lon_sfc',
'lat_sfc',
'lon_sst',
'lat_sst',
'SKINT',
'SST'/
66 integer,
parameter :: ia_lon = 1
67 integer,
parameter :: ia_lat = 2
68 integer,
parameter :: ia_p = 3
69 integer,
parameter :: ia_u = 4
70 integer,
parameter :: ia_v = 5
71 integer,
parameter :: ia_t = 6
72 integer,
parameter :: ia_hgt = 7
73 integer,
parameter :: ia_qv = 8
74 integer,
parameter :: ia_rh = 9
75 integer,
parameter :: ia_slp = 10
76 integer,
parameter :: ia_ps = 11
77 integer,
parameter :: ia_u10 = 12
78 integer,
parameter :: ia_v10 = 13
79 integer,
parameter :: ia_t2 = 14
80 integer,
parameter :: ia_q2 = 15
81 integer,
parameter :: ia_rh2 = 16
82 integer,
parameter :: ia_topo = 17
84 integer,
parameter :: il_lsmask = 1
85 integer,
parameter :: il_lon = 2
86 integer,
parameter :: il_lat = 3
87 integer,
parameter :: il_lon_sfc = 4
88 integer,
parameter :: il_lat_sfc = 5
89 integer,
parameter :: il_lz = 6
90 integer,
parameter :: il_stemp = 7
91 integer,
parameter :: il_smoisvc = 8
92 integer,
parameter :: il_smoisds = 9
93 integer,
parameter :: il_skint = 10
94 integer,
parameter :: il_topo = 11
96 integer,
parameter :: io_lsmask = 1
97 integer,
parameter :: io_lon = 2
98 integer,
parameter :: io_lat = 3
99 integer,
parameter :: io_lon_sfc = 4
100 integer,
parameter :: io_lat_sfc = 5
101 integer,
parameter :: io_lon_sst = 6
102 integer,
parameter :: io_lat_sst = 7
103 integer,
parameter :: io_skint = 8
104 integer,
parameter :: io_sst = 9
107 integer,
parameter :: lvars_limit = 1000
108 real(RP),
parameter :: large_number_one = 9.999e+15_rp
111 character(len=H_SHORT) :: upper_qv_type =
"ZERO" 115 character(len=H_SHORT) :: grads_item (num_item_list,3)
116 character(len=H_LONG) :: grads_dtype (num_item_list,3)
117 character(len=H_LONG) :: grads_fname (num_item_list,3)
118 character(len=H_SHORT) :: grads_fendian (num_item_list,3)
119 character(len=H_SHORT) :: grads_yrev (num_item_list,3)
120 real(RP) :: grads_swpoint (num_item_list,3)
121 real(RP) :: grads_dd (num_item_list,3)
122 integer :: grads_lnum (num_item_list,3)
123 real(RP) :: grads_lvars (lvars_limit,num_item_list,3)
124 integer :: grads_startrec(num_item_list,3)
125 integer :: grads_totalrec(num_item_list,3)
126 integer :: grads_knum (num_item_list,3)
127 real(SP) :: grads_missval (num_item_list,3)
129 real(SP),
allocatable :: gdata2d(:,:)
130 real(SP),
allocatable :: gdata3d(:,:,:)
131 real(SP),
allocatable :: gland2d(:,:)
132 real(SP),
allocatable :: gland3d(:,:,:)
133 real(SP),
allocatable :: gsst2d (:,:)
135 integer :: io_fid_grads_nml = -1
136 integer :: io_fid_grads_data = -1
140 integer :: outer_nx = -1
141 integer :: outer_ny = -1
142 integer :: outer_nz = -1
143 integer :: outer_nl = -1
145 integer :: outer_nx_sfc = -1
146 integer :: outer_ny_sfc = -1
148 integer :: outer_nx_sst = -1
149 integer :: outer_ny_sst = -1
151 namelist / nml_grads_grid / &
161 character(len=H_SHORT) :: item
163 character(len=H_SHORT) :: dtype
164 character(len=H_LONG) :: fname
168 real(RP) :: lvars(lvars_limit) = large_number_one
172 character(len=H_SHORT) :: fendian=
'big' 173 character(len=H_SHORT) :: yrev=
'off' 185 integer,
intent(out) :: dims(6)
186 character(len=H_LONG),
intent(in) :: basename
189 namelist / param_mkinit_real_grads / &
198 if(
io_l )
write(
io_fid_log,*)
'+++ Real Case/Atom Input File Type: GrADS format' 202 read(
io_fid_conf,nml=param_mkinit_real_grads,iostat=ierr)
205 if(
io_l )
write(
io_fid_log,*)
'xxx Not appropriate names in namelist PARAM_MKINIT_REAL_GrADS. Check!' 211 if ( len_trim(basename) == 0 )
then 213 'xxx "BASENAME_ORG" is not specified in "PARAM_MKINIT_REAL_ATMOS"!',trim(basename)
219 open( io_fid_grads_nml, &
220 file = trim(basename), &
221 form =
'formatted', &
225 if ( ierr /= 0 )
then 226 if(
io_l )
write(
io_fid_log,*)
'xxx Input file is not found! ', trim(basename)
230 read(io_fid_grads_nml,nml=nml_grads_grid,iostat=ierr)
232 if(
io_l )
write(
io_fid_log,*)
'xxx Not appropriate names in nml_grads_grid in ', trim(basename),
'. Check!' 246 allocate( gdata2d( dims(2), dims(3) ) )
247 allocate( gdata3d( dims(2), dims(3), dims(1) ) )
253 grads_swpoint(:,1), &
256 grads_lvars(:,:,1), &
257 grads_startrec(:,1), &
258 grads_totalrec(:,1), &
261 grads_fendian(:,1), &
262 grads_missval(:,1), &
263 data_available(:,1), &
265 num_item_list_atom, &
269 close( io_fid_grads_nml )
271 do ielem = 1, num_item_list_atom
272 item = item_list_atom(ielem)
274 select case(trim(item))
276 if (.not. data_available(ia_qv,1))
then 277 if (.not.data_available(ia_rh,1))
then 278 if(
io_l )
write(
io_fid_log,*)
'xxx Not found in grads namelist! : QV and RH' 285 if (.not. data_available(ia_qv,1))
then 286 if(data_available(ia_rh,1))
then 287 if ((.not. data_available(ia_t,1)).or.(.not. data_available(ia_p,1)))
then 288 if(
io_l )
write(
io_fid_log,*)
'xxx Temperature and pressure are required to convert from RH to QV ! ' 294 if(
io_l )
write(
io_fid_log,*)
'xxx Not found in grads namelist! : QV and RH' 298 case(
'MSLP',
'PSFC',
'U10',
'V10',
'T2')
299 if (.not. data_available(ielem,1))
then 300 if (
io_l)
write(
io_fid_log,*)
'warning: ',trim(item),
' is not found & will be estimated.' 304 if ( .not. data_available(ia_q2,1) )
then 305 if (
io_l)
write(
io_fid_log,*)
'warning: Q2 is not found & will be estimated.' 309 if ( data_available(ia_q2,1) )
then 312 if ( data_available(ia_rh2,1) )
then 313 if ((.not. data_available(ia_t2,1)).or.(.not. data_available(ia_ps,1)))
then 314 if (
io_l)
write(
io_fid_log,*)
'warning: T2 and PSFC are required to convert from RH2 to Q2 !' 315 if (
io_l)
write(
io_fid_log,*)
' Q2 will be copied from data at above level.' 316 data_available(ia_rh2,1) = .false.
320 if (
io_l)
write(
io_fid_log,*)
'warning: Q2 and RH2 are not found, Q2 will be estimated.' 325 if ( .not. data_available(ielem,1) )
then 326 if (
io_l)
write(
io_fid_log,*)
'warning: ',trim(item),
' is not found & not used.' 330 if ( .not. data_available(ielem,1) )
then 331 if(
io_l )
write(
io_fid_log,*)
'xxx Not found in grads namelist! : ',trim(item_list_atom(ielem))
345 if(
io_l )
write(
io_fid_log,*)
'+++ ScaleLib/IO[realinput]/Categ[AtomOpenGrADS]' 374 psat => atmos_saturation_psat_liq
378 real(RP),
intent(out) :: velz_org(:,:,:)
379 real(RP),
intent(out) :: velx_org(:,:,:)
380 real(RP),
intent(out) :: vely_org(:,:,:)
381 real(RP),
intent(out) :: pres_org(:,:,:)
382 real(RP),
intent(out) :: temp_org(:,:,:)
383 real(RP),
intent(out) :: qtrc_org(:,:,:,:)
384 real(RP),
intent(out) :: lon_org(:,:)
385 real(RP),
intent(out) :: lat_org(:,:)
386 real(RP),
intent(out) :: cz_org(:,:,:)
387 character(len=*),
intent(in) :: basename_num
388 integer,
intent(in) :: dims(6)
389 integer,
intent(in) :: nt
391 real(RP) :: rhprs_org(dims(1)+2,dims(2),dims(3))
392 real(RP) :: pott(dims(2),dims(3))
398 character(len=H_LONG) :: gfile
400 integer :: QA_outer = 1
401 real(RP) :: p_sat, qm, rhsfc
403 integer :: i, j, k, ielem
407 if(
io_l )
write(
io_fid_log,*)
'+++ ScaleLib/IO[realinput]/Categ[AtomInputGrADS]' 412 loop_inputatomgrads :
do ielem = 1, num_item_list_atom
414 if ( .not. data_available(ielem,1) ) cycle
416 item = grads_item(ielem,1)
417 dtype = grads_dtype(ielem,1)
418 fname = grads_fname(ielem,1)
419 lnum = grads_lnum(ielem,1)
421 if ( dims(1) < grads_knum(ielem,1) )
then 422 write(*,*)
'xxx "knum" must be less than or equal to outer_nz. knum:',knum,
'> outer_nz:',dims(1),trim(item)
424 else if ( grads_knum(ielem,1) > 0 )
then 425 knum = grads_knum(ielem,1)
430 select case (trim(dtype))
432 swpoint = grads_swpoint(ielem,1)
433 dd = grads_dd(ielem,1)
434 if( (abs(swpoint-large_number_one)<eps).or.(abs(dd-large_number_one)<eps) )
then 435 write(*,*)
'xxx "swpoint" is required in grads namelist! ',swpoint
436 write(*,*)
'xxx "dd" is required in grads namelist! ',dd
441 write(*,*)
'xxx "lnum" is required in grads namelist for levels data! ' 445 lvars(k)=grads_lvars(k,ielem,1)
447 if(abs(lvars(1)-large_number_one)<eps)
then 448 write(*,*)
'xxx "lvars" must be specified in grads namelist for levels data! ' 452 startrec = grads_startrec(ielem,1)
453 totalrec = grads_totalrec(ielem,1)
454 fendian = grads_fendian(ielem,1)
455 yrev = grads_yrev(ielem,1)
456 if( (startrec<0).or.(totalrec<0) )
then 457 write(*,*)
'xxx "startrec" is required in grads namelist! ',startrec
458 write(*,*)
'xxx "totalrec" is required in grads namelist! ',totalrec
462 if(io_fid_grads_data < 0)
then 465 gfile=trim(fname)//trim(basename_num)//
'.grd' 466 if( len_trim(fname)==0 )
then 467 write(*,*)
'xxx "fname" is required in grads namelist for map data! ',trim(fname)
473 select case (trim(item))
475 if ( trim(dtype) ==
"linear" )
then 478 lon_org(i,j) =
real(swpoint+real(i-1)*dd, kind=RP) * D2R
481 else if ( trim(dtype) ==
"map" )
then 482 call read_grads_file_2d(io_fid_grads_data,gfile,dims(2),dims(3),1,1,item,startrec,totalrec,yrev,gdata2d)
483 lon_org(:,:) =
real(gdata2D(:,:), kind=RP) * D2R
486 if ( trim(dtype) ==
"linear" )
then 489 lat_org(i,j) =
real(swpoint+real(j-1)*dd, kind=RP) * D2R
492 else if ( trim(dtype) ==
"map" )
then 493 call read_grads_file_2d(io_fid_grads_data,gfile,dims(2),dims(3),1,1,item,startrec,totalrec,yrev,gdata2d)
494 lat_org(:,:) =
real(gdata2D(:,:), kind=RP) * D2R
497 if(dims(1)/=knum)
then 498 write(*,*)
'xxx "knum" must be equal to outer_nz for plev. knum:',knum,
'> outer_nz:',dims(1)
501 if ( trim(dtype) ==
"levels" )
then 502 if(dims(1)/=lnum)
then 503 write(*,*)
'xxx lnum must be same as the outer_nz for plev! ',dims(1),lnum
509 pres_org(k+2,i,j) =
real(lvars(k), kind=
rp)
513 else if ( trim(dtype) ==
"map" )
then 514 call read_grads_file_3d(io_fid_grads_data,gfile,dims(2),dims(3),dims(1),nt,item,startrec,totalrec,yrev,gdata3d)
518 pres_org(k+2,i,j) =
real(gdata3D(i,j,k), kind=
rp)
524 if ( trim(dtype) ==
"map" )
then 525 call read_grads_file_3d(io_fid_grads_data,gfile,dims(2),dims(3),knum,nt,item,startrec,totalrec,yrev,gdata3d)
528 velx_org(1:2,i,j) = 0.0_rp
530 velx_org(k+2,i,j) =
real(gdata3D(i,j,k), kind=
rp)
533 do k = knum+1, dims(1)
534 velx_org(k+2,i,j) = velx_org(knum+2,i,j)
541 if ( trim(dtype) ==
"map" )
then 542 call read_grads_file_3d(io_fid_grads_data,gfile,dims(2),dims(3),knum,nt,item,startrec,totalrec,yrev,gdata3d)
545 vely_org(1:2,i,j) = 0.0_rp
547 vely_org(k+2,i,j) =
real(gdata3D(i,j,k), kind=
rp)
550 do k = knum+1, dims(1)
551 vely_org(k+2,i,j) = vely_org(knum+2,i,j)
558 if ( trim(dtype) ==
"map" )
then 559 call read_grads_file_3d(io_fid_grads_data,gfile,dims(2),dims(3),knum,nt,item,startrec,totalrec,yrev,gdata3d)
563 temp_org(k+2,i,j) =
real(gdata3D(i,j,k), kind=
rp)
566 do k = knum+1, dims(1)
567 temp_org(k+2,i,j) = temp_org(knum+2,i,j)
574 if(dims(1)/=knum)
then 575 write(*,*)
'xxx The number of levels for HGT must be same as plevs! knum:',knum,
'> outer_nz:',dims(1)
578 if ( trim(dtype) ==
"map" )
then 579 call read_grads_file_3d(io_fid_grads_data,gfile,dims(2),dims(3),dims(1),nt,item,startrec,totalrec,yrev,gdata3d)
583 cz_org(k+2,i,j) =
real(gdata3D(i,j,k), kind=
rp)
585 cz_org(1,i,j) = 0.0_rp
590 if ( trim(dtype) ==
"map" )
then 591 call read_grads_file_3d(io_fid_grads_data,gfile,dims(2),dims(3),knum,nt,item,startrec,totalrec,yrev,gdata3d)
595 qtrc_org(k+2,i,j,qa_outer) =
real(gdata3D(i,j,k), kind=
rp)
597 qtrc_org(1:2,i,j,qa_outer) = qtrc_org(3,i,j,qa_outer)
600 if( dims(1)>knum )
then 601 select case ( upper_qv_type )
605 do k = knum+1, dims(1)
606 qtrc_org(k+2,i,j,qa_outer) = qtrc_org(knum+2,i,j,qa_outer)
613 write(*,*)
'xxx upper_qv_type in PARAM_MKINIT_REAL_GrADS is invalid! ', upper_qv_type
619 if (data_available(ia_qv,1)) cycle
620 if ( trim(dtype) ==
"map" )
then 621 call read_grads_file_3d(io_fid_grads_data,gfile,dims(2),dims(3),knum,nt,item,startrec,totalrec,yrev,gdata3d)
625 rhprs_org(k+2,i,j) =
real(gdata3D(i,j,k), kind=RP) / 100.0_RP
626 call psat( p_sat, temp_org(k+2,i,j) )
627 qm = epsvap * rhprs_org(k+2,i,j) * p_sat &
628 / ( pres_org(k+2,i,j) - rhprs_org(k+2,i,j) * p_sat )
629 qtrc_org(k+2,i,j,qa_outer) = qm / ( 1.0_rp + qm )
631 qtrc_org(1:2,i,j,qa_outer) = qtrc_org(3,i,j,qa_outer)
634 if( dims(3)>knum )
then 635 select case ( upper_qv_type )
639 do k = knum+1, dims(1)
640 rhprs_org(k+2,i,j) = rhprs_org(knum+2,i,j)
641 call psat( p_sat, temp_org(k+2,i,j) )
642 qm = epsvap * rhprs_org(k+2,i,j) * p_sat &
643 / ( pres_org(k+2,i,j) - rhprs_org(k+2,i,j) * p_sat )
644 qtrc_org(k+2,i,j,qa_outer) = qm / ( 1.0_rp + qm )
645 qtrc_org(k+2,i,j,qa_outer) = min(qtrc_org(k+2,i,j,qa_outer),qtrc_org(k+1,i,j,qa_outer))
652 write(*,*)
'xxx upper_qv_type in PARAM_MKINIT_REAL_GrADS is invalid! ', upper_qv_type
658 if ( trim(dtype) ==
"map" )
then 659 call read_grads_file_2d(io_fid_grads_data,gfile,dims(2),dims(3),1,nt,item,startrec,totalrec,yrev,gdata2d)
662 pres_org(1,i,j) =
real(gdata2D(i,j), kind=
rp)
667 if ( trim(dtype) ==
"map" )
then 668 call read_grads_file_2d(io_fid_grads_data,gfile,dims(2),dims(3),1,nt,item,startrec,totalrec,yrev,gdata2d)
671 pres_org(2,i,j) =
real(gdata2D(i,j), kind=
rp)
676 if ( trim(dtype) ==
"map" )
then 677 call read_grads_file_2d(io_fid_grads_data,gfile,dims(2),dims(3),1,nt,item,startrec,totalrec,yrev,gdata2d)
680 velx_org(2,i,j) =
real(gdata2D(i,j), kind=
rp)
685 if ( trim(dtype) ==
"map" )
then 686 call read_grads_file_2d(io_fid_grads_data,gfile,dims(2),dims(3),1,nt,item,startrec,totalrec,yrev,gdata2d)
689 vely_org(2,i,j) =
real(gdata2D(i,j), kind=
rp)
694 if ( trim(dtype) ==
"map" )
then 695 call read_grads_file_2d(io_fid_grads_data,gfile,dims(2),dims(3),1,nt,item,startrec,totalrec,yrev,gdata2d)
698 temp_org(2,i,j) =
real(gdata2D(i,j), kind=
rp)
703 if ( trim(dtype) ==
"map" )
then 704 call read_grads_file_2d(io_fid_grads_data,gfile,dims(2),dims(3),1,nt,item,startrec,totalrec,yrev,gdata2d)
707 qtrc_org(2,i,j,qa_outer) =
real(gdata2D(i,j), kind=
rp)
712 if (data_available(ia_q2,1)) cycle
713 if ( trim(dtype) ==
"map" )
then 714 call read_grads_file_2d(io_fid_grads_data,gfile,dims(2),dims(3),1,nt,item,startrec,totalrec,yrev,gdata2d)
717 rhsfc =
real(gdata2D(i,j), kind=RP) / 100.0_RP
718 call psat( p_sat, temp_org(2,i,j) )
719 qm = epsvap * rhsfc * p_sat &
720 / ( pres_org(2,i,j) - rhsfc * p_sat )
721 qtrc_org(2,i,j,qa_outer) = qm / ( 1.0_rp + qm )
726 if ( trim(dtype) ==
"map" )
then 727 call read_grads_file_2d(io_fid_grads_data,gfile,dims(2),dims(3),1,nt,item,startrec,totalrec,yrev,gdata2d)
730 cz_org(2,i,j) =
real(gdata2D(i,j), kind=
rp)
735 enddo loop_inputatomgrads
741 if ( data_available(ia_t2,1) .and. data_available(ia_ps,1) )
then 744 pott(i,j) = temp_org(2,i,j) * (p00/pres_org(2,i,j))**rovcp
750 pott(i,j) = temp_org(3,i,j) * (p00/pres_org(3,i,j))**rovcp
755 if ( .not. data_available(ia_t2,1) )
then 756 if ( data_available(ia_ps,1) )
then 759 temp_org(2,i,j) = pott(i,j) * (pres_org(2,i,j)/p00)**rovcp
763 if ( data_available(ia_topo,1) )
then 766 temp_org(2,i,j) = temp_org(3,i,j) &
767 + laps * (cz_org(3,i,j)-cz_org(2,i,j))
773 temp_org(2,i,j) = temp_org(3,i,j)
780 if ( .not. data_available(ia_ps,1) )
then 783 pres_org(2,i,j) = p00 * (temp_org(2,i,j)/pott(i,j))**cpovr
788 if ( data_available(ia_slp,1) )
then 791 temp_org(1,i,j) = pott(i,j) * (pres_org(1,i,j)/p00)**rovcp
795 if ( data_available(ia_t2,1) .and. data_available(ia_topo,1) )
then 798 temp_org(1,i,j) = temp_org(2,i,j) + laps * cz_org(2,i,j)
804 temp_org(1,i,j) = temp_org(3,i,j) + laps * cz_org(3,i,j)
810 pres_org(1,i,j) = p00 * (temp_org(1,i,j)/pott(i,j))**cpovr
815 if ( .not. data_available(ia_topo,1) )
then 819 cz_org(2,i,j) = max( 0.0_rp, &
821 * (
log(pres_org(2,i,j)/pres_org(1,i,j)) ) &
822 / (
log(pres_org(3,i,j)/pres_org(1,i,j)) ) )
835 if( pres_org(k,i,j)>pres_org(2,i,j) )
then 837 velx_org(k,i,j)=velx_org(2,i,j)
838 vely_org(k,i,j)=vely_org(2,i,j)
839 temp_org(k,i,j)=temp_org(2,i,j)
840 qtrc_org(k,i,j,:)=qtrc_org(2,i,j,:)
841 cz_org(k,i,j)=cz_org(2,i,j)
876 use_file_landwater, &
880 integer,
intent(out) :: ldims(3)
881 logical,
intent(out) :: use_waterratio
882 logical,
intent(in) :: use_file_landwater
883 character(len=*),
intent(in) :: basename
891 if(
io_l )
write(
io_fid_log,*)
'+++ Real Case/Land Input File Type: GrADS format' 894 use_waterratio = .false.
896 if ( len_trim(basename) == 0 )
then 898 'xxx "BASEMAAME" is not specified in "PARAM_MKINIT_REAL_ATOMS"!',trim(basename)
904 open( io_fid_grads_nml, &
905 file = trim(basename), &
906 form =
'formatted', &
910 if ( ierr /= 0 )
then 911 if(
io_l )
write(
io_fid_log,*)
'xxx Input file is not found! ', trim(basename)
915 read(io_fid_grads_nml,nml=nml_grads_grid,iostat=ierr)
917 if(
io_l )
write(
io_fid_log,*)
'xxx Not appropriate names in nml_grads_grid in ', trim(basename),
'. Check!' 924 if(outer_nx_sfc > 0)
then 925 ldims(2) = outer_nx_sfc
928 outer_nx_sfc = outer_nx
930 if(outer_ny_sfc > 0)
then 931 ldims(3) = outer_ny_sfc
934 outer_ny_sfc = outer_ny
937 allocate( gland2d( ldims(2), ldims(3) ) )
938 allocate( gland3d( ldims(2), ldims(3), ldims(1) ) )
944 grads_swpoint(:,2), &
947 grads_lvars(:,:,2), &
948 grads_startrec(:,2), &
949 grads_totalrec(:,2), &
952 grads_fendian(:,2), &
953 grads_missval(:,2), &
954 data_available(:,2), &
956 num_item_list_land, &
960 close( io_fid_grads_nml )
962 do ielem = 1, num_item_list_land
963 item = item_list_land(ielem)
965 select case(trim(item))
966 case(
'TOPO',
'lsmask')
967 if ( .not. data_available(ielem,2) )
then 968 if (
io_l)
write(
io_fid_log,*)
'warning: ',trim(item),
' is not found & not used.' 971 case(
'lon',
'lat',
'lon_sfc',
'lat_sfc')
973 case(
'SMOISVC',
'SMOISDS')
974 if ( use_file_landwater )
then 975 if (.not. data_available(il_smoisvc,2) .and. .not. data_available(il_smoisds,2))
then 976 if(
io_l )
write(
io_fid_log,*)
'xxx Not found in grads namelist! : ',trim(item_list_land(ielem))
979 use_waterratio = data_available(il_smoisds,2)
984 if ( .not. data_available(ielem,2) )
then 985 if(
io_l )
write(
io_fid_log,*)
'xxx Not found in grads namelist! : ',trim(item_list_land(ielem))
1007 use_file_landwater, &
1016 real(RP),
intent(out) :: tg_org (:,:,:)
1017 real(RP),
intent(out) :: strg_org (:,:,:)
1018 real(RP),
intent(out) :: smds_org (:,:,:)
1019 real(RP),
intent(out) :: lst_org (:,:)
1020 real(RP),
intent(out) :: llon_org (:,:)
1021 real(RP),
intent(out) :: llat_org (:,:)
1022 real(RP),
intent(out) :: lz_org (:)
1023 real(RP),
intent(out) :: topo_org(:,:)
1024 real(RP),
intent(out) :: lmask_org(:,:)
1026 character(len=*),
intent(in) :: basename_num
1027 integer,
intent(in) :: ldims(3)
1028 logical,
intent(in) :: use_file_landwater
1029 integer,
intent(in) :: nt
1033 character(len=H_LONG) :: gfile
1035 real(RP) :: qvsat, qm
1037 integer :: i, j, k, ielem, n
1042 if(
io_l )
write(
io_fid_log,*)
'+++ ScaleLib/IO[realinput]/Categ[LandInputGrADS]' 1045 loop_inputlandgrads :
do ielem = 1, num_item_list_land
1047 item = item_list_land(ielem)
1049 dtype = grads_dtype(ielem,2)
1050 fname = grads_fname(ielem,2)
1051 lnum = grads_lnum(ielem,2)
1052 missval = grads_missval(ielem,2)
1054 if ( grads_knum(ielem,2) > 0 )
then 1055 knum = grads_knum(ielem,2)
1060 select case (trim(dtype))
1062 swpoint = grads_swpoint(ielem,2)
1063 dd = grads_dd(ielem,2)
1064 if( (abs(swpoint-large_number_one)<eps).or.(abs(dd-large_number_one)<eps) )
then 1065 write(*,*)
'xxx "swpoint" is required in grads namelist! ',swpoint
1066 write(*,*)
'xxx "dd" is required in grads namelist! ',dd
1071 write(*,*)
'xxx "lnum" in grads namelist is required for levels data! ' 1075 lvars(k)=grads_lvars(k,ielem,2)
1077 if(abs(lvars(1)-large_number_one)<eps)
then 1078 write(*,*)
'xxx "lvars" must be specified in grads namelist for levels data!',(lvars(k),k=1,lnum)
1082 startrec = grads_startrec(ielem,2)
1083 totalrec = grads_totalrec(ielem,2)
1084 fendian = grads_fendian(ielem,2)
1085 yrev = grads_yrev(ielem,2)
1086 if( (startrec<0).or.(totalrec<0) )
then 1087 write(*,*)
'xxx "startrec" is required in grads namelist! ',startrec
1088 write(*,*)
'xxx "totalrec" is required in grads namelist! ',totalrec
1092 if(io_fid_grads_data < 0)
then 1095 gfile=trim(fname)//trim(basename_num)//
'.grd' 1096 if( len_trim(fname)==0 )
then 1097 write(*,*)
'xxx "fname" is required in grads namelist for map data! ',trim(fname)
1103 select case (trim(item))
1105 if ( data_available(il_lsmask,2) )
then 1106 if ( trim(dtype) ==
"map" )
then 1107 call read_grads_file_2d(io_fid_grads_data,gfile,ldims(2),ldims(3),1,1,item,startrec,totalrec,yrev,gland2d)
1108 lmask_org(:,:) =
real(gland2D(:,:), kind=
rp)
1114 if ( .not. data_available(il_lon_sfc,2) )
then 1115 if ( ldims(2).ne.outer_nx .or. ldims(3).ne.outer_ny )
then 1116 write(*,*)
'xxx namelist of "lon_sfc" is not found in grads namelist!' 1117 write(*,*)
'xxx dimension is different: outer_nx and outer_nx_sfc! ', outer_nx, ldims(2)
1118 write(*,*)
' : outer_ny and outer_ny_sfc! ', outer_ny, ldims(3)
1121 if ( trim(dtype) ==
"linear" )
then 1124 llon_org(i,j) =
real(swpoint+real(i-1)*dd, kind=RP) * D2R
1127 else if ( trim(dtype) ==
"map" )
then 1128 call read_grads_file_2d(io_fid_grads_data,gfile,ldims(2),ldims(3),1,1,item,startrec,totalrec,yrev,gland2d)
1129 llon_org(:,:) =
real(gland2D(:,:), kind=RP) * D2R
1133 if ( .not. data_available(il_lon_sfc,2) ) cycle
1134 if ( trim(dtype) ==
"linear" )
then 1137 llon_org(i,j) =
real(swpoint+real(i-1)*dd, kind=RP) * D2R
1140 else if ( trim(dtype) ==
"map" )
then 1141 call read_grads_file_2d(io_fid_grads_data,gfile,ldims(2),ldims(3),1,1,item,startrec,totalrec,yrev,gland2d)
1142 llon_org(:,:) =
real(gland2D(:,:), kind=RP) * D2R
1145 if ( .not. data_available(il_lat_sfc,2) )
then 1146 if ( ldims(2).ne.outer_nx .or. ldims(3).ne.outer_ny )
then 1147 write(*,*)
'xxx namelist of "lat_sfc" is not found in grads namelist!' 1148 write(*,*)
'xxx dimension is different: outer_nx and outer_nx_sfc! ', outer_nx, ldims(2)
1149 write(*,*)
' : outer_ny and outer_ny_sfc! ', outer_nx, ldims(3)
1152 if ( trim(dtype) ==
"linear" )
then 1155 llat_org(i,j) =
real(swpoint+real(j-1)*dd, kind=RP) * D2R
1158 else if ( trim(dtype) ==
"map" )
then 1159 call read_grads_file_2d(io_fid_grads_data,gfile,ldims(2),ldims(3),1,1,item,startrec,totalrec,yrev,gland2d)
1160 llat_org(:,:) =
real(gland2D(:,:), kind=RP) * D2R
1164 if ( .not. data_available(il_lat_sfc,2) ) cycle
1165 if ( trim(dtype) ==
"linear" )
then 1168 llat_org(i,j) =
real(swpoint+real(j-1)*dd, kind=RP) * D2R
1171 else if ( trim(dtype) ==
"map" )
then 1172 call read_grads_file_2d(io_fid_grads_data,gfile,ldims(2),ldims(3),1,1,item,startrec,totalrec,yrev,gland2d)
1173 llat_org(:,:) =
real(gland2D(:,:), kind=RP) * D2R
1176 if(ldims(1)/=knum)
then 1177 write(*,*)
'xxx "knum" must be equal to outer_nl for llev. knum:',knum,
'> outer_nl:',ldims(1)
1180 if ( trim(dtype) ==
"levels" )
then 1181 if(ldims(1)/=lnum)
then 1182 write(*,*)
'xxx lnum must be same as the outer_nl for llev! ',ldims(1),lnum
1186 lz_org(k) =
real(lvars(k), kind=
rp)
1199 if(ldims(1)/=knum)
then 1200 write(*,*)
'xxx The number of levels for STEMP must be same as llevs! ',ldims(1),knum
1203 if ( trim(dtype) ==
"map" )
then 1204 call read_grads_file_3d(io_fid_grads_data,gfile,ldims(2),ldims(3),ldims(1),nt,item,startrec,totalrec,yrev,gland3d)
1208 if ( abs(gland3d(i,j,k)-missval) < eps )
then 1209 tg_org(k,i,j) = undef
1211 tg_org(k,i,j) =
real(gland3D(i,j,k), kind=
rp)
1218 if ( use_file_landwater )
then 1219 if(ldims(1)/=knum)
then 1220 write(*,*)
'xxx The number of levels for SMOISVC must be same as llevs! ',ldims(1),knum
1223 if ( trim(dtype) ==
"map" )
then 1224 call read_grads_file_3d(io_fid_grads_data,gfile,ldims(2),ldims(3),ldims(1),nt,item,startrec,totalrec,yrev,gland3d)
1228 if ( abs(gland3d(i,j,k)-missval) < eps )
then 1229 strg_org(k,i,j) = undef
1231 strg_org(k,i,j) =
real(gland3D(i,j,k), kind=
rp)
1239 if ( use_file_landwater )
then 1240 if(ldims(1)/=knum)
then 1241 write(*,*)
'xxx The number of levels for SMOISDS must be same as llevs! ',ldims(1),knum
1244 if ( trim(dtype) ==
"map" )
then 1245 call read_grads_file_3d(io_fid_grads_data,gfile,ldims(2),ldims(3),ldims(1),nt,item,startrec,totalrec,yrev,gland3d)
1249 if ( abs(gland3d(i,j,k)-missval) < eps )
then 1250 smds_org(k,i,j) = undef
1252 smds_org(k,i,j) =
real(gland3D(i,j,k), kind=
rp)
1260 if ( trim(dtype) ==
"map" )
then 1261 call read_grads_file_2d(io_fid_grads_data,gfile,ldims(2),ldims(3),1,nt,item,startrec,totalrec,yrev,gland2d)
1264 if ( abs(gland2d(i,j)-missval) < eps )
then 1265 lst_org(i,j) = undef
1267 lst_org(i,j) =
real(gland2D(i,j), kind=
rp)
1273 if ( data_available(il_topo,2) )
then 1274 if ( trim(dtype) ==
"map" )
then 1275 call read_grads_file_2d(io_fid_grads_data,gfile,ldims(2),ldims(3),1,nt,item,startrec,totalrec,yrev,gland2d)
1278 if ( abs(gland2d(i,j)-missval) < eps )
then 1279 topo_org(i,j) = undef
1281 topo_org(i,j) =
real(gland2D(i,j), kind=
rp)
1290 enddo loop_inputlandgrads
1315 integer,
intent(out) :: odims(2)
1316 integer,
intent(out) :: timelen
1317 character(len=*),
intent(in) :: basename
1319 character(len=H_LONG) :: grads_ctl
1326 if(
io_l )
write(
io_fid_log,*)
'+++ Real Case/Ocean Input File Type: GrADS format' 1330 if ( len_trim(basename) == 0 )
then 1331 grads_ctl =
"namelist.grads_boundary" 1333 grads_ctl = basename
1338 open( io_fid_grads_nml, &
1339 file = trim(grads_ctl), &
1340 form =
'formatted', &
1344 if ( ierr /= 0 )
then 1345 if(
io_l )
write(
io_fid_log,*)
'xxx Input file is not found! ', trim(grads_ctl)
1349 read(io_fid_grads_nml,nml=nml_grads_grid,iostat=ierr)
1350 if( ierr /= 0 )
then 1351 if(
io_l )
write(
io_fid_log,*)
'xxx Not appropriate names in nml_grads_grid in ', trim(grads_ctl),
'. Check!' 1359 if(outer_nx_sst > 0)
then 1360 odims(1) = outer_nx_sst
1361 else if (outer_nx_sfc > 0)
then 1362 odims(1) = outer_nx_sfc
1363 outer_nx_sst = outer_nx_sfc
1366 outer_nx_sst = outer_nx
1368 if(outer_ny_sst > 0)
then 1369 odims(2) = outer_ny_sst
1370 else if(outer_ny_sfc > 0)
then 1371 odims(2) = outer_ny_sfc
1372 outer_ny_sst = outer_ny_sfc
1375 outer_ny_sst = outer_ny
1378 allocate( gsst2d( odims(1), odims(2) ) )
1385 grads_swpoint(:,3), &
1388 grads_lvars(:,:,3), &
1389 grads_startrec(:,3), &
1390 grads_totalrec(:,3), &
1393 grads_fendian(:,3), &
1394 grads_missval(:,3), &
1395 data_available(:,3), &
1397 num_item_list_ocean, &
1401 close( io_fid_grads_nml )
1403 do ielem = 1, num_item_list_ocean
1404 item = item_list_ocean(ielem)
1406 select case(trim(item))
1408 if ( .not. data_available(ielem,3) )
then 1409 if (
io_l)
write(
io_fid_log,*)
'warning: ',trim(item),
' is not found & not used.' 1412 case(
'lon',
'lat',
'lon_sfc',
'lat_sfc',
'lon_sst',
'lat_sst')
1415 if (.not. data_available(io_sst,3) .and. .not. data_available(io_skint,3) )
then 1416 if (
io_l)
write(
io_fid_log,*)
'xxx SST and SKINT are found in grads namelist!' 1419 if (.not. data_available(io_sst,3))
then 1420 if (
io_l)
write(
io_fid_log,*)
'warning: SST is found in grads namelist. SKINT is used in place of SST.' 1426 if ( .not. data_available(ielem,3) )
then 1427 if(
io_l )
write(
io_fid_log,*)
'xxx Not found in grads namelist! : ',trim(item_list_ocean(ielem))
1441 if(
io_l )
write(
io_fid_log,*)
'+++ ScaleLib/IO[realinput]/Categ[OceanOpenGrADS]' 1463 real(RP),
intent(out) :: tw_org (:,:)
1464 real(RP),
intent(out) :: sst_org (:,:)
1465 real(RP),
intent(out) :: omask_org(:,:)
1466 real(RP),
intent(out) :: olon_org (:,:)
1467 real(RP),
intent(out) :: olat_org (:,:)
1469 character(len=*),
intent(in) :: basename_num
1470 integer,
intent(in) :: odims(2)
1471 integer,
intent(in) :: nt
1475 character(len=H_LONG) :: gfile
1477 real(RP) :: qvsat, qm
1479 integer :: i, j, ielem, n
1484 if(
io_l )
write(
io_fid_log,*)
'+++ ScaleLib/IO[realinput]/Categ[OceanInputGrADS]' 1487 loop_inputoceangrads :
do ielem = 1, num_item_list_ocean
1489 item = item_list_ocean(ielem)
1491 dtype = grads_dtype(ielem,3)
1492 fname = grads_fname(ielem,3)
1493 lnum = grads_lnum(ielem,3)
1494 missval = grads_missval(ielem,3)
1496 select case (trim(dtype))
1498 swpoint = grads_swpoint(ielem,3)
1499 dd = grads_dd(ielem,3)
1500 if( (abs(swpoint-large_number_one)<eps).or.(abs(dd-large_number_one)<eps) )
then 1501 write(*,*)
'xxx "swpoint" is required in grads namelist! ',swpoint
1502 write(*,*)
'xxx "dd" is required in grads namelist! ',dd
1506 write(*,*)
'xxx "lnum" in grads namelist is invalid for ocean data' 1509 startrec = grads_startrec(ielem,3)
1510 totalrec = grads_totalrec(ielem,3)
1511 fendian = grads_fendian(ielem,3)
1512 yrev = grads_yrev(ielem,3)
1513 if( (startrec<0).or.(totalrec<0) )
then 1514 write(*,*)
'xxx "startrec" is required in grads namelist! ',startrec
1515 write(*,*)
'xxx "totalrec" is required in grads namelist! ',totalrec
1519 if(io_fid_grads_data < 0)
then 1522 gfile=trim(fname)//trim(basename_num)//
'.grd' 1523 if( len_trim(fname)==0 )
then 1524 write(*,*)
'xxx "fname" is required in grads namelist for map data! ',trim(fname)
1530 select case (trim(item))
1532 if ( data_available(io_lsmask,3) )
then 1533 if ( trim(dtype) ==
"map" )
then 1534 call read_grads_file_2d(io_fid_grads_data,gfile,odims(1),odims(2),1,1,item,startrec,totalrec,yrev,gsst2d)
1535 omask_org(:,:) =
real(gsst2D(:,:), kind=
rp)
1541 if ( .not. data_available(io_lon_sst,3) .and. .not. data_available(io_lon_sfc,3) )
then 1542 if ( odims(1).ne.outer_nx .or. odims(2).ne.outer_ny )
then 1543 write(*,*)
'xxx namelist of "lon_sst" is not found in grads namelist!' 1544 write(*,*)
'xxx dimension is different: outer_nx and outer_nx_sst! ', outer_nx, odims(1)
1545 write(*,*)
' : outer_ny and outer_ny_sst! ', outer_ny, odims(2)
1548 if ( trim(dtype) ==
"linear" )
then 1551 olon_org(i,j) =
real(swpoint+real(i-1)*dd, kind=RP) * D2R
1554 else if ( trim(dtype) ==
"map" )
then 1555 call read_grads_file_2d(io_fid_grads_data,gfile,odims(1),odims(2),1,1,item,startrec,totalrec,yrev,gsst2d)
1556 olon_org(:,:) =
real(gsst2D(:,:), kind=RP) * D2R
1560 if ( .not. data_available(io_lon_sst,3) .and. data_available(io_lon_sfc,3) )
then 1561 if ( odims(1).ne.outer_nx_sfc .or. odims(2).ne.outer_ny_sfc )
then 1562 write(*,*)
'xxx namelist of "lon_sst" is not found in grads namelist!' 1563 write(*,*)
'xxx dimension is different: outer_nx_sfc and outer_nx_sst! ', outer_nx_sfc, odims(1)
1564 write(*,*)
' : outer_ny_sfc and outer_ny_sst! ', outer_ny_sfc, odims(2)
1567 if ( trim(dtype) ==
"linear" )
then 1570 olon_org(i,j) =
real(swpoint+real(i-1)*dd, kind=RP) * D2R
1573 else if ( trim(dtype) ==
"map" )
then 1574 call read_grads_file_2d(io_fid_grads_data,gfile,odims(1),odims(2),1,1,item,startrec,totalrec,yrev,gsst2d)
1575 olon_org(:,:) =
real(gsst2D(:,:), kind=RP) * D2R
1579 if ( .not. data_available(io_lon_sst,3) ) cycle
1580 if ( trim(dtype) ==
"linear" )
then 1583 olon_org(i,j) =
real(swpoint+real(i-1)*dd, kind=RP) * D2R
1586 else if ( trim(dtype) ==
"map" )
then 1587 call read_grads_file_2d(io_fid_grads_data,gfile,odims(1),odims(2),1,1,item,startrec,totalrec,yrev,gsst2d)
1588 olon_org(:,:) =
real(gsst2D(:,:), kind=RP) * D2R
1591 if ( .not. data_available(io_lat_sfc,3) .and. .not. data_available(io_lat_sst,3) )
then 1592 if ( odims(1).ne.outer_nx .or. odims(2).ne.outer_ny )
then 1593 write(*,*)
'xxx namelist of "lat_sst" is not found in grads namelist!' 1594 write(*,*)
'xxx dimension is different: outer_nx and outer_nx_sst! ', outer_nx, odims(1)
1595 write(*,*)
' : outer_ny and outer_ny_sst! ', outer_ny, odims(2)
1598 if ( trim(dtype) ==
"linear" )
then 1601 olat_org(i,j) =
real(swpoint+real(j-1)*dd, kind=RP) * D2R
1604 else if ( trim(dtype) ==
"map" )
then 1605 call read_grads_file_2d(io_fid_grads_data,gfile,odims(1),odims(2),1,1,item,startrec,totalrec,yrev,gsst2d)
1606 olat_org(:,:) =
real(gsst2D(:,:), kind=RP) * D2R
1610 if ( .not. data_available(io_lat_sst,3) .and. data_available(io_lat_sfc,3) )
then 1611 if ( odims(1).ne.outer_nx .or. odims(1).ne.outer_ny )
then 1612 write(*,*)
'xxx namelist of "lat_sst" is not found in grads namelist!' 1613 write(*,*)
'xxx dimension is different: outer_nx_sfc and outer_nx_sst! ', outer_nx_sfc, odims(1)
1614 write(*,*)
' : outer_ny_sfc and outer_ny_sst! ', outer_ny_sfc, odims(2)
1617 if ( trim(dtype) ==
"linear" )
then 1620 olat_org(i,j) =
real(swpoint+real(j-1)*dd, kind=RP) * D2R
1623 else if ( trim(dtype) ==
"map" )
then 1624 call read_grads_file_2d(io_fid_grads_data,gfile,odims(1),odims(2),1,1,item,startrec,totalrec,yrev,gsst2d)
1625 olat_org(:,:) =
real(gsst2D(:,:), kind=RP) * D2R
1629 if ( .not. data_available(io_lat_sst,3) ) cycle
1630 if ( trim(dtype) ==
"linear" )
then 1633 olat_org(i,j) =
real(swpoint+real(j-1)*dd, kind=RP) * D2R
1636 else if ( trim(dtype) ==
"map" )
then 1637 call read_grads_file_2d(io_fid_grads_data,gfile,odims(1),odims(2),1,1,item,startrec,totalrec,yrev,gsst2d)
1638 olat_org(:,:) =
real(gsst2D(:,:), kind=RP) * D2R
1641 if ( .not. data_available(io_sst,3) )
then 1642 if ( odims(1).ne.outer_nx_sfc .or. odims(2).ne.outer_ny_sfc )
then 1643 write(*,*)
'xxx dimsntion is different: outer_nx_sst/outer_nx_sfc and outer_nx_sst! ', odims(1), outer_nx_sfc
1644 write(*,*)
' : outer_ny_sst/outer_ny_sfc and outer_ny_sst! ', odims(2), outer_ny_sfc
1647 if ( trim(dtype) ==
"map" )
then 1648 call read_grads_file_2d(io_fid_grads_data,gfile,odims(1),odims(2),1,nt,item,startrec,totalrec,yrev,gsst2d)
1651 if ( abs(gsst2d(i,j)-missval) < eps )
then 1652 sst_org(i,j) = undef
1654 sst_org(i,j) =
real(gsst2D(i,j), kind=
rp)
1661 if ( .not. data_available(io_sst,3) ) cycle
1662 if ( trim(dtype) ==
"map" )
then 1663 call read_grads_file_2d(io_fid_grads_data,gfile,odims(1),odims(2),1,nt,item,startrec,totalrec,yrev,gsst2d)
1666 if ( abs(gsst2d(i,j)-missval) < eps )
then 1667 sst_org(i,j) = undef
1669 sst_org(i,j) =
real(gsst2D(i,j), kind=
rp)
1675 enddo loop_inputoceangrads
1715 character(len=H_SHORT),
intent(out) :: grads_item (:)
1716 character(len=H_LONG),
intent(out) :: grads_fname (:)
1717 character(len=H_LONG),
intent(out) :: grads_dtype (:)
1718 real(RP),
intent(out) :: grads_swpoint (:)
1719 real(RP),
intent(out) :: grads_dd (:)
1720 integer,
intent(out) :: grads_lnum (:)
1721 real(RP),
intent(out) :: grads_lvars (:,:)
1722 integer,
intent(out) :: grads_startrec(:)
1723 integer,
intent(out) :: grads_totalrec(:)
1724 integer,
intent(out) :: grads_knum (:)
1725 character(len=H_SHORT),
intent(out) :: grads_yrev (:)
1726 character(len=H_SHORT),
intent(out) :: grads_fendian (:)
1727 real(SP),
intent(out) :: grads_missval (:)
1728 logical,
intent(out) :: data_available(:)
1729 character(len=H_SHORT),
intent(in) :: item_list (:)
1730 integer,
intent(in) :: num_item_list
1731 character(len=*),
intent(in) :: basename
1732 integer,
intent(in) :: io_fid_grads_nml
1734 integer :: grads_vars_nmax
1735 integer :: k, n, ielem, ierr
1753 if ( io_fid_grads_nml > 0 )
then 1754 rewind( io_fid_grads_nml )
1756 do n = 1, grads_vars_limit
1757 read(io_fid_grads_nml, nml=grdvar, iostat=ierr)
1759 if(
io_l )
write(
io_fid_log,*)
'xxx Not appropriate names in grdvar in ', trim(basename),
'. Check!' 1761 else if( ierr < 0 )
then 1764 grads_vars_nmax = grads_vars_nmax + 1
1767 if(
io_l )
write(
io_fid_log,*)
'xxx namelist file is not open! ', trim(basename)
1771 if ( grads_vars_nmax > grads_vars_limit )
then 1773 'xxx The number of grads vars exceeds grads_vars_limit! ',grads_vars_nmax,
' >', grads_vars_limit
1779 data_available(:) = .false.
1780 do ielem = 1, num_item_list
1781 if ( io_fid_grads_nml > 0 ) rewind( io_fid_grads_nml )
1782 do n = 1, grads_vars_nmax
1788 swpoint = large_number_one
1789 dd = large_number_one
1791 lvars = large_number_one
1797 missval = large_number_one
1800 if ( io_fid_grads_nml > 0 )
then 1801 read(io_fid_grads_nml, nml=grdvar, iostat=ierr)
1802 if( ierr /= 0 )
exit 1805 if(item == item_list(ielem))
then 1806 grads_item(ielem) = item
1807 grads_fname(ielem) = fname
1808 grads_dtype(ielem) = dtype
1809 grads_swpoint(ielem) = swpoint
1810 grads_dd(ielem) = dd
1811 grads_lnum(ielem) = lnum
1812 do k = 1, lvars_limit
1813 grads_lvars(k,ielem) = lvars(k)
1815 grads_startrec(ielem) = startrec
1816 grads_totalrec(ielem) = totalrec
1817 grads_knum(ielem) = knum
1818 grads_yrev(ielem) = yrev
1819 grads_fendian(ielem) = fendian
1820 grads_missval(ielem) = missval
1821 data_available(ielem) = .true.
1826 if(
io_l )
write(
io_fid_log,*)
'GrADS data availability ',trim(item_list(ielem)),data_available(ielem)
1832 subroutine open_grads_file(io_fid,filename,irecl)
1834 integer,
intent(in) :: io_fid
1835 character(*),
intent(in) :: filename
1836 integer,
intent(in) :: irecl
1840 file = trim(filename), &
1841 form =
'unformatted', &
1842 access =
'direct', &
1846 if ( ierr /= 0 )
then 1847 write(*,*)
'xxx grads file does not found! ', trim(filename)
1851 end subroutine open_grads_file
1854 subroutine read_grads_file_2d( &
1864 integer,
intent(in) :: io_fid
1865 character(*),
intent(in) :: gfile
1866 integer,
intent(in) :: nx,ny,nz,it
1867 character(*),
intent(in) :: item
1868 integer,
intent(in) :: startrec
1869 integer,
intent(in) :: totalrec
1870 character(*),
intent(in) :: yrev
1871 real(SP),
intent(out) :: gdata(nx,ny)
1873 real(SP) :: work(nx,ny)
1876 integer :: irec, irecl
1880 call open_grads_file(io_fid, gfile, irecl)
1881 irec = totalrec * (it-1) + startrec
1882 read(io_fid, rec=irec, iostat=ierr) gdata(:,:)
1883 if ( ierr /= 0 )
then 1884 write(*,*)
'xxx grads data is not found! ',trim(item),it
1885 write(*,*)
'xxx namelist or grads data might be wrong.' 1889 if( trim(yrev) ==
"on" )
then 1890 work(:,:)=gdata(:,:)
1893 gdata(i,j)=work(i,ny-j+1)
1898 call close_grads_file(io_fid,gfile)
1901 end subroutine read_grads_file_2d
1904 subroutine read_grads_file_3d( &
1914 integer,
intent(in) :: io_fid
1915 character(*),
intent(in) :: gfile
1916 integer,
intent(in) :: nx,ny,nz,it
1917 character(*),
intent(in) :: item
1918 integer,
intent(in) :: startrec
1919 integer,
intent(in) :: totalrec
1920 character(*),
intent(in) :: yrev
1921 real(SP),
intent(out) :: gdata(nx,ny,nz)
1923 real(SP) :: work(nx,ny,nz)
1926 integer :: irec,irecl
1930 call open_grads_file(io_fid, gfile, irecl)
1932 irec = totalrec * (it-1) + startrec + (k-1)
1933 read(io_fid, rec=irec, iostat=ierr) gdata(:,:,k)
1934 if ( ierr /= 0 )
then 1935 write(*,*)
'xxx grads data does not found! ',trim(item),
', k=',k,
', it=',it,
' in ', trim(gfile)
1940 if( trim(yrev) ==
"on" )
then 1941 work(:,:,:)=gdata(:,:,:)
1945 gdata(i,j,k)=work(i,ny-j+1,k)
1951 call close_grads_file(io_fid,gfile)
1954 end subroutine read_grads_file_3d
1957 subroutine close_grads_file(io_fid,filename)
1959 integer,
intent(in) :: io_fid
1960 character(*),
intent(in) :: filename
1963 close(io_fid, iostat=ierr)
1964 if ( ierr /= 0 )
then 1965 write(*,*)
'xxx grads file was not closed peacefully! ',trim(filename)
1970 end subroutine close_grads_file
real(rp), public const_cpdry
specific heat (dry air,constant pressure) [J/kg/K]
module ATMOSPHERE / Saturation adjustment
subroutine, public prc_mpistop
Abort MPI.
logical, public io_l
output log or not? (this process)
real(rp), parameter, public const_tem00
temperature reference (0C) [K]
real(rp), public const_d2r
degree to radian
real(rp), public const_laps
lapse rate of ISA [K/m]
real(rp), public const_rdry
specific gas constant (dry air) [J/kg/K]
real(rp), public const_undef
integer function, public io_get_available_fid()
search & get available file ID
real(rp), public const_pre00
pressure reference [Pa]
real(rp), public const_grav
standard acceleration of gravity [m/s2]
real(rp), public const_epsvap
Rdry / Rvap.
subroutine, public log(type, message)
integer, public prc_myrank
process num in local communicator
real(rp), public const_eps
small number
logical, public io_lnml
output log or not? (for namelist, this process)
integer, public io_fid_conf
Config file ID.
integer, public io_fid_log
Log file ID.
integer, parameter, public rp