59 character(len=32) :: name =
""
60 logical :: zstg = .false.
61 logical :: xstg = .false.
62 logical :: ystg = .false.
63 real(RP) :: fact = 1.0_rp
64 real(RP) :: offset = 0.0_rp
67 type(hash_table) :: vars_atmos
68 type(hash_table) :: vars_ocean
69 type(hash_table) :: vars_land
71 real(RP),
allocatable :: work3d(:,:,:)
72 real(RP),
allocatable :: work2d(:,:)
75 logical :: SCALE_tile_atm
76 logical :: SCALE_tile_lnd
77 logical :: SCALE_tile_ocn
78 integer :: SCALE_DOMID_atm = -1
79 integer :: SCALE_DOMID_lnd = -1
80 integer :: SCALE_DOMID_ocn = -1
81 integer :: nfiles_atm = 0
82 integer :: nfiles_lnd = 0
83 integer :: nfiles_ocn = 0
84 integer :: fid_atm = -1
85 integer :: fid_lnd = -1
86 integer :: fid_ocn = -1
87 integer,
allocatable :: fids_atm(:)
88 integer,
allocatable :: fids_lnd(:)
89 integer,
allocatable :: fids_ocn(:)
90 integer,
allocatable :: tile_id_atm(:)
91 integer,
allocatable :: tile_id_lnd(:)
92 integer,
allocatable :: tile_id_ocn(:)
94 integer,
parameter :: vars_max = 100
97 character(len=32) :: zname, zhname
98 character(len=32) :: xname, xhname
99 character(len=32) :: yname, yhname
100 character(len=32) :: tname
102 namelist / netcdf_dims / &
111 character(len=32) :: item
112 character(len=32) :: name
113 logical :: zstg, xstg, ystg
114 real(RP) :: fact, offset
116 namelist / netcdf_item / &
158 file_get_attribute, &
171 integer,
intent(out) :: dims(6)
172 integer,
intent(out) :: timelen
173 logical,
intent(out) :: mixing_ratio
174 logical,
intent(out) :: update_coord
176 logical,
intent(out) :: qtrc_flag(
qa)
177 real(rp),
allocatable,
intent(out) :: lon_all(:,:)
178 real(rp),
allocatable,
intent(out) :: lat_all(:,:)
180 character(len=*),
intent(in) :: basename_org
181 character(len=*),
intent(in) :: basename_num
182 logical,
intent(in) :: same_mptype
184 logical,
intent(inout) :: pt_dry
185 logical,
intent(inout) :: serial
186 logical,
intent(inout) :: do_read
188 character(len=8) :: file_type
189 character(len=FILE_HLONG) :: nm_file
190 integer :: scale_parent_prc_num_x
191 integer :: scale_parent_prc_num_y
192 character(len=FILE_HLONG) :: scale_latlon_catalogue
194 namelist / param_mkinit_real_atmos_netcdf / &
198 scale_parent_prc_num_x, &
199 scale_parent_prc_num_y, &
200 scale_latlon_catalogue
202 character(len=H_SHORT) :: mapping_name
203 real(
dp) :: false_easting
204 real(
dp) :: false_northing
205 real(
dp) :: longitude_of_central_meridian
206 real(
dp) :: longitude_of_projection_origin
207 real(
dp) :: latitude_of_projection_origin
208 real(
dp) :: straight_vertical_longitude_from_pole
209 real(
dp) :: standard_parallel(2)
212 namelist / netcdf_mapprojection / &
216 longitude_of_central_meridian, &
217 longitude_of_projection_origin, &
218 latitude_of_projection_origin, &
219 straight_vertical_longitude_from_pole, &
223 character(len=32) :: items(vars_max)
225 type(vinfo),
pointer :: var_info
226 class(*),
pointer :: v
228 character(len=FILE_HLONG) :: basename
229 character(len=FILE_HLONG) :: fname
230 character(len=16) :: map
235 logical :: exist, error
239 log_info(
"ParentAtmosSetupNetCDF",*)
'Real Case/Atmos Setup'
243 mixing_ratio = .false.
244 scale_parent_prc_num_x = -1
245 scale_parent_prc_num_y = -1
246 scale_latlon_catalogue =
""
250 read(
io_fid_conf,nml=param_mkinit_real_atmos_netcdf,iostat=ierr)
252 log_error(
"ParentAtmosSetupNetCDF",*)
'Not appropriate names in namelist PARAM_MKINIT_REAL_ATMOS_NetCDF. Check!'
255 log_nml(param_mkinit_real_atmos_netcdf)
257 basename = trim(basename_org) // trim(basename_num)
261 call check_filetype(fid_atm, file_type, basename, scale_tile_atm,
"ParentAtmosOpenNetCDF")
264 call comm_bcast( file_type )
266 if ( file_type ==
"SCALE-RM" )
then
267 call comm_bcast( scale_tile_atm )
268 if ( scale_tile_atm )
then
278 false_easting = undef
279 false_easting = undef
280 longitude_of_central_meridian = undef
281 longitude_of_projection_origin = undef
282 latitude_of_projection_origin = undef
283 straight_vertical_longitude_from_pole = undef
284 standard_parallel = (/ undef, undef /)
289 select case( file_type )
299 call vars_atmos%put(
"lon", vinfo(
"lon"))
300 call vars_atmos%put(
"lat", vinfo(
"lat"))
302 call vars_atmos%put(
"height", vinfo(
"height"))
303 call vars_atmos%put(
"pressure", vinfo(
"PRES"))
305 call vars_atmos%put(
"DENS", vinfo(
"DENS"))
306 call vars_atmos%put(
"W", vinfo(
"W"))
307 call vars_atmos%put(
"MOMZ", vinfo(
"MOMZ", zstg=.true.))
308 call vars_atmos%put(
"Umet", vinfo(
"Umet"))
309 call vars_atmos%put(
"U", vinfo(
"U"))
310 call vars_atmos%put(
"MOMX", vinfo(
"MOMX", xstg=.true.))
311 call vars_atmos%put(
"Vmet", vinfo(
"Vmet"))
312 call vars_atmos%put(
"V", vinfo(
"V"))
313 call vars_atmos%put(
"MOMY", vinfo(
"MOMY", ystg=.true.))
315 call vars_atmos%put(
"PT", vinfo(
"PT"))
316 call vars_atmos%put(
"T", vinfo(
"T"))
317 call vars_atmos%put(
"RHOT", vinfo(
"RHOT"))
319 call vars_atmos%put(
"QV", vinfo(
"QV"))
320 call vars_atmos%put(
"RH", vinfo(
"RH"))
322 if ( same_mptype )
then
327 call vars_atmos%put(
"QC", vinfo(
"QC"))
328 call vars_atmos%put(
"QR", vinfo(
"QR"))
329 call vars_atmos%put(
"QI", vinfo(
"QI"))
330 call vars_atmos%put(
"QS", vinfo(
"QS"))
331 call vars_atmos%put(
"QG", vinfo(
"QG"))
333 call vars_atmos%put(
"NC", vinfo(
"NC"))
334 call vars_atmos%put(
"NR", vinfo(
"NR"))
335 call vars_atmos%put(
"NI", vinfo(
"NI"))
336 call vars_atmos%put(
"NS", vinfo(
"NS"))
337 call vars_atmos%put(
"NG", vinfo(
"NG"))
340 call vars_atmos%put(
"topo", vinfo(
"topo"))
341 call vars_atmos%put(
"MSLP", vinfo(
"MSLP"))
342 call vars_atmos%put(
"SFC_PRES", vinfo(
"SFC_PRES"))
343 call vars_atmos%put(
"U10met", vinfo(
"U10met"))
344 call vars_atmos%put(
"U10", vinfo(
"U10"))
345 call vars_atmos%put(
"V10met", vinfo(
"V10met"))
346 call vars_atmos%put(
"V10", vinfo(
"V10"))
347 call vars_atmos%put(
"T2", vinfo(
"T2"))
348 call vars_atmos%put(
"Q2", vinfo(
"Q2"))
349 call vars_atmos%put(
"RH2", vinfo(
"RH2"))
351 mixing_ratio = .false.
352 update_coord = .false.
356 call file_get_attribute( fid_atm,
"QV",
"grid_mapping", map, existed=exist )
358 call file_get_attribute( fid_atm, map,
"grid_mapping_name", mapping_name )
360 call file_get_attribute( fid_atm, map,
"false_easting", false_easting, existed=exist )
361 call file_get_attribute( fid_atm, map,
"false_northing", false_northing, existed=exist )
362 call file_get_attribute( fid_atm, map,
"longitude_of_central_meridian", longitude_of_central_meridian, existed=exist )
363 call file_get_attribute( fid_atm, map,
"longitude_of_projection_origin", longitude_of_projection_origin, existed=exist )
364 call file_get_attribute( fid_atm, map,
"latitude_of_projection_origin", latitude_of_projection_origin, existed=exist )
365 call file_get_attribute( fid_atm, map,
"straight_vertical_longitude_from_pole", straight_vertical_longitude_from_pole, existed=exist )
366 call file_get_attribute( fid_atm, map,
"standard_parallel", standard_parallel(:), existed=exist )
368 call file_get_attribute( fid_atm, map,
"standard_parallel", standard_parallel(1:1), existed=exist )
369 call file_get_attribute( fid_atm, map,
"rotation", rotation, existed=exist )
373 call comm_bcast( mapping_name )
375 call comm_bcast( false_easting )
376 call comm_bcast( false_northing )
377 call comm_bcast( longitude_of_central_meridian )
378 call comm_bcast( longitude_of_projection_origin )
379 call comm_bcast( latitude_of_projection_origin )
380 call comm_bcast( straight_vertical_longitude_from_pole )
381 call comm_bcast( 2, standard_parallel )
382 call comm_bcast( rotation )
386 zhname =
"bottom_top_stag"
388 xhname =
"west_east_stag"
389 yname =
"south_north"
390 yhname =
"south_north_stag"
393 call vars_atmos%put(
"lon", vinfo(
"XLONG"))
394 call vars_atmos%put(
"lat", vinfo(
"XLAT"))
396 call vars_atmos%put(
"hbar", vinfo(
"PHB", zstg=.true., fact=1.0_rp/grav))
397 call vars_atmos%put(
"hdev", vinfo(
"PH", zstg=.true., fact=1.0_rp/grav))
399 call vars_atmos%put(
"pbar", vinfo(
"PB"))
400 call vars_atmos%put(
"pdev", vinfo(
"P"))
402 call file_get_datainfo( fid_atm,
"U", existed=exist )
404 log_info(
"ParentAtmosSetupNetCDF",*)
'WRF-ARW FILE-TYPE: WRF History Output'
405 call vars_atmos%put(
"W", vinfo(
"W",zstg=.true.))
406 call vars_atmos%put(
"U", vinfo(
"U",xstg=.true.))
407 call vars_atmos%put(
"V", vinfo(
"V",ystg=.true.))
408 call vars_atmos%put(
"PT", vinfo(
"T", offset=300.0_rp))
410 log_info(
"ParentAtmosSetupNetCDF",*)
'WRF-ARW FILE-TYPE: WRF Restart'
411 call vars_atmos%put(
"W", vinfo(
"W_1"))
412 call vars_atmos%put(
"U", vinfo(
"U_1"))
413 call vars_atmos%put(
"V", vinfo(
"V_1"))
414 call vars_atmos%put(
"PT", vinfo(
"T_1", offset=300.0_rp))
417 if ( same_mptype )
then
418 log_error(
"ParentAtmosSetupNetCDF",*)
'same_mptype must be .false. for WRF file'
421 call vars_atmos%put(
"QV", vinfo(
"QVAPOR"))
422 call vars_atmos%put(
"QC", vinfo(
"QCLOUD"))
423 call vars_atmos%put(
"QR", vinfo(
"QRAIN"))
424 call vars_atmos%put(
"QI", vinfo(
"QICE"))
425 call vars_atmos%put(
"QS", vinfo(
"QSNOW"))
426 call vars_atmos%put(
"QG", vinfo(
"QGRAUP"))
427 call vars_atmos%put(
"NC", vinfo(
"NC"))
428 call vars_atmos%put(
"NR", vinfo(
"NR"))
429 call vars_atmos%put(
"NI", vinfo(
"NI"))
430 call vars_atmos%put(
"NS", vinfo(
"NS"))
431 call vars_atmos%put(
"NG", vinfo(
"NG"))
433 mixing_ratio = .true.
436 call vars_atmos%put(
"topo", vinfo(
"HGT"))
437 call vars_atmos%put(
"U10", vinfo(
"U10"))
438 call vars_atmos%put(
"V10", vinfo(
"V10"))
439 call vars_atmos%put(
"T2", vinfo(
"T2"))
440 call vars_atmos%put(
"Q2", vinfo(
"Q2"))
441 call vars_atmos%put(
"RH2", vinfo(
"RH2"))
442 call vars_atmos%put(
"SFC_PRES", vinfo(
"PSFC"))
444 call file_get_attribute( fid_atm,
"global",
"MAP_PROJ", i, existed=exist )
447 mapping_name =
"lambert_conformal_conic"
448 call file_get_attribute( fid_atm,
"global",
"TRUELAT1", standard_parallel(1) )
449 call file_get_attribute( fid_atm,
"global",
"TRUELAT2", standard_parallel(2) )
450 call file_get_attribute( fid_atm,
"global",
"STAND_LON", longitude_of_central_meridian )
451 else if ( i >= 3 )
then
454 log_warn(
"ParentAtmodSetupNetCDF",*)
"This map projection type is not supported: ", i
455 log_warn_cont(*)
"Specify map projection parameter manually"
459 update_coord = .true.
463 update_coord = .true.
466 log_error(
"ParentAtmosSetupNetCDF",*)
'FILE_TYPE must be "SCALE-RM", "WRFARW", "NAMELIST", or "AUTO", ', trim(file_type)
472 if ( nm_file /=
"" )
then
475 open(nmfid, file=fname, form=
"formatted", status=
"old", action=
"read", iostat=ierr)
476 if ( ierr /= 0 )
then
477 log_error(
"ParentAtmosSetupNetCDF",*)
'namelist file is not found! ', trim(fname)
481 read(nmfid, nml=netcdf_dims, iostat=ierr)
483 log_error(
"ParentAtmosSetupNetCDF",*)
'Not appropriate names in namelist NetCDF_DIMS in ', trim(fname),
'. Check!'
488 read(nmfid, nml=netcdf_mapprojection, iostat=ierr)
490 log_error(
"ParentAtmosSetupNetCDF",*)
'Not appropriate names in namelist NetCDF_MAPPROJECTION in ', trim(fname),
'. Check!'
497 read(nmfid, nml=netcdf_item, iostat=ierr)
499 log_error(
"ParentAtmosSetupNetCDF",*)
'Not appropriate names in namelist NetCDF_ITEM in ', trim(fname),
'. Check!'
501 else if( ierr < 0 )
then
507 if ( nvars > vars_max )
then
508 log_error(
"ParentAtmosSetupNetCDF",*)
"The number of item in the namelist file exceeds the limit! ", nvars
514 if ( vars_atmos%has_key(items(n)) )
then
516 v => vars_atmos%get(item)
526 offset = var_info%offset
536 read(nmfid, nml=netcdf_item, iostat=ierr)
537 if ( ierr /= 0 )
exit
539 call vars_atmos%put(item, vinfo(name=name, zstg=zstg, xstg=xstg, ystg=ystg, fact=fact, offset=offset))
542 else if ( file_type ==
"NAMELIST" )
then
543 log_error(
"ParentAtmosSetupNetCDF",*)
'NM_FILE is necessary'
547 mapping_info%mapping_name = mapping_name
548 if ( false_easting /= undef ) mapping_info%false_easting = false_easting
549 if ( false_northing /= undef ) mapping_info%false_northing = false_northing
550 if ( longitude_of_central_meridian /= undef ) mapping_info%longitude_of_central_meridian = longitude_of_central_meridian
551 if ( longitude_of_projection_origin /= undef ) mapping_info%longitude_of_projection_origin = longitude_of_projection_origin
552 if ( latitude_of_projection_origin /= undef ) mapping_info%latitude_of_projection_origin = latitude_of_projection_origin
553 if ( straight_vertical_longitude_from_pole /= undef ) mapping_info%straight_vertical_longitude_from_pole = straight_vertical_longitude_from_pole
554 if ( standard_parallel(1) /= undef ) mapping_info%standard_parallel(1) = standard_parallel(1)
555 if ( standard_parallel(2) /= undef ) mapping_info%standard_parallel(2) = standard_parallel(2)
556 if ( rotation /= undef ) mapping_info%rotation = rotation
560 if ( scale_tile_atm )
then
565 scale_parent_prc_num_x, &
566 scale_parent_prc_num_y, &
567 scale_latlon_catalogue )
574 num_tile=nfiles_atm )
580 allocate( fids_atm(nfiles_atm) )
581 allocate( tile_id_atm(nfiles_atm) )
585 tile_id = tile_id_atm )
589 else if ( do_read )
then
604 qtrc_flag(iq) = .false.
606 select type ( v => vars_atmos%get(
tracer_name(iq) ) )
608 if ( v%name .ne.
"" )
then
609 call file_get_datainfo( fid_atm, v%name, existed = qtrc_flag(iq) )
616 if ( error ) timelen = 1
618 allocate( lon_all(dims(2), dims(3)) )
619 allocate( lat_all(dims(2), dims(3)) )
621 call read2d( dims(2), 1, dims(2), dims(3), 1, dims(3), &
622 lon_all(:,:), vars_atmos%get(
"lon"), &
623 1, nfiles_atm, fid_atm, fids_atm, scale_tile_atm, scale_domid_atm )
624 lon_all(:,:) = lon_all(:,:) * d2r
625 call read2d( dims(2), 1, dims(2), dims(3), 1, dims(3), &
626 lat_all(:,:), vars_atmos%get(
"lat"), &
627 1, nfiles_atm, fid_atm, fids_atm, scale_tile_atm, scale_domid_atm )
628 lat_all(:,:) = lat_all(:,:) * d2r
641 basename_org, basename_num )
645 character(len=*),
intent(in) :: basename_org
646 character(len=*),
intent(in) :: basename_num
648 character(len=FILE_HLONG) :: basename
654 log_info(
"ParentAtmosOpenNetCDF",*)
'Real Case/Atmos Open'
657 basename = trim(basename_org) // trim(basename_num)
659 if ( scale_tile_atm )
then
667 rankid=tile_id_atm(n) )
670 fid_atm = fids_atm(1)
674 call file_open(basename, fid_atm, postfix=
"")
688 log_info(
"ParentAtmosFinalizeNetCDF",*)
'Real Case/Atmos Finalize'
692 if (
allocated(fids_atm) )
deallocate( fids_atm )
693 if (
allocated(tile_id_atm) )
deallocate( tile_id_atm )
695 call vars_atmos%destroy()
706 KA_org, KS_org, KE_org, &
707 IA_org, IS_org, IE_org, &
708 JA_org, JS_org, JE_org, &
711 w_org, u_org, v_org, &
717 qhyd_org, qnum_org, &
737 integer,
intent(in) :: ka_org, ks_org, ke_org
738 integer,
intent(in) :: ia_org, is_org, ie_org
739 integer,
intent(in) :: ja_org, js_org, je_org
740 integer,
intent(in) ::
qa
742 real(rp),
intent(inout) :: cz_org(ka_org,ia_org,ja_org)
744 real(rp),
intent(out) :: w_org(ka_org,ia_org,ja_org)
745 real(rp),
intent(out) :: u_org(ka_org,ia_org,ja_org)
746 real(rp),
intent(out) :: v_org(ka_org,ia_org,ja_org)
747 real(rp),
intent(out) :: pres_org(ka_org,ia_org,ja_org)
748 real(rp),
intent(out) :: dens_org(ka_org,ia_org,ja_org)
749 real(rp),
intent(out) :: temp_org(ka_org,ia_org,ja_org)
750 real(rp),
intent(out) :: pt_org(ka_org,ia_org,ja_org)
751 real(rp),
intent(out) :: qtrc_org(ka_org,ia_org,ja_org,
qa)
752 real(rp),
intent(out) :: qv_org(ka_org,ia_org,ja_org)
753 real(rp),
intent(out) :: rh_org(ka_org,ia_org,ja_org)
754 real(rp),
intent(out) :: qhyd_org(ka_org,ia_org,ja_org,
n_hyd)
755 real(rp),
intent(out) :: qnum_org(ka_org,ia_org,ja_org,
n_hyd)
756 logical,
intent(out) :: nopres
757 logical,
intent(out) :: nodens
758 logical,
intent(out) :: uvmet
759 logical,
intent(out) :: temp2pt
760 logical,
intent(out) :: rh2qv
761 logical,
intent(out) :: qnum_flag
763 logical,
intent(in) :: same_mptype
764 logical,
intent(in) :: sfc_diagnoses
765 logical,
intent(in) :: update_coord
766 integer,
intent(in) :: dims(6)
767 integer,
intent(in) :: it
771 integer ::
k, i, j, iq
774 if ( .not.
allocated( work2d ) )
then
775 allocate( work2d(ia_org,ja_org) )
776 allocate( work3d(ka_org-2,ia_org,ja_org) )
780 if ( first_atm .or. update_coord )
then
781 call read3d( ka_org, ks_org+2, ke_org, ia_org, is_org, ie_org, ja_org, js_org, je_org, &
782 cz_org(:,:,:), vars_atmos%get(
"height"), &
783 it, nfiles_atm, fid_atm, fids_atm, scale_tile_atm, scale_domid_atm, &
785 if ( .not. exist )
then
786 call read3d( ka_org, ks_org+2, ke_org, ia_org, is_org, ie_org, ja_org, js_org, je_org, &
787 cz_org(:,:,:), vars_atmos%get(
"hbar"), &
788 it, nfiles_atm, fid_atm, fids_atm, scale_tile_atm, scale_domid_atm, &
791 call read3d( ka_org-2, ks_org, ke_org-2, ia_org, is_org, ie_org, ja_org, js_org, je_org, &
792 work3d(:,:,:), vars_atmos%get(
"hdev"), &
793 it, nfiles_atm, fid_atm, fids_atm, scale_tile_atm, scale_domid_atm, &
796 if ( .not. exist )
then
797 log_error(
"ParentAtmosInputNetCDF",*)
'"height" or "hbar"+"hdev" is necessary'
804 cz_org(
k+2,i,j) = cz_org(
k+2,i,j) + work3d(
k,i,j)
815 call read3d( ka_org, ks_org+2, ke_org, ia_org, is_org, ie_org, ja_org, js_org, je_org, &
816 qtrc_org(:,:,:,iq), vars_atmos%get(
tracer_name(iq)), &
817 it, nfiles_atm, fid_atm, fids_atm, scale_tile_atm, scale_domid_atm, &
819 if ( .not. exist )
then
824 qtrc_org(
k+2,i,j,iq) = undef
832 if ( same_mptype )
then
835 call read3d( ka_org, ks_org+2, ke_org, ia_org, is_org, ie_org, ja_org, js_org, je_org, &
836 qtrc_org(:,:,:,iq), vars_atmos%get(
tracer_name(iq)), &
837 it, nfiles_atm, fid_atm, fids_atm, scale_tile_atm, scale_domid_atm, &
839 if ( .not. exist )
then
844 qtrc_org(
k+2,i,j,iq) = undef
854 call read3d( ka_org, ks_org+2, ke_org, ia_org, is_org, ie_org, ja_org, js_org, je_org, &
855 qv_org(:,:,:), vars_atmos%get(
"QV"), &
856 it, nfiles_atm, fid_atm, fids_atm, scale_tile_atm, scale_domid_atm, &
861 call read3d( ka_org, ks_org+2, ke_org, ia_org, is_org, ie_org, ja_org, js_org, je_org, &
862 rh_org(:,:,:), vars_atmos%get(
"RH"), &
863 it, nfiles_atm, fid_atm, fids_atm, scale_tile_atm, scale_domid_atm )
870 call read3d( ka_org, ks_org+2, ke_org, ia_org, is_org, ie_org, ja_org, js_org, je_org, &
871 qhyd_org(:,:,:,iq), vars_atmos%get(
hyd_name(iq)), &
872 it, nfiles_atm, fid_atm, fids_atm, scale_tile_atm, scale_domid_atm, &
874 if ( .not. exist )
then
879 qhyd_org(
k+2,i,j,iq) = 0.0_rp
885 call read3d( ka_org, ks_org+2, ke_org, ia_org, is_org, ie_org, ja_org, js_org, je_org, &
886 qnum_org(:,:,:,iq), vars_atmos%get(
num_name(iq)), &
887 it, nfiles_atm, fid_atm, fids_atm, scale_tile_atm, scale_domid_atm, &
896 qnum_org(
k+2,i,j,iq) = undef
906 call read3d( ka_org, ks_org+2, ke_org, ia_org, is_org, ie_org, ja_org, js_org, je_org, &
907 pres_org(:,:,:), vars_atmos%get(
"pressure"), &
908 it, nfiles_atm, fid_atm, fids_atm, scale_tile_atm, scale_domid_atm, &
910 if ( .not. exist )
then
911 call read3d( ka_org, ks_org+2, ke_org, ia_org, is_org, ie_org, ja_org, js_org, je_org, &
912 pres_org(:,:,:), vars_atmos%get(
"pbar"), &
913 it, nfiles_atm, fid_atm, fids_atm, scale_tile_atm, scale_domid_atm, &
916 call read3d( ka_org-2, ks_org, ke_org-2, ia_org, is_org, ie_org, ja_org, js_org, je_org, &
917 work3d(:,:,:), vars_atmos%get(
"pdev"), &
918 it, nfiles_atm, fid_atm, fids_atm, scale_tile_atm, scale_domid_atm, &
920 if ( .not. exist )
then
921 log_error(
"ParentAtmosInputNetCDF",*)
'"pdev" is necessary if "pbar" exists'
928 pres_org(
k+2,i,j) = pres_org(
k+2,i,j) + work3d(
k,i,j)
941 call read3d( ka_org, ks_org+2, ke_org, ia_org, is_org, ie_org, ja_org, js_org, je_org, &
942 dens_org(:,:,:), vars_atmos%get(
"DENS"), &
943 it, nfiles_atm, fid_atm, fids_atm, scale_tile_atm, scale_domid_atm, &
952 call read3d( ka_org, ks_org+2, ke_org, ia_org, is_org, ie_org, ja_org, js_org, je_org, &
953 pt_org(:,:,:), vars_atmos%get(
"PT"), &
954 it, nfiles_atm, fid_atm, fids_atm, scale_tile_atm, scale_domid_atm, &
959 call read3d( ka_org, ks_org+2, ke_org, ia_org, is_org, ie_org, ja_org, js_org, je_org, &
960 pt_org(:,:,:), vars_atmos%get(
"RHOT"), &
961 it, nfiles_atm, fid_atm, fids_atm, scale_tile_atm, scale_domid_atm, &
965 log_error(
"ParentAtmosInputNetCDF",*)
"DENS is necessary to calculate PT from RHOT"
972 pt_org(
k+2,i,j) = pt_org(
k+2,i,j) / dens_org(
k+2,i,j)
978 call read3d( ka_org, ks_org+2, ke_org, ia_org, is_org, ie_org, ja_org, js_org, je_org, &
979 temp_org(:,:,:), vars_atmos%get(
"T"), &
980 it, nfiles_atm, fid_atm, fids_atm, scale_tile_atm, scale_domid_atm, &
982 if ( .not. exist )
then
983 log_error(
"ParentAtmosInputNetCDF",*)
'"PT", "RHOT", or "T" is necessary'
991 call read3d( ka_org, ks_org+2, ke_org, ia_org, is_org, ie_org, ja_org, js_org, je_org, &
992 w_org(:,:,:), vars_atmos%get(
"W"), &
993 it, nfiles_atm, fid_atm, fids_atm, scale_tile_atm, scale_domid_atm, &
995 if ( .not. exist )
then
997 log_error(
"ParentAtmosInputNetCDF",*)
"DENS is necessary to use MOMZ"
1000 call read3d( ka_org, ks_org+2, ke_org, ia_org, is_org, ie_org, ja_org, js_org, je_org, &
1001 w_org(:,:,:), vars_atmos%get(
"MOMZ"), &
1002 it, nfiles_atm, fid_atm, fids_atm, scale_tile_atm, scale_domid_atm, &
1009 w_org(
k+2,i,j) = w_org(
k+2,i,j) / dens_org(
k+2,i,j)
1018 w_org(
k+2,i,j) = 0.0_rp
1026 call read3d( ka_org, ks_org+2, ke_org, ia_org, is_org, ie_org, ja_org, js_org, je_org, &
1027 u_org(:,:,:), vars_atmos%get(
"Umet"), &
1028 it, nfiles_atm, fid_atm, fids_atm, scale_tile_atm, scale_domid_atm, &
1033 call read3d( ka_org, ks_org+2, ke_org, ia_org, is_org, ie_org, ja_org, js_org, je_org, &
1034 u_org(:,:,:), vars_atmos%get(
"U"), &
1035 it, nfiles_atm, fid_atm, fids_atm, scale_tile_atm, scale_domid_atm, &
1037 if ( .not. exist )
then
1039 log_error(
"ParentAtmosInputNetCDF",*)
"DENS is necessary to use MOMX"
1042 call read3d( ka_org, ks_org+2, ke_org, ia_org, is_org, ie_org, ja_org, js_org, je_org, &
1043 u_org(:,:,:), vars_atmos%get(
"MOMX"), &
1044 it, nfiles_atm, fid_atm, fids_atm, scale_tile_atm, scale_domid_atm, &
1046 if ( .not. exist )
then
1047 log_error(
"ParentAtmosInputNetCDF",*)
'"Ument", "U", or "MOMX" is necessary'
1054 u_org(
k+2,i,j) = u_org(
k+2,i,j) / dens_org(
k+2,i,j)
1064 call read3d( ka_org, ks_org+2, ke_org, ia_org, is_org, ie_org, ja_org, js_org, je_org, &
1065 v_org(:,:,:), vars_atmos%get(
"Vmet"), &
1066 it, nfiles_atm, fid_atm, fids_atm, scale_tile_atm, scale_domid_atm, &
1068 if ( .not. exist )
then
1069 log_error(
"ParentAtmosInputNetCDF",*)
"Vmet is required when Umet exists"
1073 call read3d( ka_org, ks_org+2, ke_org, ia_org, is_org, ie_org, ja_org, js_org, je_org, &
1074 v_org(:,:,:), vars_atmos%get(
"V"), &
1075 it, nfiles_atm, fid_atm, fids_atm, scale_tile_atm, scale_domid_atm, &
1077 if ( .not. exist )
then
1079 log_error(
"ParentAtmosInputNetCDF",*)
"DENS is necessary to use MOMY"
1082 call read3d( ka_org, ks_org+2, ke_org, ia_org, is_org, ie_org, ja_org, js_org, je_org, &
1083 v_org(:,:,:), vars_atmos%get(
"MOMY"), &
1084 it, nfiles_atm, fid_atm, fids_atm, scale_tile_atm, scale_domid_atm, &
1086 if ( .not. exist )
then
1087 log_error(
"ParentAtmosInputNetCDF",*)
'"V" or "MOMY" is required when "U" or "MOMX" exists'
1094 v_org(
k+2,i,j) = v_org(
k+2,i,j) / dens_org(
k+2,i,j)
1102 if ( sfc_diagnoses )
then
1107 cz_org(1,i,j) = 0.0_rp
1112 if ( first_atm .or. update_coord )
then
1114 call read2d( ia_org, is_org, ie_org, ja_org, js_org, je_org, &
1115 work2d(:,:), vars_atmos%get(
"topo"), &
1116 it, nfiles_atm, fid_atm, fids_atm, scale_tile_atm, scale_domid_atm, &
1122 cz_org(2,i,j) = work2d(i,j)
1129 cz_org(2,i,j) = undef
1136 call read2d( ia_org, is_org, ie_org, ja_org, js_org, je_org, &
1137 work2d(:,:), vars_atmos%get(
"MSLP"), &
1138 it, nfiles_atm, fid_atm, fids_atm, scale_tile_atm, scale_domid_atm, &
1144 pres_org(1,i,j) = work2d(i,j)
1151 pres_org(1,i,j) = undef
1157 call read2d( ia_org, is_org, ie_org, ja_org, js_org, je_org, &
1158 work2d(:,:), vars_atmos%get(
"SFC_PRES"), &
1159 it, nfiles_atm, fid_atm, fids_atm, scale_tile_atm, scale_domid_atm, &
1165 pres_org(2,i,j) = work2d(i,j)
1172 pres_org(2,i,j) = undef
1179 call read2d( ia_org, is_org, ie_org, ja_org, js_org, je_org, &
1180 work2d(:,:), vars_atmos%get(
"U10met"), &
1181 it, nfiles_atm, fid_atm, fids_atm, scale_tile_atm, scale_domid_atm, &
1187 u_org(2,i,j) = work2d(i,j)
1194 u_org(2,i,j) = undef
1198 call read2d( ia_org, is_org, ie_org, ja_org, js_org, je_org, &
1199 work2d(:,:), vars_atmos%get(
"V10met"), &
1200 it, nfiles_atm, fid_atm, fids_atm, scale_tile_atm, scale_domid_atm, &
1206 v_org(2,i,j) = work2d(i,j)
1213 v_org(2,i,j) = undef
1218 call read2d( ia_org, is_org, ie_org, ja_org, js_org, je_org, &
1219 work2d(:,:), vars_atmos%get(
"U10"), &
1220 it, nfiles_atm, fid_atm, fids_atm, scale_tile_atm, scale_domid_atm, &
1226 u_org(2,i,j) = work2d(i,j)
1233 u_org(2,i,j) = undef
1237 call read2d( ia_org, is_org, ie_org, ja_org, js_org, je_org, &
1238 work2d(:,:), vars_atmos%get(
"V10"), &
1239 it, nfiles_atm, fid_atm, fids_atm, scale_tile_atm, scale_domid_atm, &
1245 v_org(2,i,j) = work2d(i,j)
1252 v_org(2,i,j) = undef
1259 call read2d( ia_org, is_org, ie_org, ja_org, js_org, je_org, &
1260 work2d(:,:), vars_atmos%get(
"T2"), &
1261 it, nfiles_atm, fid_atm, fids_atm, scale_tile_atm, scale_domid_atm, &
1267 temp_org(2,i,j) = work2d(i,j)
1274 call read2d( ia_org, is_org, ie_org, ja_org, js_org, je_org, &
1275 work2d(:,:), vars_atmos%get(
"RH2"), &
1276 it, nfiles_atm, fid_atm, fids_atm, scale_tile_atm, scale_domid_atm, &
1282 rh_org(2,i,j) = work2d(i,j)
1289 rh_org(2,i,j) = undef
1294 call read2d( ia_org, is_org, ie_org, ja_org, js_org, je_org, &
1295 work2d(:,:), vars_atmos%get(
"Q2"), &
1296 it, nfiles_atm, fid_atm, fids_atm, scale_tile_atm, scale_domid_atm, &
1299 if ( same_mptype )
then
1303 qtrc_org(2,i,j,
qs_mp) = work2d(i,j)
1310 qv_org(2,i,j) = work2d(i,j)
1318 qv_org(2,i,j) = undef
1330 cz_org(1,i,j) = 0.0_rp
1331 cz_org(2,i,j) = 0.0_rp
1332 pres_org(1,i,j) = undef
1333 pres_org(2,i,j) = undef
1334 u_org(2,i,j) = undef
1335 v_org(2,i,j) = undef
1336 temp_org(2,i,j) = undef
1337 pt_org(2,i,j) = undef
1338 qv_org(2,i,j) = undef
1339 rh_org(2,i,j) = undef
1359 use_file_landwater, &
1374 integer,
intent(out) :: ldims(3)
1375 integer,
intent(out) :: timelen
1376 real(rp),
allocatable,
intent(out) :: lon_all(:,:)
1377 real(rp),
allocatable,
intent(out) :: lat_all(:,:)
1379 character(len=*),
intent(in) :: basename_org
1380 character(len=*),
intent(in) :: basename_num
1381 logical,
intent(in) :: use_file_landwater
1383 logical,
intent(inout) :: serial
1384 logical,
intent(inout) :: do_read
1386 character(len=8) :: file_type =
"AUTO"
1387 character(len=FILE_HLONG) :: nm_file
1388 logical :: scale_multi_file = .true.
1389 integer :: scale_parent_prc_num_x
1390 integer :: scale_parent_prc_num_y
1391 character(len=FILE_HLONG) :: scale_latlon_catalogue
1393 namelist / param_mkinit_real_land_netcdf / &
1396 scale_parent_prc_num_x, &
1397 scale_parent_prc_num_y, &
1398 scale_latlon_catalogue
1400 character(len=FILE_HLONG) :: basename
1401 character(len=FILE_HLONG) :: fname
1404 character(len=32) :: items(vars_max)
1406 type(vinfo),
pointer :: var_info
1407 class(*),
pointer :: v
1409 logical :: error, exist
1414 log_info(
"ParentLandSetupNetCDF",*)
'Real Case/Land Setup'
1418 scale_parent_prc_num_x = -1
1419 scale_parent_prc_num_y = -1
1420 scale_latlon_catalogue =
""
1424 read(
io_fid_conf,nml=param_mkinit_real_land_netcdf,iostat=ierr)
1426 log_error(
"ParentLandSetupNetCDF",*)
'Not appropriate names in namelist PARAM_MKINIT_REAL_LAND_NetCDF. Check!'
1429 log_nml(param_mkinit_real_land_netcdf)
1432 basename = trim(basename_org) // trim(basename_num)
1436 call check_filetype(fid_lnd, file_type, basename, scale_tile_lnd,
"ParentLandSetupNetCDF")
1439 call comm_bcast( file_type )
1441 if ( file_type ==
"SCALE-RM" )
then
1442 call comm_bcast( scale_tile_lnd )
1443 if ( scale_tile_lnd )
then
1452 select case( file_type )
1459 call vars_land%put(
"lon", vinfo(
"lon"))
1460 call vars_land%put(
"lat", vinfo(
"lat"))
1461 call vars_land%put(
"lz", vinfo(
"lz"))
1463 call vars_land%put(
"topo", vinfo(
"topo"))
1464 call vars_land%put(
"lsmask", vinfo(
"lsmask"))
1466 call vars_land%put(
"LAND_TEMP", vinfo(
"LAND_TEMP"))
1467 if ( use_file_landwater )
then
1468 call vars_land%put(
"LAND_WATER", vinfo(
"LAND_WATER"))
1471 call vars_land%put(
"LAND_SFC_TEMP", vinfo(
"LAND_SFC_TEMP"))
1473 call vars_land%put(
"LAND_SFC_ALB_IR_dir", vinfo(
"LAND_SFC_ALB_IR_dir"))
1474 call vars_land%put(
"LAND_SFC_ALB_IR_dif", vinfo(
"LAND_SFC_ALB_IR_dif"))
1475 call vars_land%put(
"LAND_SFC_ALB_NIR_dir", vinfo(
"LAND_SFC_ALB_NIR_dir"))
1476 call vars_land%put(
"LAND_SFC_ALB_NIR_dif", vinfo(
"LAND_SFC_ALB_NIR_dif"))
1477 call vars_land%put(
"LAND_SFC_ALB_VIS_dir", vinfo(
"LAND_SFC_ALB_VIS_dir"))
1478 call vars_land%put(
"LAND_SFC_ALB_VIS_dif", vinfo(
"LAND_SFC_ALB_VIS_dif"))
1480 call vars_land%put(
"URBAN_SFC_TEMP", vinfo(
"URBAN_SFC_TEMP"))
1483 zname =
"soil_layers_stag"
1485 yname =
"south_north"
1488 call vars_land%put(
"lon", vinfo(
"XLONG"))
1489 call vars_land%put(
"lat", vinfo(
"XLAT"))
1490 call vars_land%put(
"lz", vinfo(
"ZS"))
1492 call vars_land%put(
"topo", vinfo(
"HGT"))
1493 call vars_land%put(
"lsmask", vinfo(
"LANDMASK"))
1495 call vars_land%put(
"LAND_TEMP", vinfo(
"TSLB"))
1496 if ( use_file_landwater )
then
1497 call vars_land%put(
"LAND_WATER", vinfo(
"SH2O"))
1500 call vars_land%put(
"LAND_SFC_TEMP", vinfo(
"TSK"))
1502 call vars_land%put(
"LAND_SFC_ALB_VIS_dir", vinfo(
"ALBEDO"))
1503 call vars_land%put(
"LAND_SFC_EMIS_IR_dif", vinfo(
"EMISS"))
1505 call vars_land%put(
"URBAN_SFC_TEMP", vinfo(
"URBAN_SFC_TEMP"))
1512 log_error(
"ParentLandSetupNetCDF",*)
'FILE_TYPE must be "SCALE-RM", "WRFARW", or "AUTO", ', trim(file_type)
1519 if ( nm_file /=
"" )
then
1522 open(nmfid, file=fname, form=
"formatted", status=
"old", action=
"read", iostat=ierr)
1523 if ( ierr /= 0 )
then
1524 log_error(
"ParentLandSetupNetCDF",*)
'namelist file is not found! ', trim(fname)
1529 read(nmfid, nml=netcdf_dims, iostat=ierr)
1531 log_error(
"ParentLandSetupNetCDF",*)
'Not appropriate names in namelist NetCDF_DIMS in ', trim(fname),
'. Check!'
1539 read(nmfid, nml=netcdf_item, iostat=ierr)
1541 log_error(
"ParentLandSetupNetCDF",*)
'Not appropriate names in namelist NetCDF_ITEM in ', trim(fname),
'. Check!'
1543 else if( ierr < 0 )
then
1549 if ( nvars > vars_max )
then
1550 log_error(
"ParentLandSetupNetCDF",*)
"The number of item in the namelist file exceeds the limit! ", nvars
1556 if ( vars_land%has_key(items(n)) )
then
1558 v => vars_land%get(item)
1563 name = var_info%name
1564 fact = var_info%fact
1565 offset = var_info%offset
1575 read(nmfid, nml=netcdf_item, iostat=ierr)
1576 if ( ierr /= 0 )
exit
1578 call vars_land%put(item, vinfo(name=name, zstg=zstg, xstg=xstg, ystg=ystg, fact=fact, offset=offset))
1581 else if ( file_type ==
"NAMELIST" )
then
1582 log_error(
"ParentLANDSetupNetCDF",*)
'NM_FILE is necessary'
1588 if ( scale_tile_lnd )
then
1593 scale_parent_prc_num_x, &
1594 scale_parent_prc_num_y, &
1595 scale_latlon_catalogue )
1602 num_tile=nfiles_lnd )
1604 allocate( fids_lnd(nfiles_lnd) )
1605 allocate( tile_id_lnd(nfiles_lnd) )
1609 tile_id = tile_id_lnd )
1613 else if ( do_read )
then
1624 if ( error ) timelen = 1
1626 allocate( lon_all(ldims(2), ldims(3)) )
1627 allocate( lat_all(ldims(2), ldims(3)) )
1629 call read2d( ldims(2), 1, ldims(2), ldims(3), 1, ldims(3), &
1630 lon_all(:,:), vars_land%get(
"lon"), &
1631 1, nfiles_lnd, fid_lnd, fids_lnd, scale_tile_lnd, scale_domid_lnd )
1632 lon_all(:,:) = lon_all(:,:) * d2r
1633 call read2d( ldims(2), 1, ldims(2), ldims(3), 1, ldims(3), &
1634 lat_all(:,:), vars_land%get(
"lat"), &
1635 1, nfiles_lnd, fid_lnd, fids_lnd, scale_tile_lnd, scale_domid_lnd )
1636 lat_all(:,:) = lat_all(:,:) * d2r
1648 basename_org, basename_num )
1652 character(len=*),
intent(in) :: basename_org
1653 character(len=*),
intent(in) :: basename_num
1655 character(len=FILE_HLONG) :: basename
1661 log_info(
"ParentLandOpenNetCDF",*)
'Real Case/Land Open'
1663 basename = trim(basename_org) // trim(basename_num)
1665 if ( scale_tile_lnd )
then
1667 do n = 1, nfiles_lnd
1671 aggregate=.false., &
1673 rankid=tile_id_lnd(n) )
1676 fid_lnd = fids_lnd(1)
1680 call file_open(basename, fid_lnd, postfix=
"")
1694 log_info(
"ParentLandFinalizeNetCDF",*)
'Real Case/Land Finalize'
1696 if (
allocated(fids_lnd) )
deallocate( fids_lnd )
1697 if (
allocated(tile_id_lnd) )
deallocate( tile_id_lnd )
1699 call vars_land%destroy()
1701 scale_domid_lnd = -1
1710 KA_org, KS_org, KE_org, &
1711 IA_org, IS_org, IE_org, &
1712 JA_org, JS_org, JE_org, &
1721 use_file_landwater, &
1728 integer,
intent(in) :: ka_org, ks_org, ke_org
1729 integer,
intent(in) :: ia_org, is_org, ie_org
1730 integer,
intent(in) :: ja_org, js_org, je_org
1732 real(rp),
intent(out) :: tg_org(ka_org,ia_org,ja_org)
1733 real(rp),
intent(out) :: strg_org(ka_org,ia_org,ja_org)
1734 real(rp),
intent(out) :: lst_org(ia_org,ja_org)
1735 real(rp),
intent(out) :: ust_org(ia_org,ja_org)
1738 real(rp),
intent(inout) :: topo_org(ia_org,ja_org)
1739 real(rp),
intent(inout) :: lmask_org(ia_org,ja_org)
1740 real(rp),
intent(inout) :: lz_org(ka_org)
1742 logical,
intent(in) :: use_file_landwater
1743 integer,
intent(in) :: ldims(3)
1744 integer,
intent(in) :: it
1750 if ( first_lnd )
then
1751 call read2d( ia_org, is_org, ie_org, ja_org, js_org, je_org, &
1752 topo_org(:,:), vars_land%get(
"topo"), &
1753 it, nfiles_lnd, fid_lnd, fids_lnd, scale_tile_lnd, scale_domid_lnd )
1755 call read1d( ka_org, lz_org(:), vars_land%get(
"lz"), it, fid_lnd )
1757 call read2d( ia_org, is_org, ie_org, ja_org, js_org, je_org, &
1758 lmask_org(:,:), vars_land%get(
"lsmask"), &
1759 it, nfiles_lnd, fid_lnd, fids_lnd, scale_tile_lnd, scale_domid_lnd )
1762 call read3d( ka_org, ks_org, ke_org, ia_org, is_org, ie_org, ja_org, js_org, je_org, &
1763 tg_org(:,:,:), vars_land%get(
"LAND_TEMP"), &
1764 it, nfiles_lnd, fid_lnd, fids_lnd, scale_tile_lnd, scale_domid_lnd )
1768 if( use_file_landwater )
then
1769 call read3d( ka_org, ks_org, ke_org, ia_org, is_org, ie_org, ja_org, js_org, je_org, &
1770 strg_org(:,:,:), vars_land%get(
"LAND_WATER"), &
1771 it, nfiles_lnd, fid_lnd, fids_lnd, scale_tile_lnd, scale_domid_lnd )
1774 call read2d( ia_org, is_org, ie_org, ja_org, js_org, je_org, &
1775 lst_org(:,:), vars_land%get(
"LAND_SFC_TEMP"), &
1776 it, nfiles_lnd, fid_lnd, fids_lnd, scale_tile_lnd, scale_domid_lnd )
1778 call read2d( ia_org, is_org, ie_org, ja_org, js_org, je_org, &
1779 ust_org(:,:), vars_land%get(
"URBAN_SFC_TEMP"), &
1780 it, nfiles_lnd, fid_lnd, fids_lnd, scale_tile_lnd, scale_domid_lnd, &
1782 if ( .not. exist )
then
1786 ust_org(i,j) = lst_org(i,j)
1791 call read2d( ia_org, is_org, ie_org, ja_org, js_org, je_org, &
1793 it, nfiles_lnd, fid_lnd, fids_lnd, scale_tile_lnd, scale_domid_lnd )
1794 call read2d( ia_org, is_org, ie_org, ja_org, js_org, je_org, &
1796 it, nfiles_lnd, fid_lnd, fids_lnd, scale_tile_lnd, scale_domid_lnd, &
1798 if ( .not. exist )
then
1806 call read2d( ia_org, is_org, ie_org, ja_org, js_org, je_org, &
1808 it, nfiles_lnd, fid_lnd, fids_lnd, scale_tile_lnd, scale_domid_lnd, &
1810 if ( .not. exist )
then
1818 call read2d( ia_org, is_org, ie_org, ja_org, js_org, je_org, &
1820 it, nfiles_lnd, fid_lnd, fids_lnd, scale_tile_lnd, scale_domid_lnd, &
1822 if ( .not. exist )
then
1830 call read2d( ia_org, is_org, ie_org, ja_org, js_org, je_org, &
1832 it, nfiles_lnd, fid_lnd, fids_lnd, scale_tile_lnd, scale_domid_lnd, &
1834 if ( .not. exist )
then
1835 call read2d( ia_org, is_org, ie_org, ja_org, js_org, je_org, &
1837 it, nfiles_lnd, fid_lnd, fids_lnd, scale_tile_lnd, scale_domid_lnd, &
1839 if ( .not. exist )
then
1840 log_error(
"ParentLandInputNetCDF",*)
'"LAND_SFC_ALB_IR_dif" or "LAND_SFC_EMIS_IR_dif" is necessary'
1850 call read2d( ia_org, is_org, ie_org, ja_org, js_org, je_org, &
1852 it, nfiles_lnd, fid_lnd, fids_lnd, scale_tile_lnd, scale_domid_lnd, &
1854 if ( .not. exist )
then
1891 integer,
intent(out) :: odims(2)
1892 integer,
intent(out) :: timelen
1893 real(rp),
allocatable,
intent(out) :: lon_all(:,:)
1894 real(rp),
allocatable,
intent(out) :: lat_all(:,:)
1896 character(len=*),
intent(in) :: basename_org
1897 character(len=*),
intent(in) :: basename_num
1899 logical,
intent(inout) :: serial
1900 logical,
intent(inout) :: do_read
1902 character(len=8) :: file_type =
"AUTO"
1903 character(len=FILE_HLONG) :: nm_file
1904 logical :: scale_multi_file = .true.
1905 integer :: scale_parent_prc_num_x
1906 integer :: scale_parent_prc_num_y
1907 character(len=FILE_HLONG) :: scale_latlon_catalogue
1909 namelist / param_mkinit_real_ocean_netcdf / &
1913 scale_parent_prc_num_x, &
1914 scale_parent_prc_num_y, &
1915 scale_latlon_catalogue
1917 character(len=FILE_HLONG) :: basename
1918 character(len=FILE_HLONG) :: fname
1921 character(len=32) :: items(vars_max)
1923 type(vinfo),
pointer :: var_info
1924 class(*),
pointer :: v
1931 log_info(
"ParentOceanSetupNetCDF",*)
'Real Case/Ocean Setup'
1935 scale_parent_prc_num_x = -1
1936 scale_parent_prc_num_y = -1
1937 scale_latlon_catalogue =
""
1941 read(
io_fid_conf,nml=param_mkinit_real_ocean_netcdf,iostat=ierr)
1943 log_error(
"ParentOceanSetupNetCDF",*)
'Not appropriate names in namelist PARAM_MKINIT_REAL_OCEAN_NetCDF. Check!'
1946 log_nml(param_mkinit_real_ocean_netcdf)
1949 basename = trim(basename_org) // trim(basename_num)
1953 call check_filetype(fid_ocn, file_type, basename, scale_tile_ocn,
"ParentOceanSetupNetCDF")
1956 call comm_bcast( file_type )
1958 if ( file_type ==
"SCALE-RM" )
then
1959 call comm_bcast( scale_tile_ocn )
1960 if ( scale_tile_ocn )
then
1970 select case( file_type )
1976 call vars_ocean%put(
"lon", vinfo(
"lon"))
1977 call vars_ocean%put(
"lat", vinfo(
"lat"))
1979 call vars_ocean%put(
"lsmask", vinfo(
"lsmask"))
1981 call vars_ocean%put(
"OCEAN_TEMP", vinfo(
"OCEAN_TEMP"))
1983 call vars_ocean%put(
"OCEAN_SFC_TEMP", vinfo(
"OCEAN_SFC_TEMP"))
1984 call vars_ocean%put(
"OCEAN_SFC_Z0M", vinfo(
"OCEAN_SFC_Z0M"))
1986 call vars_ocean%put(
"OCEAN_SFC_ALB_IR_dir", vinfo(
"OCEAN_SFC_ALB_IR_dir"))
1987 call vars_ocean%put(
"OCEAN_SFC_ALB_IR_dif", vinfo(
"OCEAN_SFC_ALB_IR_dif"))
1988 call vars_ocean%put(
"OCEAN_SFC_ALB_NIR_dir", vinfo(
"OCEAN_SFC_ALB_NIR_dir"))
1989 call vars_ocean%put(
"OCEAN_SFC_ALB_NIR_dif", vinfo(
"OCEAN_SFC_ALB_NIR_dif"))
1990 call vars_ocean%put(
"OCEAN_SFC_ALB_VIS_dir", vinfo(
"OCEAN_SFC_ALB_VIS_dir"))
1991 call vars_ocean%put(
"OCEAN_SFC_ALB_VIS_dif", vinfo(
"OCEAN_SFC_ALB_VIS_dif"))
1995 yname =
"south_north"
1998 call vars_ocean%put(
"lon", vinfo(
"XLONG"))
1999 call vars_ocean%put(
"lat", vinfo(
"XLAT"))
2000 call vars_ocean%put(
"lz", vinfo(
"ZS"))
2002 call vars_ocean%put(
"topo", vinfo(
"HGT"))
2003 call vars_ocean%put(
"lsmask", vinfo(
"LANDMASK"))
2005 call vars_ocean%put(
"OCEAN_TEMP", vinfo(
"OCEAN_TEMP"))
2007 call vars_ocean%put(
"OCEAN_SFC_TEMP", vinfo(
"SST"))
2008 call vars_ocean%put(
"OCEAN_SFC_Z0M", vinfo(
"ZNT"))
2010 call vars_ocean%put(
"OCEAN_SFC_ALB_VIS_dir", vinfo(
"ALBEDO"))
2011 call vars_ocean%put(
"OCEAN_SFC_EMIS_IR_dif", vinfo(
"EMISS"))
2015 log_error(
"ParentOCEANSetupNetCDF",*)
'FILE_TYPE must be "SCALE-RM", "WRFARW", "NAMELIST", or "AUTO", ', trim(file_type)
2022 if ( nm_file /=
"" )
then
2025 open(nmfid, file=fname, form=
"formatted", status=
"old", action=
"read", iostat=ierr)
2026 if ( ierr /= 0 )
then
2027 log_error(
"ParentOceanSetupNetCDF",*)
'namelist file is not found! ', trim(fname)
2032 read(nmfid, nml=netcdf_dims, iostat=ierr)
2034 log_error(
"ParentOceanSetupNetCDF",*)
'Not appropriate names in namelist NetCDF_DIMS in ', trim(fname),
'. Check!'
2042 read(nmfid, nml=netcdf_item, iostat=ierr)
2044 log_error(
"ParentLandSetupNetCDF",*)
'Not appropriate names in namelist NetCDF_ITEM in ', trim(fname),
'. Check!'
2046 else if( ierr < 0 )
then
2052 if ( nvars > vars_max )
then
2053 log_error(
"ParentLandSetupNetCDF",*)
"The number of item in the namelist file exceeds the limit! ", nvars
2059 if ( vars_ocean%has_key(items(n)) )
then
2061 v => vars_ocean%get(item)
2066 name = var_info%name
2067 fact = var_info%fact
2068 offset = var_info%offset
2078 read(nmfid, nml=netcdf_item, iostat=ierr)
2079 if ( ierr /= 0 )
exit
2081 call vars_ocean%put(item, vinfo(name=name, zstg=zstg, xstg=xstg, ystg=ystg, fact=fact, offset=offset))
2084 else if ( file_type ==
"NAMELIST" )
then
2085 log_error(
"ParentLANDSetupNetCDF",*)
'NM_FILE is necessary'
2091 if ( scale_tile_ocn )
then
2096 scale_parent_prc_num_x, &
2097 scale_parent_prc_num_y, &
2098 scale_latlon_catalogue )
2104 num_tile=nfiles_ocn )
2106 allocate( fids_ocn(nfiles_ocn) )
2107 allocate( tile_id_ocn(nfiles_ocn) )
2111 tile_id = tile_id_ocn )
2115 else if ( do_read )
then
2125 if ( error ) timelen = 1
2127 allocate( lon_all(odims(1),odims(2)) )
2128 allocate( lat_all(odims(1),odims(2)) )
2130 call read2d( odims(1), 1, odims(1), odims(2), 1, odims(2), &
2131 lon_all(:,:), vars_ocean%get(
"lon"), &
2132 1, nfiles_ocn, fid_ocn, fids_ocn, scale_tile_ocn, scale_domid_ocn )
2133 lon_all(:,:) = lon_all(:,:) * d2r
2134 call read2d( odims(1), 1, odims(1), odims(2), 1, odims(2), &
2135 lat_all(:,:), vars_ocean%get(
"lat"), &
2136 1, nfiles_ocn, fid_ocn, fids_ocn, scale_tile_ocn, scale_domid_ocn )
2137 lat_all(:,:) = lat_all(:,:) * d2r
2149 basename_org, basename_num )
2153 character(len=*),
intent(in) :: basename_org
2154 character(len=*),
intent(in) :: basename_num
2156 character(len=FILE_HLONG) :: basename
2162 log_info(
"ParentOceanOpenNetCDF",*)
'Real Case/Ocean Open'
2164 basename = trim(basename_org) // trim(basename_num)
2166 if ( scale_tile_ocn )
then
2168 do n = 1, nfiles_ocn
2172 aggregate=.false., &
2174 rankid=tile_id_ocn(n) )
2177 fid_ocn = fids_ocn(1)
2181 call file_open(basename, fid_ocn, postfix=
"")
2194 log_info(
"ParentOceanFinalizeNetCDF",*)
'Real Case/Ocean Finalize'
2196 if (
allocated(fids_ocn) )
deallocate( fids_ocn )
2197 if (
allocated(tile_id_ocn) )
deallocate( tile_id_ocn )
2199 call vars_ocean%destroy()
2201 scale_domid_ocn = -1
2210 IA_org, IS_org, IE_org, &
2211 JA_org, JS_org, JE_org, &
2223 integer,
intent(in) :: ia_org, is_org, ie_org
2224 integer,
intent(in) :: ja_org, js_org, je_org
2226 real(rp),
intent(out) :: tw_org(ia_org,ja_org)
2227 real(rp),
intent(out) :: sst_org(ia_org,ja_org)
2229 real(rp),
intent(out) :: z0w_org(ia_org,ja_org)
2230 real(rp),
intent(inout) :: omask_org(ia_org,ja_org)
2232 integer,
intent(in) :: odims(2)
2233 integer,
intent(in) :: it
2239 if ( first_ocn )
then
2240 call read2d( ia_org, is_org, ie_org, ja_org, js_org, je_org, &
2241 omask_org(:,:), vars_ocean%get(
"lsmask"), &
2242 it, nfiles_ocn, fid_ocn, fids_ocn, scale_tile_ocn, scale_domid_ocn )
2245 call read2d( ia_org, is_org, ie_org, ja_org, js_org, je_org, &
2246 tw_org(:,:), vars_ocean%get(
"OCEAN_SFC_TEMP"), &
2247 it, nfiles_ocn, fid_ocn, fids_ocn, scale_tile_ocn, scale_domid_ocn )
2248 sst_org(:,:) = tw_org(:,:)
2250 call read2d( ia_org, is_org, ie_org, ja_org, js_org, je_org, &
2251 z0w_org(:,:), vars_ocean%get(
"OCEAN_SFC_Z0M"), &
2252 it, nfiles_ocn, fid_ocn, fids_ocn, scale_tile_ocn, scale_domid_ocn, &
2254 if ( .not. exist )
then
2258 z0w_org(:,:) = undef
2263 call read2d( ia_org, is_org, ie_org, ja_org, js_org, je_org, &
2265 it, nfiles_ocn, fid_ocn, fids_ocn, scale_tile_ocn, scale_domid_ocn )
2266 call read2d( ia_org, is_org, ie_org, ja_org, js_org, je_org, &
2268 it, nfiles_ocn, fid_ocn, fids_ocn, scale_tile_ocn, scale_domid_ocn, &
2270 if ( .not. exist )
then
2278 call read2d( ia_org, is_org, ie_org, ja_org, js_org, je_org, &
2280 it, nfiles_ocn, fid_ocn, fids_ocn, scale_tile_ocn, scale_domid_ocn, &
2282 if ( .not. exist )
then
2290 call read2d( ia_org, is_org, ie_org, ja_org, js_org, je_org, &
2292 it, nfiles_ocn, fid_ocn, fids_ocn, scale_tile_ocn, scale_domid_ocn, &
2294 if ( .not. exist )
then
2302 call read2d( ia_org, is_org, ie_org, ja_org, js_org, je_org, &
2304 it, nfiles_ocn, fid_ocn, fids_ocn, scale_tile_ocn, scale_domid_ocn, &
2306 if ( .not. exist )
then
2307 call read2d( ia_org, is_org, ie_org, ja_org, js_org, je_org, &
2309 it, nfiles_ocn, fid_ocn, fids_ocn, scale_tile_ocn, scale_domid_ocn, &
2311 if ( .not. exist )
then
2312 log_error(
"ParentOceanInputNetCDF",*)
'"OCEAN_SFC_ALB_IR_dif" or "OCEAN_SFC_EMIS_IR_dif" is necessary'
2322 call read2d( ia_org, is_org, ie_org, ja_org, js_org, je_org, &
2324 it, nfiles_ocn, fid_ocn, fids_ocn, scale_tile_ocn, scale_domid_ocn, &
2326 if ( .not. exist )
then
2342 subroutine check_filetype(fid, FILE_TYPE, basename_org, SCALE_tile, subname)
2346 integer,
intent(out) :: fid
2347 character(len=*),
intent(inout) :: FILE_TYPE
2348 logical,
intent(out) :: SCALE_tile
2349 character(len=*),
intent(in) :: basename_org
2350 character(len=*),
intent(in) :: subname
2352 character(len=FILE_HLONG) :: fname
2353 character(len=32) :: att
2357 fname = basename_org
2358 inquire(file=fname, exist=exist)
2359 if ( .not. exist )
then
2360 fname = trim(basename_org)//
".nc"
2361 inquire(file=fname, exist=exist)
2363 if ( .not. exist )
then
2364 fname = trim(basename_org)//
".pe000000.nc"
2365 inquire(file=fname, exist=exist)
2367 if ( .not. exist )
then
2368 log_error(subname,*)
"file is not found: ", trim(basename_org)
2371 call file_open(fname, fid, postfix=
"", allnodes=.false.)
2372 if ( file_type ==
"AUTO" )
then
2373 call file_get_attribute( &
2374 fid,
"global",
"source", &
2377 if ( exist .and. att(:8)==
"SCALE-RM" )
then
2378 file_type =
"SCALE-RM"
2379 log_info(subname,*)
'FILE-TYPE SCALE-RM was detected'
2381 call file_get_attribute( &
2382 fid,
"global",
"TITLE", &
2385 if ( exist .and. index(att,
"WRF") > 0 )
then
2386 file_type =
"WRFARW"
2387 log_info(subname,*)
'FILE-TYPE WRF was detected'
2389 file_type =
"NAMELIST"
2394 scale_tile = .false.
2395 if ( file_type ==
"SCALE-RM" )
then
2396 call file_get_attribute( &
2397 fid,
"global",
"scale_cartesC_prc_num_x", &
2400 if ( exist .and. i > 1 )
then
2402 log_info(subname,*)
'Multi files was detected'
2404 call file_get_attribute( &
2405 fid,
"global",
"scale_cartesC_prc_num_y", &
2408 if ( exist .and. i > 1 )
then
2410 log_info(subname,*)
'Multi files was detected'
2419 KA_org, KS_org, KE_org, &
2420 IA_org, IS_org, IE_org, &
2421 JA_org, JS_org, JE_org, &
2425 nfiles, fid, fids, &
2426 scale_tile, scale_domid, &
2429 file_get_datainfo, &
2434 integer,
intent(in) :: KA_org, KS_org, KE_org
2435 integer,
intent(in) :: IA_org, IS_org, IE_org
2436 integer,
intent(in) :: JA_org, JS_org, JE_org
2438 real(RP),
intent(out),
target :: val(KA_org,IA_org,JA_org)
2440 class(*),
pointer,
intent(in) :: var
2441 integer,
intent(in) :: it
2442 integer,
intent(in) :: nfiles
2443 integer,
intent(in) :: fid, fids(nfiles)
2444 logical,
intent(in) :: scale_tile
2445 integer,
intent(in) :: scale_domid
2447 logical,
intent(out),
optional :: exist
2449 real(RP),
allocatable :: buf3d(:,:,:)
2450 real(RP),
pointer :: work(:,:,:)
2451 real(RP),
allocatable,
target :: work_t(:,:,:)
2454 integer :: tilei, tilej
2456 integer :: cxs, cxe, cys, cye
2457 integer :: pxs, pxe, pys, pye
2459 logical :: transpose
2461 integer :: i0, i1, j0, j1
2462 integer :: kst, ist, jst
2464 integer :: k, i, j, n
2466 if ( .not.
associated(var) )
then
2467 if (
present(exist) )
then
2470 log_error(
"read3d",*)
'data is not found '
2478 if ( var%name ==
"" )
then
2479 if (
present(exist) )
then
2482 log_error(
"read3d",*)
'data is not found '
2488 call file_get_datainfo( fid, var%name, has_tdim=has_tdim, existed=exist_ )
2489 if ( .not. exist_ )
then
2490 if (
present(exist) )
then
2494 log_error(
"read3d",*)
'data is not found: ', trim(var%name)
2499 if ( has_tdim )
then
2505 kmax = ke_org - ks_org + 1
2507 if ( var%zstg )
then
2512 if ( var%xstg )
then
2517 if ( var%ystg )
then
2523 call file_get_shape( fid, var%name, dims(:) )
2524 transpose = dims(1) .ne. kmax+kst
2526 if ( scale_tile )
then
2527 if ( var%xstg .or. var%ystg )
then
2528 allocate( work_t(ka_org,ia_org+ist,ja_org+jst) )
2536 cxs, cxe, cys, cye, &
2537 pxs, pxe, pys, pye, &
2541 i0 = max(is_org - cxs, 0)
2542 i1 = max(cxe - ie_org - ist, 0)
2543 j0 = max(js_org - cys, 0)
2544 j1 = max(cye - je_org - jst, 0)
2545 if ( transpose )
then
2546 allocate( buf3d(pxs+i0:pxe-i1,pys+j0:pye-j1,ks_org:ke_org+kst) )
2547 call file_read( fids(n), var%name, buf3d(:,:,:), &
2548 step=it_, start=(/pxs+i0,pys+j0,1/), count=(/pxe-pxs+1-i1-i0,pye-pys+1-j1-j0,kmax+kst/) )
2549 if ( var%zstg )
then
2551 do j = j0, pye-pys-j1
2552 do i = i0, pxe-pxs-i1
2553 do k = ks_org, ke_org
2554 work(k,cxs+i-is_org+1,cys+j-js_org+1) = ( buf3d(pxs+i,pys+j,k) + buf3d(pxs+i,pys+j,k+1) ) * 0.5_rp * var%fact + var%offset
2560 do j = j0, pye-pys-j1
2561 do i = i0, pxe-pxs-i1
2562 do k = ks_org, ke_org
2563 work(k,cxs+i-is_org+1,cys+j-js_org+1) = buf3d(pxs+i,pys+j,k) * var%fact + var%offset
2569 if ( var%xstg .and. cxs==2 .and. is_org==1 )
then
2571 do j = j0, pye-pys-j1
2572 do k = ks_org, ke_org
2573 work(k,1,cys+j-js_org+1) = work(k,2,cys+j-js_org+1)
2577 if ( var%ystg .and. cys==2 .and. js_org==1 )
then
2579 do i = i0, pxe-pxs-i1
2580 do k = ks_org, ke_org
2581 work(k,cxs+i-is_org+1,1) = work(k,cxs+i-is_org+1,2)
2586 allocate( buf3d(ks_org:ke_org+kst,pxs+i0:pxe-i1,pys+j0:pye-j1) )
2587 call file_read( fids(n), var%name, buf3d(:,:,:), &
2588 step=it_, start=(/1,pxs+i0,pys+j0/), count=(/kmax+kst,pxe-pxs+1-i1-i0,pye-pys+1-j1-j0/) )
2589 if ( var%zstg )
then
2591 do j = j0, pye-pys-j1
2592 do i = i0, pxe-pxs-i1
2593 do k = ks_org, ke_org
2594 work(k,cxs+i-is_org+1,cys+j-js_org+1) = ( buf3d(k,pxs+i,pys+j) + buf3d(k+1,pxs+i,pys+j) ) * 0.5_rp * var%fact + var%offset
2600 do j = j0, pye-pys-j1
2601 do i = i0, pxe-pxs-i1
2602 do k = ks_org, ke_org
2603 work(k,cxs+i-is_org+1,cys+j-js_org+1) = buf3d(k,pxs+i,pys+j) * var%fact + var%offset
2611 if ( var%xstg )
then
2615 do k = ks_org, ke_org
2616 val(k,i,j) = ( work(k,i,j) + work(k,i+1,j) ) * 0.5_rp
2620 else if ( var%ystg )
then
2624 do k = ks_org, ke_org
2625 val(k,i,j) = ( work(k,i,j) + work(k,i,j+1) ) * 0.5_rp
2630 if ( var%xstg .or. var%ystg )
then
2631 deallocate( work_t )
2635 if ( transpose )
then
2636 allocate( buf3d(is_org:ie_org+ist,js_org:je_org+jst,ks_org:ke_org+kst) )
2641 start=(/is_org,js_org,1/), &
2642 count=(/ia_org+ist,ja_org+jst,kmax+kst/))
2643 if ( var%zstg )
then
2647 do k = ks_org, ke_org
2648 val(k,i,j) = ( buf3d(i+is_org-1,j+js_org-1,k) + buf3d(i+is_org-1,j+js_org-1,k+1) ) * 0.5_rp * var%fact + var%offset
2652 else if ( var%xstg )
then
2656 do k = ks_org, ke_org
2657 val(k,i,j) = ( buf3d(i+is_org-1,j+js_org-1,k) + buf3d(i+is_org,j+js_org-1,k) ) * 0.5_rp * var%fact + var%offset
2661 else if ( var%ystg )
then
2665 do k = ks_org, ke_org
2666 val(k,i,j) = ( buf3d(i+is_org-1,j+js_org-1,k) + buf3d(i+is_org-1,j+js_org,k) ) * 0.5_rp * var%fact + var%offset
2674 do k = ks_org, ke_org
2675 val(k,i,j) = buf3d(i+is_org-1,j+js_org-1,k) * var%fact + var%offset
2682 allocate( buf3d(ks_org:ke_org+kst,is_org:ie_org+ist,js_org:je_org+jst) )
2687 start=(/1,is_org,js_org/), &
2688 count=(/kmax+kst,ia_org+ist,ja_org+jst/) )
2689 if ( var%zstg )
then
2693 do k = ks_org, ke_org
2694 val(k,i,j) = ( buf3d(k,i+is_org-1,j+js_org-1) + buf3d(k+1,i+is_org-1,j+js_org-1) ) * 0.5_rp * var%fact + var%offset
2698 else if ( var%xstg )
then
2702 do k = ks_org, ke_org
2703 val(k,i,j) = ( buf3d(k,i+is_org-1,j+js_org-1) + buf3d(k,i+is_org,j+js_org-1) ) * 0.5_rp * var%fact + var%offset
2707 else if ( var%ystg )
then
2711 do k = ks_org, ke_org
2712 val(k,i,j) = ( buf3d(k,i+is_org-1,j+js_org-1) + buf3d(k,i+is_org-1,j+js_org) ) * 0.5_rp * var%fact + var%offset
2720 do k = ks_org, ke_org
2721 val(k,i,j) = buf3d(k,i+is_org-1,j+js_org-1) * var%fact + var%offset
2730 if (
present(exist) ) exist = .true.
2737 IA_org, IS_org, IE_org, &
2738 JA_org, JS_org, JE_org, &
2742 nfiles, fid, fids, &
2743 scale_tile, scale_domid, &
2746 file_get_datainfo, &
2751 integer,
intent(in) :: IA_org, IS_org, IE_org
2752 integer,
intent(in) :: JA_org, JS_org, JE_org
2754 real(RP),
intent(out),
target :: val(IA_org,JA_org)
2756 class(*),
pointer,
intent(in) :: var
2757 integer,
intent(in) :: it
2758 integer,
intent(in) :: nfiles
2759 integer,
intent(in) :: fid, fids(nfiles)
2760 logical,
intent(in) :: scale_tile
2761 integer,
intent(in) :: scale_domid
2763 logical,
intent(out),
optional :: exist
2765 real(RP),
allocatable :: buf2d(:,:)
2766 real(RP),
pointer :: work(:,:)
2767 real(RP),
allocatable,
target :: work_t(:,:)
2769 integer :: tilei, tilej
2770 integer :: cxs, cxe, cys, cye
2771 integer :: pxs, pxe, pys, pye
2775 integer :: i0, i1, j0, j1
2783 if ( .not.
associated(var) )
then
2784 if (
present(exist) )
then
2787 log_error(
"read3d",*)
'data is not found '
2795 if ( var%name ==
"" )
then
2796 if (
present(exist) )
then
2799 log_error(
"read2d",*)
'data is not found '
2805 call file_get_datainfo( fid, var%name, has_tdim=has_tdim, existed=exist_ )
2806 if ( .not. exist_ )
then
2807 if (
present(exist) )
then
2811 log_error(
"read2d",*)
'data is not found: ', trim(var%name)
2816 if ( has_tdim )
then
2822 if ( var%xstg )
then
2827 if ( var%ystg )
then
2833 if ( scale_domid > 0 )
then
2834 if ( var%xstg .or. var%ystg )
then
2835 allocate( work_t(ia_org+ist,ja_org+jst) )
2843 cxs, cxe, cys, cye, &
2844 pxs, pxe, pys, pye, &
2848 i0 = max(is_org - cxs, 0)
2849 i1 = max(cxe - ie_org - ist, 0)
2850 j0 = max(js_org - cys, 0)
2851 j1 = max(cye - je_org - jst, 0)
2852 allocate( buf2d(pxs+i0:pxe-i1,pys+j0:pye-j1) )
2853 call file_read( fids(n), var%name, buf2d(:,:), &
2854 step=it_, start=(/pxs+i0,pys+j0/), count=(/pxe-pxs+1-i1-i0,pye-pys+1-j1-j0/) )
2856 do j = j0, pye-pys-j1
2857 do i = i0, pxe-pxs-i1
2858 work(cxs+i-is_org+1,cys+j-js_org+1) = buf2d(pxs+i,pys+j) * var%fact + var%offset
2862 if ( var%xstg .and. cxs==2 .and. is_org==1 )
then
2864 do j = j0, pye-pys-j1
2865 work(1,cys+j-js_org+1) = work(2,cys+j-js_org+1)
2868 if ( var%ystg .and. cys==2 .and. js_org==1 )
then
2870 do i = i0, pxe-pxs-i1
2871 work(cxs+i-is_org+1,1) = work(cxs+i-is_org+1,2)
2875 if ( var%xstg )
then
2879 val(i,j) = ( work(i,j) + work(i+1,j) ) * 0.5_rp
2882 else if ( var%ystg )
then
2886 val(i,j) = ( work(i,j) + work(i,j+1) ) * 0.5_rp
2890 if ( var%xstg .or. var%ystg )
then
2891 deallocate( work_t )
2895 if ( var%xstg .or. var%ystg )
then
2896 allocate( work_t(is_org:ie_org+ist,js_org:je_org+jst) )
2905 start=(/is_org,js_org/), &
2906 count=(/ia_org+ist,ja_org+jst/) )
2907 if ( var%xstg )
then
2911 val(i,j) = ( work(i,j) + work(i+1,j) ) * 0.5_rp * var%fact + var%offset
2914 else if ( var%ystg )
then
2918 val(i,j) = ( work(i,j) + work(i,j+1) ) * 0.5_rp * var%fact + var%offset
2921 else if ( var%fact .ne. 1.0_rp .or. var%offset .ne. 0.0_rp )
then
2925 val(i,j) = val(i,j) * var%fact + var%offset
2929 if ( var%xstg .or. var%ystg )
then
2930 deallocate( work_t )
2935 if (
present(exist) ) exist = .true.
2949 file_get_datainfo, &
2951 integer,
intent(in) :: KA_org
2953 real(RP),
intent(out) :: val(KA_org)
2955 class(*),
pointer,
intent(in) :: var
2956 integer,
intent(in) :: it
2957 integer,
intent(in) :: fid
2959 logical,
intent(out),
optional :: exist
2966 if ( .not.
associated(var) )
then
2967 if (
present(exist) )
then
2970 log_error(
"read3d",*)
'data is not found '
2978 if ( var%name ==
"" )
then
2979 if (
present(exist) )
then
2982 log_error(
"read1d",*)
'data is not found '
2988 call file_get_datainfo( fid, var%name, has_tdim=has_tdim, existed=exist_ )
2989 if ( .not. exist_ )
then
2990 if (
present(exist) )
then
2994 log_error(
"read1d",*)
'data is not found: ', trim(var%name)
2999 if ( has_tdim )
then
3005 call file_read( fid, var%name, val(:), step=it_ )
3006 if ( var%fact .ne. 1.0_rp .or. var%offset .ne. 0.0_rp )
then
3007 val(:) = val(:) * var%fact + var%offset
3010 if (
present(exist) ) exist = .true.