54 real(RP),
parameter :: t0 = 300.0_rp
55 real(RP),
parameter :: p0 = 1000.0e+2_rp
56 real(RP),
parameter :: Rd = 287.04_rp
57 real(RP),
parameter :: Cp = 7.0_rp * rd / 2.0_rp
58 real(RP),
parameter :: RCP = rd / cp
60 integer,
parameter :: cosin = 1
61 integer,
parameter :: sine = 2
63 real(RP),
allocatable :: read_xy (:,:)
64 real(RP),
allocatable :: read_xyz(:,:,:)
65 real(RP),
allocatable :: read_xyw(:,:,:)
66 real(RP),
allocatable :: read_xyl(:,:,:)
68 real(RP),
allocatable :: p_org (:,:,:)
69 real(RP),
allocatable :: pb_org (:,:,:)
70 real(RP),
allocatable :: ph_org (:,:,:)
71 real(RP),
allocatable :: phb_org (:,:,:)
73 logical,
private :: wrfout = .false.
88 integer,
intent(out) :: dims(6)
89 integer,
intent(out) :: timelen
90 character(len=*),
intent(in) :: basename_org
92 logical :: wrf_file_type = .false.
94 namelist / param_mkinit_real_wrfarw / &
103 log_info(
"ParentAtmosSetupWRFARW",*)
'Setup'
107 read(
io_fid_conf,nml=param_mkinit_real_wrfarw,iostat=ierr)
109 log_error(
"ParentAtmosSetupWRFARW",*)
'Not appropriate names in namelist PARAM_MKINIT_REAL_WRFARW. Check!'
112 log_nml(param_mkinit_real_wrfarw)
114 call file_open( basename_org, fid, rankid=myrank, single=.true., postfix=
"" )
125 if ( error ) timelen = 0
127 if ( wrf_file_type )
then
129 log_info(
"ParentAtmosSetupWRFARW",*)
'WRF-ARW FILE-TYPE: WRF History Output'
132 log_info(
"ParentAtmosSetupWRFARW",*)
'WRF-ARW FILE-TYPE: WRF Restart'
136 allocate( read_xy(dims(2),dims(3)) )
137 allocate( read_xyz(dims(2),dims(3),dims(1)) )
138 allocate( read_xyw(dims(2),dims(3),dims(4)) )
140 allocate( p_org(dims(1),dims(2),dims(3)) )
141 allocate( pb_org(dims(1),dims(2),dims(3)) )
142 allocate( ph_org(dims(4),dims(2),dims(3)) )
143 allocate( phb_org(dims(4),dims(2),dims(3)) )
190 real(rp),
intent(out) :: velz_org(:,:,:)
191 real(rp),
intent(out) :: llvelx_org(:,:,:)
192 real(rp),
intent(out) :: llvely_org(:,:,:)
193 real(rp),
intent(out) :: pres_org(:,:,:)
194 real(rp),
intent(out) :: temp_org(:,:,:)
195 real(rp),
intent(out) :: qv_org(:,:,:)
196 real(rp),
intent(out) :: qhyd_org(:,:,:,:)
197 real(rp),
intent(out) :: qnum_org(:,:,:,:)
198 real(rp),
intent(out) :: lon_org(:,:)
199 real(rp),
intent(out) :: lat_org(:,:)
200 real(rp),
intent(out) :: cz_org(:,:,:)
201 character(len=*),
intent(in) :: basename
202 logical,
intent(in) :: sfc_diagnoses
203 integer,
intent(in) :: dims(6)
204 integer,
intent(in) :: it
207 real(rp) :: velx_org(dims(1)+2,dims(2),dims(3))
208 real(rp) :: vely_org(dims(1)+2,dims(2),dims(3))
209 real(rp) :: pott_org(dims(1)+2,dims(2),dims(3))
210 real(rp) :: topo_org( dims(2),dims(3))
211 real(rp) :: geof_org(dims(4) ,dims(2),dims(3))
215 real(rp) :: velzs_org(dims(2),dims(3),dims(4))
216 real(rp) :: velxs_org(dims(5),dims(3),dims(1))
217 real(rp) :: velys_org(dims(2),dims(6),dims(1))
223 integer ::
k, i, j, iq
225 character(len=H_MID) :: varname_t
226 character(len=H_MID) :: varname_w
227 character(len=H_MID) :: varname_u
228 character(len=H_MID) :: varname_v
246 call file_open( basename, fid, rankid=myrank, single=.true., postfix=
"" )
248 call file_read( fid,
"XLAT", lat_org(:,:), step=it )
249 lat_org(:,:) = lat_org(:,:) * d2r
251 call file_read( fid,
"XLONG", lon_org(:,:), step=it )
252 lon_org(:,:) = lon_org(:,:) * d2r
254 call file_read( fid,
"HGT", topo_org(:,:), step=it )
256 call file_read( fid,
"PH", read_xyw(:,:,:), step=it )
261 ph_org(
k,i,j) = read_xyw(i,j,
k)
266 call file_read( fid,
"PHB", read_xyw(:,:,:), step=it )
271 phb_org(
k,i,j) = read_xyw(i,j,
k)
276 call file_read( fid,
"P", read_xyz(:,:,:), step=it )
281 p_org(
k,i,j) = read_xyz(i,j,
k)
286 call file_read( fid,
"PB", read_xyz(:,:,:), step=it )
291 pb_org(
k,i,j) = read_xyz(i,j,
k)
296 call file_read( fid, varname_w, velzs_org(:,:,:), step=it )
298 call file_read( fid, varname_u, velxs_org(:,:,:), step=it )
300 call file_read( fid, varname_v, velys_org(:,:,:), step=it )
308 velz_org(
k+2,i,j) = ( velzs_org(i,j,
k) + velzs_org(i,j,
k+1) ) * 0.5_rp
309 velx_org(
k+2,i,j) = ( velxs_org(i,j,
k) + velxs_org(i+1,j,
k) ) * 0.5_rp
310 vely_org(
k+2,i,j) = ( velys_org(i,j,
k) + velys_org(i,j+1,
k) ) * 0.5_rp
312 velz_org(1:2,i,j) = 0.0_rp
313 velx_org(1:2,i,j) = 0.0_rp
314 vely_org(1:2,i,j) = 0.0_rp
319 velx_org, vely_org, &
322 dims(1)+2, dims(2), dims(3) )
329 qhyd_org(
k,i,j,iq) = 0.0_rp
335 call file_read( fid,
"QVAPOR", read_xyz(:,:,:), step=it )
340 qv_org(
k+2,i,j) = read_xyz(i,j,
k)
345 if ( sfc_diagnoses )
then
346 call file_read( fid,
"Q2", read_xy(:,:), step=it )
350 qv_org(1,i,j) = read_xy(i,j)
351 qv_org(2,i,j) = read_xy(i,j)
358 qv_org(1:2,i,j) = undef
364 call file_read( fid,
"QCLOUD", read_xyz(:,:,:), step=it, allow_missing=.true. )
369 qhyd_org(
k+2,i,j,
i_hc) = read_xyz(i,j,
k)
374 call file_read( fid,
"QRAIN", read_xyz(:,:,:), step=it, allow_missing=.true. )
379 qhyd_org(
k+2,i,j,
i_hc) = read_xyz(i,j,
k)
384 call file_read( fid,
"QICE", read_xyz(:,:,:), step=it, allow_missing=.true. )
389 qhyd_org(
k+2,i,j,
i_hi) = read_xyz(i,j,
k)
394 call file_read( fid,
"QSNOW", read_xyz(:,:,:), step=it, allow_missing=.true. )
399 qhyd_org(
k+2,i,j,
i_hs) = read_xyz(i,j,
k)
404 call file_read( fid,
"QGRAUP", read_xyz(:,:,:), step=it, allow_missing=.true. )
409 qhyd_org(
k+2,i,j,
i_hg) = read_xyz(i,j,
k)
421 if (
k<3 .and. .not. sfc_diagnoses )
then
422 qv_org(
k,i,j) = undef
424 qhyd_org(
k,i,j,iq) = undef
429 qtot = qtot + qhyd_org(
k,i,j,iq)
431 qv_org(
k,i,j) = qv_org(
k,i,j) / ( 1.0_rp + qtot )
433 qhyd_org(
k,i,j,iq) = qhyd_org(
k,i,j,iq) / ( 1.0_rp + qtot )
440 call file_read( fid,
"NC", read_xyz(:,:,:), step=it, allow_missing=.true. )
445 qnum_org(
k+2,i,j,
i_hc) = read_xyz(i,j,
k)
450 call file_read( fid,
"NR", read_xyz(:,:,:), step=it, allow_missing=.true. )
455 qnum_org(
k+2,i,j,
i_hr) = read_xyz(i,j,
k)
460 call file_read( fid,
"NI", read_xyz(:,:,:), step=it, allow_missing=.true. )
465 qnum_org(
k+2,i,j,
i_hi) = read_xyz(i,j,
k)
470 call file_read( fid,
"NS", read_xyz(:,:,:), step=it, allow_missing=.true. )
475 qnum_org(
k+2,i,j,
i_hs) = read_xyz(i,j,
k)
480 call file_read( fid,
"NG", read_xyz(:,:,:), step=it, allow_missing=.true. )
485 qnum_org(
k+2,i,j,
i_hg) = read_xyz(i,j,
k)
495 if (
k<3 .and. .not. sfc_diagnoses )
then
496 qhyd_org(
k,i,j,iq) = undef
497 qnum_org(
k,i,j,iq) = undef
499 qhyd_org(
k,i,j,iq) = max( qhyd_org(
k,i,j,iq), 0.0_rp )
500 qnum_org(
k,i,j,iq) = max( qnum_org(
k,i,j,iq), 0.0_rp )
508 call file_read( fid, varname_t, read_xyz(:,:,:), step=it, allow_missing=.true. )
513 pott_org(
k+2,i,j) = read_xyz(i,j,
k) + t0
517 if ( sfc_diagnoses )
then
518 call file_read( fid,
"T2", read_xy(:,:), step=it, allow_missing=.false. )
522 temp_org(2,i,j) = read_xy(i,j)
526 call file_read( fid,
"PSFC", read_xy(:,:), step=it, allow_missing=.false. )
530 pres_org(2,i,j) = read_xy(i,j)
537 temp_org(2,i,j) = undef
538 pres_org(2,i,j) = undef
548 geof_org(
k,i,j) = ( ph_org(
k,i,j) + phb_org(
k,i,j) ) / grav
552 cz_org(
k+2,i,j) = ( geof_org(
k,i,j) + geof_org(
k+1,i,j) ) * 0.5_rp
554 cz_org(2,i,j) = topo_org(i,j)
555 cz_org(1,i,j) = 0.0_rp
564 pres_org(
k,i,j) = p_org(
k-2,i,j) + pb_org(
k-2,i,j)
565 temp_org(
k,i,j) = pott_org(
k,i,j) * ( pres_org(
k,i,j) / p0 )**rcp
567 if ( sfc_diagnoses )
then
568 pott_org(2,i,j) = temp_org(2,i,j) * ( p0/pres_org(2,i,j) )**rcp
569 temp_org(1,i,j) = temp_org(2,i,j) + laps * topo_org(i,j)
570 dens = pres_org(2,i,j) / ( rdry * temp_org(2,i,j) )
571 pres_org(1,i,j) = ( pres_org(2,i,j) + grav * dens * cz_org(2,i,j) * 0.5_rp ) &
572 / ( rdry * temp_org(1,i,j) - grav * cz_org(2,i,j) * 0.5_rp ) &
573 * rdry * temp_org(1,i,j)
575 pott_org(2,i,j) = undef
576 temp_org(1,i,j) = undef
577 pres_org(1,i,j) = undef
586 log_info(
"ParentAtmosInputWRFARW",*)
"read 3D wrf data",i,j,
k
587 log_info(
"ParentAtmosInputWRFARW",*)
"lon_org ",lon_org(i,j)/d2r
588 log_info(
"ParentAtmosInputWRFARW",*)
"lat_org ",lat_org(i,j)/d2r
589 log_info(
"ParentAtmosInputWRFARW",*)
"cz_org ",cz_org(
k,i,j)
590 log_info(
"ParentAtmosInputWRFARW",*)
"pres_org ",pres_org(
k,i,j)
591 log_info(
"ParentAtmosInputWRFARW",*)
"velx_org ",llvelx_org(
k,i,j)
592 log_info(
"ParentAtmosInputWRFARW",*)
"vely_org ",llvely_org(
k,i,j)
593 log_info(
"ParentAtmosInputWRFARW",*)
"velz_org ",velz_org(
k,i,j)
594 log_info(
"ParentAtmosInputWRFARW",*)
"temp_org ",temp_org(
k,i,j)
595 log_info(
"ParentAtmosInputWRFARW",*)
"qv_org ",qv_org(
k,i,j)
596 k=3 ; i=3 ; j=3 ; iq = 1
597 log_info(
"ParentAtmosInputWRFARW",*)
"read 3D wrf data",i,j,
k
598 log_info(
"ParentAtmosInputWRFARW",*)
"lon_org ",lon_org(i,j)/d2r
599 log_info(
"ParentAtmosInputWRFARW",*)
"lat_org ",lat_org(i,j)/d2r
600 log_info(
"ParentAtmosInputWRFARW",*)
"cz_org ",cz_org(
k,i,j)
601 log_info(
"ParentAtmosInputWRFARW",*)
"pres_org ",pres_org(
k,i,j)
602 log_info(
"ParentAtmosInputWRFARW",*)
"velx_org ",llvelx_org(
k,i,j)
603 log_info(
"ParentAtmosInputWRFARW",*)
"vely_org ",llvely_org(
k,i,j)
604 log_info(
"ParentAtmosInputWRFARW",*)
"velz_org ",velz_org(
k,i,j)
605 log_info(
"ParentAtmosInputWRFARW",*)
"temp_org ",temp_org(
k,i,j)
606 log_info(
"ParentAtmosInputWRFARW",*)
"qv_org ",qv_org(
k,i,j)
622 integer,
intent(out) :: ldims(3)
623 character(len=*),
intent(in) :: basename_land
625 logical :: wrf_file_type = .false.
627 namelist / param_mkinit_real_wrfarw / &
634 log_info(
"ParentLandSetupWRFARW",*)
'Real Case/Atmos Input File Type: WRF-ARW'
638 read(
io_fid_conf,nml=param_mkinit_real_wrfarw,iostat=ierr)
640 log_error(
"ParentLandSetupWRFARW",*)
'Not appropriate names in namelist PARAM_MKINIT_REAL_WRFARW. Check!'
643 log_nml(param_mkinit_real_wrfarw)
646 call file_open( basename_land, fid, rankid=myrank, single=.true., postfix=
"" )
652 if ( wrf_file_type )
then
654 log_info(
"ParentLandSetupWRFARW",*)
'WRF-ARW FILE-TYPE: WRF History Output'
657 log_info(
"ParentLandSetupWRFARW",*)
'WRF-ARW FILE-TYPE: WRF Restart'
661 if ( .not.
allocated(read_xy) )
then
662 allocate( read_xy(ldims(2),ldims(3)) )
665 allocate( read_xyl(ldims(2),ldims(3),ldims(1)) )
684 use_file_landwater, &
693 real(rp),
intent(out) :: tg_org(:,:,:)
694 real(rp),
intent(out) :: sh2o_org(:,:,:)
695 real(rp),
intent(out) :: lst_org(:,:)
696 real(rp),
intent(out) :: ust_org(:,:)
697 real(rp),
intent(out) :: albg_org(:,:,:,:)
698 real(rp),
intent(out) :: topo_org(:,:)
699 real(rp),
intent(out) :: lmask_org(:,:)
700 real(rp),
intent(out) :: llon_org(:,:)
701 real(rp),
intent(out) :: llat_org(:,:)
702 real(rp),
intent(out) :: lz_org(:)
703 character(len=*),
intent( in) :: basename
704 integer,
intent( in) :: ldims(3)
705 logical,
intent( in) :: use_file_landwater
706 integer,
intent( in) :: it
712 call file_open( basename, fid, rankid=myrank, single=.true., postfix=
"" )
714 call file_read( fid,
"XLAT", llat_org(:,:), step=it )
718 llat_org(i,j) = llat_org(i,j) * d2r
722 call file_read( fid,
"XLONG", llon_org(:,:), step=it )
726 llon_org(i,j) = llon_org(i,j) * d2r
730 call file_read( fid,
"HGT", topo_org(:,:), step=it )
734 call file_read( fid,
"ZS", lz_org(:), step=it )
737 call file_read( fid,
"LANDMASK", lmask_org(:,:), step=it )
740 call file_read( fid,
"TSLB", read_xyl(:,:,:), step=it )
745 tg_org(
k,i,j) = read_xyl(i,j,
k)
751 if( use_file_landwater )
then
752 call file_read( fid,
"SH2O", read_xyl(:,:,:), step=it, allow_missing=.true., missing_value=undef )
757 sh2o_org(
k,i,j) = read_xyl(i,j,
k)
774 call file_read( fid,
"TSK", lst_org(:,:), step=it )
779 ust_org(i,j) = lst_org(i,j)
795 call file_read( fid,
"EMISS", read_xy(:,:), step=it )
835 integer,
intent(out) :: odims(2)
836 integer,
intent(out) :: timelen
837 character(len=*),
intent(in) :: basename_org
839 logical :: wrf_file_type = .false.
841 namelist / param_mkinit_real_wrfarw / &
849 log_info(
"ParentOceanSetupWRFARW",*)
'Real Case/Ocean Input File Type: WRF-ARW'
853 read(
io_fid_conf,nml=param_mkinit_real_wrfarw,iostat=ierr)
855 log_error(
"ParentOceanSetupWRFARW",*)
'Not appropriate names in namelist PARAM_MKINIT_REAL_WRFARW. Check!'
858 log_nml(param_mkinit_real_wrfarw)
861 call file_open( basename_org, fid, rankid=myrank, single=.true., postfix=
"" )
868 if ( error ) timelen = 0
870 if ( wrf_file_type )
then
872 log_info(
"ParentOceanSetupWRFARW",*)
'WRF-ARW FILE-TYPE: WRF History Output'
875 log_info(
"ParentOceanSetupWRFARW",*)
'WRF-ARW FILE-TYPE: WRF Restart'
879 if ( .not.
allocated(read_xy) )
then
880 allocate( read_xy(odims(1),odims(2)) )
912 real(rp),
intent(out) :: tw_org(:,:)
913 real(rp),
intent(out) :: sst_org(:,:)
914 real(rp),
intent(out) :: albw_org(:,:,:,:)
915 real(rp),
intent(out) :: z0w_org(:,:)
916 real(rp),
intent(out) :: omask_org(:,:)
917 real(rp),
intent(out) :: olon_org(:,:)
918 real(rp),
intent(out) :: olat_org(:,:)
919 character(len=*),
intent( in) :: basename
920 integer,
intent( in) :: odims(2)
921 integer,
intent( in) :: it
927 call file_open( basename, fid, rankid=myrank, single=.true., postfix=
"" )
929 call file_read( fid,
"XLAT", olat_org(:,:), step=it )
933 olat_org(i,j) = olat_org(i,j) * d2r
937 call file_read( fid,
"XLONG", olon_org(:,:), step=it )
941 olon_org(i,j) = olon_org(i,j) * d2r
947 call file_read( fid,
"LANDMASK", omask_org(:,:), step=it )
950 call file_read( fid,
"SST", sst_org(:,:), step=it )
954 tw_org(i,j) = sst_org(i,j)
970 call file_read( fid,
"EMISS", read_xy(:,:), step=it )
985 call file_read( fid,
"ZNT", z0w_org(:,:), step=it, allow_missing=.true., missing_value=undef )
1010 real(RP),
intent(out) :: u_latlon(:,:,:)
1011 real(RP),
intent(out) :: v_latlon(:,:,:)
1012 real(RP),
intent(in ) :: u_on_map(:,:,:)
1013 real(RP),
intent(in ) :: v_on_map(:,:,:)
1014 real(RP),
intent(in ) :: xlon(:,:)
1015 real(RP),
intent(in ) :: xlat(:,:)
1016 integer ,
intent(in ) :: K1, I1, J1
1018 character(len=*),
intent( in) :: basename
1022 real(RP) :: truelat1, truelat2
1023 real(RP) :: stand_lon
1026 real(RP) :: sine(I1,J1)
1027 real(RP) :: cose(I1,J1)
1031 real(RP) :: dum_r(1)
1038 call file_open( basename, fid, rankid=myrank, single=.true., postfix=
"" )
1040 call file_get_attribute( fid,
"global",
"MAP_PROJ", dum_i(:) )
1043 call file_get_attribute( fid,
"global",
"TRUELAT1", dum_r(:) )
1044 truelat1 = dum_r(1) * d2r
1045 call file_get_attribute( fid,
"global",
"TRUELAT2", dum_r(:) )
1046 truelat2 = dum_r(1) * d2r
1047 call file_get_attribute( fid,
"global",
"STAND_LON", dum_r(:) )
1048 stand_lon = dum_r(1) * d2r
1051 if ( map_proj .ge. 3 )
then
1056 u_latlon(k,i,j) = u_on_map(k,i,j)
1057 v_latlon(k,i,j) = v_on_map(k,i,j)
1067 if ( map_proj .eq. 1 )
then
1068 if ( abs(truelat1-truelat2) .gt. 0.1_rp*d2r )
then
1069 cone = ( log(cos(truelat1)) - &
1070 log(cos(truelat2)) ) / &
1071 ( log(tan((pi*0.5_rp-abs(truelat1))*0.5_rp )) - &
1072 log(tan((pi*0.5_rp-abs(truelat2))*0.5_rp )) )
1074 cone = sin( abs(truelat1) )
1082 diff = xlon(i,j) - stand_lon
1083 if ( diff .gt. pi )
then
1084 diff = diff - pi*2.0_rp
1086 if ( diff .lt. -pi )
then
1087 diff = diff + pi*2.0_rp
1089 alpha = diff * cone * sign(1.0_rp, xlat(i,j))
1090 sine(i,j) = sin( alpha )
1091 cose(i,j) = cos( alpha )
1099 u_latlon(k,i,j) = v_on_map(k,i,j)*sine(i,j) + u_on_map(k,i,j)*cose(i,j)
1100 v_latlon(k,i,j) = v_on_map(k,i,j)*cose(i,j) - u_on_map(k,i,j)*sine(i,j)