58 private :: parentatmossetup
59 private :: parentatmosfinalize
60 private :: parentatmosopen
61 private :: parentatmosinput
62 private :: boundaryatmossetup
63 private :: boundaryatmosoutput
65 private :: parentsurfacesetup
66 private :: parentsurfacefinalize
67 private :: parentsurfaceopen
68 private :: parentsurfaceinput
69 private :: boundarysurfacesetup
70 private :: boundarysurfaceoutput
71 private :: interp_oceanland_data
78 integer,
public,
parameter ::
igrads = 2
80 integer,
private :: ka_org, ks_org, ke_org
81 integer,
private :: ia_org, is_org, ie_org
82 integer,
private :: ja_org, js_org, je_org
83 integer,
private :: lka_org, lks_org, lke_org
84 integer,
private :: lia_org, lis_org, lie_org
85 integer,
private :: lja_org, ljs_org, lje_org
86 integer,
private :: oia_org, ois_org, oie_org
87 integer,
private :: oja_org, ojs_org, oje_org
89 real(
rp),
private,
allocatable :: lon_org (:,:)
90 real(
rp),
private,
allocatable :: lat_org (:,:)
91 real(
rp),
private,
allocatable :: cz_org (:,:,:)
93 real(
rp),
private,
allocatable :: w_org (:,:,:)
94 real(
rp),
private,
allocatable :: u_org (:,:,:)
95 real(
rp),
private,
allocatable :: v_org (:,:,:)
96 real(
rp),
private,
allocatable :: dens_org(:,:,:)
97 real(
rp),
private,
allocatable :: pt_org (:,:,:)
98 real(
rp),
private,
allocatable :: temp_org(:,:,:)
99 real(
rp),
private,
allocatable :: pres_org(:,:,:)
100 real(
rp),
private,
allocatable :: qtrc_org (:,:,:,:)
101 real(
rp),
private,
allocatable :: qv_org (:,:,:)
102 real(
rp),
private,
allocatable :: rh_org (:,:,:)
103 real(
rp),
private,
allocatable :: qhyd_org (:,:,:,:)
104 real(
rp),
private,
allocatable :: qnum_org (:,:,:,:)
106 real(
rp),
private,
allocatable :: llon_org (:,:)
107 real(
rp),
private,
allocatable :: llat_org (:,:)
109 real(
rp),
private,
allocatable :: olon_org (:,:)
110 real(
rp),
private,
allocatable :: olat_org (:,:)
112 real(
rp),
private,
allocatable :: rotc_org(:,:,:)
114 integer,
private :: itp_nh_a = 4
115 integer,
private :: itp_nh_l = 4
116 integer,
private :: itp_nh_o = 4
117 integer,
private :: itp_nh_ol = 5
119 integer,
private,
parameter :: i_intrp_linear = 0
120 integer,
private,
parameter :: i_intrp_dstwgt = 1
121 integer,
private :: itp_type_a
122 integer,
private :: itp_type_l
123 integer,
private :: itp_type_o
125 integer,
private,
allocatable :: igrd ( :,:,:)
126 integer,
private,
allocatable :: jgrd ( :,:,:)
127 real(
rp),
private,
allocatable :: hfact( :,:,:)
128 integer,
private,
allocatable :: kgrd (:,:,:,:,:)
129 real(
rp),
private,
allocatable :: vfact(:, :,:,:)
131 integer,
private,
allocatable :: oigrd (:,:,:)
132 integer,
private,
allocatable :: ojgrd (:,:,:)
133 real(
rp),
private,
allocatable :: ohfact(:,:,:)
135 logical,
private :: ol_interp
136 real(
rp),
private,
allocatable :: hfact_ol(:,:,:)
137 integer,
private,
allocatable :: igrd_ol (:,:,:)
138 integer,
private,
allocatable :: jgrd_ol (:,:,:)
140 logical,
private :: serial_atmos
141 logical,
private :: serial_land
142 logical,
private :: serial_ocean
143 logical,
private :: do_read_atmos
144 logical,
private :: do_read_land
145 logical,
private :: do_read_ocean
147 logical,
private :: mixing_ratio
148 logical,
private :: temp2pt
149 logical,
private :: update_coord
150 logical,
private :: use_waterratio
152 integer,
private,
parameter :: i_intrp_off = 0
153 integer,
private,
parameter :: i_intrp_mask = 1
154 integer,
private,
parameter :: i_intrp_fill = 2
156 integer,
private :: i_intrp_land_temp
157 integer,
private :: i_intrp_land_water
158 integer,
private :: i_intrp_land_sfc_temp
159 integer,
private :: i_intrp_ocean_temp
160 integer,
private :: i_intrp_ocean_sfc_temp
163 real(
rp),
private,
parameter :: maskval_tg = 298.0_rp
164 real(
rp),
private,
parameter :: maskval_strg = 0.02_rp
169 integer,
private :: number_of_files = 1
170 integer,
private :: number_of_tsteps = -1
171 integer,
private :: number_of_skip_tsteps = 0
173 logical,
private :: serial_proc_read = .true.
175 character(len=H_LONG),
private :: filetype_org =
''
176 character(len=H_LONG),
private :: basename_org =
''
177 logical,
private :: basename_add_num = .false.
179 character(len=H_LONG),
private :: basename_boundary =
''
180 logical,
private :: boundary_postfix_timelabel = .false.
181 character(len=H_LONG),
private :: boundary_title =
'SCALE-RM BOUNDARY CONDITION for REAL CASE'
182 character(len=H_SHORT),
private :: boundary_dtype =
'DEFAULT'
183 real(
dp),
private :: boundary_update_dt = 0.0_dp
185 integer,
private :: filter_order = 8
186 integer,
private :: filter_niter = 0
188 logical,
private :: use_file_density = .false.
189 logical,
private :: pt_dry = .true.
190 logical,
private :: same_mp_type = .false.
191 character(len=4),
private :: upper_qv_type =
"ZERO"
195 character(len=H_SHORT),
private :: intrp_type =
"LINEAR"
199 logical,
private :: first_atmos = .true.
200 logical,
private :: first_surface = .true.
219 atmos_thermodyn_specific_heat
222 logical :: use_sfc_diagnoses = .false.
223 logical :: use_data_under_sfc = .true.
224 logical :: use_nonhydro_dens_boundary = .false.
225 logical :: skip_vertical_range_check = .false.
228 namelist / param_mkinit_real_atmos / &
231 number_of_skip_tsteps, &
237 boundary_postfix_timelabel, &
240 boundary_update_dt, &
245 use_nonhydro_dens_boundary, &
247 use_data_under_sfc, &
251 skip_vertical_range_check
253 character(len=6) :: basename_num
254 character(len=H_LONG) :: basename_out_mod
255 character(len=19) :: timelabel
261 integer :: vid_atmos(5+
qa)
262 logical :: qtrc_flag(
qa)
282 integer :: ifile, istep, t, tall
283 integer ::
k, i, j, iq
288 log_info(
'REALINPUT_atmos',*)
'Setup'
292 read(
io_fid_conf,nml=param_mkinit_real_atmos,iostat=ierr)
294 log_info(
"REALINPUT_atmos",*)
'Not found namelist. Default used.'
295 elseif( ierr > 0 )
then
296 log_error(
"REALINPUT_atmos",*)
'Not appropriate names in namelist PARAM_MKINIT_REAL_ATMOS. Check!'
299 log_nml(param_mkinit_real_atmos)
301 if ( boundary_update_dt <= 0.0_dp )
then
302 log_error(
"REALINPUT_atmos",*)
'BOUNDARY_UPDATE_DT is necessary in real case preprocess'
306 if ( number_of_files > 1 .OR. basename_add_num )
then
307 basename_num =
'_00000'
312 select case( intrp_type )
315 itp_type_a = i_intrp_linear
316 case (
"DIST-WEIGHT" )
318 itp_type_a = i_intrp_dstwgt
320 log_error(
"REALINPUT_atmos",*)
'Unsupported type of INTRP_TYPE : ', trim(intrp_type)
321 log_error_cont(*)
' It must be "LINEAR" or "DIST-WEIGHT"'
325 call parentatmossetup( filetype_org, &
335 if ( timelen < number_of_tsteps )
then
336 log_error(
"REALINPUT_atmos",*)
'time dimension in file is shorter than NUMBER_OF_TSTEPS', timelen, number_of_tsteps
339 if ( number_of_tsteps < 1 )
then
340 number_of_tsteps = timelen
344 log_info(
"REALINPUT_atmos",*)
'Number of temporal data in each file : ', number_of_tsteps
346 do ifile = 1, number_of_files
348 if ( number_of_files > 1 .OR. basename_add_num )
then
349 write(basename_num,
'(A,I5.5)')
'_', ifile-1
355 if ( basename_num ==
"" )
then
356 log_info(
"REALINPUT_atmos",*)
'read external data from : ', trim(basename_org)
358 log_info(
"REALINPUT_atmos",*)
'read external data from : ', trim(basename_org),
' (', trim(basename_num),
')'
361 call parentatmosopen( filetype_org, basename_org, basename_num )
363 do istep = 1, number_of_tsteps
365 tall = number_of_tsteps * (ifile-1) + istep
366 t = tall - number_of_skip_tsteps
369 log_progress(
'(1x,A,I4,A,I5,A,I6,A)') &
370 '[file,step,cons.] = [', ifile,
',', istep,
',', tall,
'] ...skip.'
374 if ( t == 1 .OR. basename_boundary /=
'' )
then
376 log_progress(
'(1x,A,I4,A,I5,A,I6,A)') &
377 '[file,step,cons.] = [', ifile,
',', istep,
',', tall,
']'
380 call parentatmosinput( filetype_org, &
385 use_data_under_sfc, &
387 skip_vertical_range_check, &
401 log_progress(
'(1x,A,I4,A,I5,A,I6,A)') &
402 '[file,step,cons.] = [', ifile,
',', istep,
',', tall,
'] ...skip.'
408 log_info(
"REALINPUT_atmos",*)
'store initial state.'
416 dens(
k,i,j) = dens_in(
k,i,j)
417 momz(
k,i,j) = momz_in(
k,i,j)
418 momx(
k,i,j) = momx_in(
k,i,j)
419 momy(
k,i,j) = momy_in(
k,i,j)
420 rhot(
k,i,j) = rhot_in(
k,i,j)
432 qtrc(
k,i,j,iq) = qtrc_in(
k,i,j,iq)
442 if ( basename_boundary /=
'' )
then
445 if ( boundary_postfix_timelabel )
then
447 basename_out_mod = trim(basename_boundary)//
'_'//trim(timelabel)
449 basename_out_mod = trim(basename_boundary)
452 call boundaryatmossetup( basename_out_mod, &
455 boundary_update_dt, &
461 if ( use_nonhydro_dens_boundary )
then
462 call atmos_thermodyn_specific_heat(
ka,
ks,
ke,
ia, 1,
ia,
ja, 1,
ja,
qa, &
465 qdry(:,:,:), rtot(:,:,:), cvtot(:,:,:), cptot(:,:,:) )
470 dens_in(
k,i,j) = ( pres_in(
k,i,j) / p00 )**( cvtot(
k,i,j) / cptot(
k,i,j) ) * p00 / ( rtot(
k,i,j) * pt_in(
k,i,j) )
476 call boundaryatmosoutput( dens_in(:,:,:), &
485 boundary_update_dt, &
492 call parentatmosfinalize( filetype_org )
566 logical :: use_file_landwater = .true.
567 real(
rp) :: init_landwater_ratio = 0.5_rp
569 real(
rp) :: init_ocean_alb_lw = 0.04_rp
570 real(
rp) :: init_ocean_alb_sw = 0.10_rp
571 real(
rp) :: init_ocean_z0w = 1.0e-3_rp
572 character(len=H_SHORT) :: intrp_land_temp =
'off'
573 character(len=H_SHORT) :: intrp_land_water =
'off'
574 character(len=H_SHORT) :: intrp_land_sfc_temp =
'off'
575 character(len=H_SHORT) :: intrp_ocean_temp =
'off'
576 character(len=H_SHORT) :: intrp_ocean_sfc_temp =
'off'
577 integer :: intrp_iter_max = 5
578 character(len=H_SHORT) :: soilwater_ds2vc =
'limit'
579 logical :: soilwater_ds2vc_flag
580 logical :: elevation_correction = .true.
581 logical :: elevation_correction_land
582 logical :: elevation_correction_ocean
584 namelist / param_mkinit_real_land / &
587 number_of_skip_tsteps, &
592 boundary_postfix_timelabel, &
594 boundary_update_dt, &
595 use_file_landwater, &
596 init_landwater_ratio, &
601 intrp_land_sfc_temp, &
606 elevation_correction, &
609 namelist / param_mkinit_real_ocean / &
612 number_of_skip_tsteps, &
617 boundary_postfix_timelabel, &
619 boundary_update_dt, &
625 intrp_ocean_sfc_temp, &
631 character(len=6) :: filetype_land
632 character(len=6) :: filetype_ocean
633 character(len=6) :: basename_land
634 character(len=6) :: basename_ocean
639 real(
rp) :: land_sfc_temp_in (
ia,
ja)
643 real(
rp) :: urban_tc_in(
ia,
ja)
644 real(
rp) :: urban_qc_in(
ia,
ja)
645 real(
rp) :: urban_uc_in(
ia,
ja)
646 real(
rp) :: urban_sfc_temp_in(
ia,
ja)
651 real(
rp) :: ocean_sfc_temp_in (
ia,
ja)
653 real(
rp) :: ocean_sfc_z0_in (
ia,
ja)
655 integer :: number_of_files_land = 1
656 integer :: number_of_files_ocean = 1
657 integer :: number_of_tsteps_land = 1
658 integer :: number_of_tsteps_ocean = 1
659 integer :: number_of_skip_tsteps_land = 0
660 integer :: number_of_skip_tsteps_ocean = 0
662 character(len=H_LONG) :: basename_org_land =
''
663 character(len=H_LONG) :: basename_org_ocean =
''
664 character(len=H_LONG) :: basename_boundary_land =
''
665 character(len=H_LONG) :: basename_boundary_ocean =
''
666 logical :: boundary_postfix_timelabel_land = .false.
667 logical :: boundary_postfix_timelabel_ocean = .false.
668 character(len=H_LONG) :: boundary_title_land =
'SCALE-RM BOUNDARY CONDITION for REAL CASE'
669 character(len=H_LONG) :: boundary_title_ocean =
'SCALE-RM BOUNDARY CONDITION for REAL CASE'
670 real(
dp) :: boundary_update_dt_land = 0.0_dp
671 real(
dp) :: boundary_update_dt_ocean = 0.0_dp
672 logical :: basename_add_num_land
673 logical :: basename_add_num_ocean
675 real(
rp),
allocatable :: lst_ocean(:,:)
676 real(
rp),
allocatable :: lz_org(:)
677 real(
rp),
allocatable :: topo_org(:,:)
678 real(
rp),
allocatable :: lmask_org(:,:)
679 real(
rp),
allocatable :: omask_org(:,:)
681 integer :: mdlid_land, mdlid_ocean
682 integer :: ldims(3), odims(2)
684 integer :: totaltimesteps = 1
685 integer :: timelen_land, timelen_ocean
688 character(len=H_LONG) :: basename_out_mod
689 character(len=19) :: timelabel
692 integer :: vid_sfc(10)
695 logical :: multi_land
696 logical :: multi_ocean
698 integer :: oistep, listep
700 integer :: idir, irgn
702 integer ::
k, i, j, n
711 if ( .not. land_flag .or. .not.
ocean_do )
then
712 log_error(
"REALINPUT_surface",*)
'OCEAN_ and LAND_DYN_TYPE must be set'
717 log_info(
'REALINPUT_surface',*)
'Setup LAND'
724 read(
io_fid_conf,nml=param_mkinit_real_land,iostat=ierr)
726 log_info(
"REALINPUT_surface",*)
'Not found namelist. Default used.'
727 elseif( ierr > 0 )
then
728 log_error(
"REALINPUT_surface",*)
'Not appropriate names in namelist PARAM_MKINIT_REAL_LAND. Check!'
731 log_nml(param_mkinit_real_land)
733 number_of_files_land = number_of_files
734 number_of_tsteps_land = number_of_tsteps
735 number_of_skip_tsteps_land = number_of_skip_tsteps
736 filetype_land = filetype_org
737 basename_org_land = basename_org
738 basename_add_num_land = basename_add_num
739 basename_boundary_land = basename_boundary
740 boundary_postfix_timelabel_land = boundary_postfix_timelabel
741 boundary_title_land = boundary_title
742 boundary_update_dt_land = boundary_update_dt
743 elevation_correction_land = elevation_correction
745 if ( number_of_files > 1 .OR. basename_add_num_land )
then
746 basename_land =
"_00000"
763 select case( soilwater_ds2vc )
765 soilwater_ds2vc_flag = .true.
767 soilwater_ds2vc_flag = .false.
769 log_error(
"REALINPUT_surface",*)
'Unsupported SOILWATER_DS2CV TYPE:', trim(soilwater_ds2vc)
777 select case( intrp_type )
780 itp_type_l = i_intrp_linear
781 case (
"DIST-WEIGHT" )
783 itp_type_l = i_intrp_dstwgt
785 log_error(
"REALINPUT_surface",*)
'Unsupported type of INTRP_TYPE : ', trim(intrp_type)
786 log_error_cont(*)
' It must be "LINEAR" or "DIST-WEIGHT"'
793 log_info(
'REALINPUT_surface',*)
'Setup OCEAN'
797 read(
io_fid_conf,nml=param_mkinit_real_ocean,iostat=ierr)
799 log_info(
"REALINPUT_surface",*)
'Not found namelist. Default used.'
800 elseif( ierr > 0 )
then
801 log_error(
"REALINPUT_surface",*)
'Not appropriate names in namelist PARAM_MKINIT_REAL_OCEAN. Check!'
804 log_nml(param_mkinit_real_ocean)
806 number_of_files_ocean = number_of_files
807 number_of_tsteps_ocean = number_of_tsteps
808 number_of_skip_tsteps_ocean = number_of_skip_tsteps
809 filetype_ocean = filetype_org
810 basename_org_ocean = basename_org
811 basename_add_num_ocean = basename_add_num
812 basename_boundary_ocean = basename_boundary
813 boundary_postfix_timelabel_ocean = boundary_postfix_timelabel
814 boundary_title_ocean = boundary_title
815 boundary_update_dt_ocean = boundary_update_dt
816 elevation_correction_ocean = elevation_correction
818 if ( number_of_files > 1 .OR. basename_add_num_ocean )
then
819 basename_ocean =
"_00000"
826 serial_ocean = .true.
828 select case( intrp_type )
831 itp_type_o = i_intrp_linear
832 case (
"DIST-WEIGHT" )
834 itp_type_o = i_intrp_dstwgt
836 log_error(
"REALINPUT_surface",*)
'Unsupported type of INTRP_TYPE : ', trim(intrp_type)
837 log_error_cont(*)
' It must be "LINEAR" or "DIST-WEIGHT"'
843 multi_land = ( number_of_files_land * number_of_tsteps_land - number_of_skip_tsteps_land ) > 1
844 multi_ocean = basename_boundary_ocean .ne.
''
846 if ( ( multi_land .and. multi_ocean ) .AND. &
847 ( ( number_of_files_land .NE. number_of_files_ocean ) .OR. &
848 ( number_of_tsteps_land .NE. number_of_tsteps_ocean ) .OR. &
849 ( number_of_skip_tsteps_land .NE. number_of_skip_tsteps_ocean ) .OR. &
850 ( basename_boundary_land .NE. basename_boundary_ocean ) .OR. &
851 ( boundary_postfix_timelabel_land .NEQV. boundary_postfix_timelabel_ocean ) .OR. &
852 ( boundary_title_land .NE. boundary_title_ocean ) .OR. &
853 ( boundary_update_dt_land .NE. boundary_update_dt_ocean ) ) )
then
854 log_error(
"REALINPUT_surface",*)
'The following LAND/OCEAN parameters must be consistent due to technical problem:'
855 log_error_cont(*)
' NUMBER_OF_FILES, NUMBER_OF_TSTEPS, NUMBER_OF_SKIP_TSTEPS,'
856 log_error_cont(*)
' BASENAME_BOUNDARY, BOUNDARY_POSTFIX_TIMELABEL, BOUNDARY_TITLE, BOUNDARY_UPDATE_DT.'
860 if ( multi_land .and. .not. multi_ocean )
then
861 log_error(
"REALINPUT_surface",*)
'To output boundary data for land data, it is necessary to output ocean data'
865 call parentsurfacesetup( ldims, odims, &
871 basename_org_ocean, &
876 use_file_landwater, &
880 intrp_land_sfc_temp, &
882 intrp_ocean_sfc_temp )
884 if ( timelen_land < number_of_tsteps_land )
then
885 log_error(
"REALINPUT_surface",*)
'time dimension in file is shorter than NUMBER_OF_TSTEPS_LAND', timelen_land, number_of_tsteps_land
889 if ( timelen_ocean < number_of_tsteps_ocean )
then
890 log_error(
"REALINPUT_surface",*)
'time dimension in file is shorter than NUMBER_OF_TSTEPS_OCEAN', timelen_ocean, number_of_tsteps_ocean
894 if ( number_of_tsteps_land < 1 )
then
895 number_of_tsteps_land = timelen_land
897 if ( number_of_tsteps_ocean < 1 )
then
898 number_of_tsteps_ocean = timelen_ocean
901 totaltimesteps = number_of_files_ocean * number_of_tsteps_ocean
903 if ( totaltimesteps <= number_of_skip_tsteps_ocean )
then
904 log_error(
"REALSINPUT_surface",*)
"NUMBER_OF_FILES_OCEAN * NUMBER_OF_TSTEPS_OCEAN <= NUMBER_OF_SKIP_TSTEPS_OCEAN"
907 if ( multi_ocean )
then
908 if ( boundary_update_dt_ocean <= 0.0_dp )
then
909 log_error(
"REALINPUT_surface",*)
'BOUNDARY_UPDATE_DT is necessary in real case preprocess'
914 allocate( lz_org(lka_org) )
915 allocate( topo_org(lia_org, lja_org) )
916 allocate( lmask_org(lia_org, lja_org) )
917 allocate( omask_org(oia_org, oja_org) )
918 allocate( lst_ocean(oia_org, oja_org) )
921 do n = 1, number_of_files_ocean
923 if ( number_of_files_land > 1 .OR. basename_add_num_land )
then
924 if ( multi_land )
then
925 write(basename_land,
'(A,I5.5)')
'_', n-1
927 write(basename_land,
'(A,I5.5)')
'_', number_of_skip_tsteps_land / number_of_tsteps_land
932 if ( number_of_files_ocean > 1 .OR. basename_add_num_ocean )
then
933 write(basename_ocean,
'(A,I5.5)')
'_', n-1
939 log_info(
"REALINPUT_surface",*)
'Target Postfix Name (Land) : ', trim(basename_land)
940 log_info(
"REALINPUT_surface",*)
'Target Postfix Name (Ocean): ', trim(basename_ocean)
941 log_info(
"REALINPUT_surface",*)
'Time Steps in One File : ', number_of_tsteps
943 call parentsurfaceopen( filetype_land, filetype_ocean, &
944 basename_org_land, basename_org_ocean, &
945 basename_land, basename_ocean )
947 do oistep = 1, number_of_tsteps_ocean
949 tall = number_of_tsteps_ocean * (n-1) + oistep
950 t = tall - number_of_skip_tsteps_ocean
952 log_progress(
'(1x,A,I4,A,I5,A,I6,A)') &
953 '[file,step,cons.] = [', n,
',', oistep,
',', tall,
'] ...skip.'
956 if ( t > 1 .and. .not. multi_ocean .and. .not. multi_land )
exit
958 if ( multi_land )
then
961 listep = mod(number_of_skip_tsteps_land, number_of_tsteps_land) + 1
966 call parentsurfaceinput( land_temp_in(:,:,:), &
967 land_water_in(:,:,:), &
968 land_sfc_temp_in(:,:), &
969 land_sfc_albedo_in(:,:,:,:), &
973 urban_sfc_temp_in(:,:), &
974 urban_sfc_albedo_in(:,:,:,:), &
976 lz_org(:), topo_org(:,:), &
977 lmask_org(:,:), omask_org(:,:), &
978 ocean_temp_in(
oks,:,:), &
979 ocean_sfc_temp_in( :,:), &
980 ocean_sfc_albedo_in( :,:,:,:), &
981 ocean_sfc_z0_in( :,:), &
982 basename_land, basename_ocean, &
983 mdlid_land, mdlid_ocean, &
985 use_file_landwater, &
986 init_landwater_ratio, &
988 init_ocean_alb_lw, init_ocean_alb_sw, &
991 soilwater_ds2vc_flag, &
992 elevation_correction_land, &
993 elevation_correction_ocean, &
1059 urban_tr(i,j) = urban_sfc_temp_in(i,j)
1060 urban_tb(i,j) = urban_sfc_temp_in(i,j)
1061 urban_tg(i,j) = urban_sfc_temp_in(i,j)
1102 if ( multi_ocean )
then
1105 if ( boundary_postfix_timelabel_ocean )
then
1107 basename_out_mod = trim(basename_boundary_ocean)//
'_'//trim(timelabel)
1109 basename_out_mod = trim(basename_boundary_ocean)
1112 call boundarysurfacesetup( basename_out_mod, &
1113 boundary_title_ocean, &
1114 boundary_update_dt_ocean, &
1115 multi_ocean, multi_land, &
1120 call boundarysurfaceoutput( land_temp_in(:,:,:), &
1121 land_water_in(:,:,:), &
1122 land_sfc_temp_in(:,:), &
1123 ocean_temp_in(:,:,:), &
1124 ocean_sfc_temp_in(:,:), &
1125 ocean_sfc_z0_in(:,:), &
1126 multi_ocean, multi_land, &
1129 boundary_update_dt_ocean, &
1136 if( t > 0 .and. .not. ( multi_land .or. multi_ocean ) )
exit
1140 deallocate( lst_ocean )
1141 deallocate( lz_org )
1142 deallocate( topo_org )
1143 deallocate( lmask_org )
1144 deallocate( omask_org )
1146 call parentsurfacefinalize( filetype_land, &
1155 subroutine parentatmossetup( &
1161 use_file_density_in, &
1173 mapprojection_rotcoef, &
1184 character(len=*),
intent(in) :: inputtype
1185 character(len=*),
intent(in) :: basename
1186 character(len=*),
intent(in) :: basename_num
1187 logical,
intent(in) :: serial_in
1188 logical,
intent(in) :: same_mptype
1189 logical,
intent(in) :: use_file_density_in
1191 integer,
intent(out) :: dims(6)
1192 integer,
intent(out) :: timelen
1193 logical,
intent(out) :: qtrc_flag(
qa)
1195 real(
rp),
allocatable :: lon_all(:,:)
1196 real(
rp),
allocatable :: lat_all(:,:)
1198 real(
rp) :: lon_min, lon_max
1199 real(
rp) :: lat_min, lat_max
1208 serial_atmos = serial_in
1210 do_read_atmos = .false.
1212 do_read_atmos = .true.
1215 select case(inputtype)
1235 if ( do_read_atmos )
then
1244 mapping_info%mapping_name =
""
1245 mixing_ratio = .false.
1246 update_coord = .true.
1250 log_error(
"ParentAtmosSetup",*)
'Unsupported type of input data : ', trim(inputtype)
1260 if ( serial_atmos )
then
1261 call comm_bcast( 6, dims(:) )
1262 call comm_bcast( timelen )
1264 call comm_bcast(
qa, qtrc_flag(:) )
1266 call comm_bcast( mixing_ratio )
1267 call comm_bcast( update_coord )
1269 call comm_bcast( mapping_info%mapping_name )
1270 call comm_bcast( mapping_info%longitude_of_central_meridian )
1271 call comm_bcast( mapping_info%longitude_of_projection_origin )
1272 call comm_bcast( mapping_info%latitude_of_projection_origin )
1273 call comm_bcast( 2, mapping_info%standard_parallel )
1274 call comm_bcast( mapping_info%rotation )
1276 if ( .not. do_read_atmos )
then
1277 allocate( lon_all(dims(2), dims(3)) )
1278 allocate( lat_all(dims(2), dims(3)) )
1280 call comm_bcast( dims(2), dims(3), lon_all )
1281 call comm_bcast( dims(2), dims(3), lat_all )
1289 call get_ijrange( is_org, ie_org, js_org, je_org, &
1291 lon_min, lon_max, lat_min, lat_max, &
1293 ka_org = dims(1) + 2
1296 ia_org = ie_org - is_org + 1
1297 ja_org = je_org - js_org + 1
1299 allocate( lon_org( ia_org, ja_org) )
1300 allocate( lat_org( ia_org, ja_org) )
1301 allocate( cz_org(ka_org, ia_org, ja_org) )
1303 allocate( w_org(ka_org, ia_org, ja_org ) )
1304 allocate( u_org(ka_org, ia_org, ja_org ) )
1305 allocate( v_org(ka_org, ia_org, ja_org ) )
1306 allocate( pt_org(ka_org, ia_org, ja_org ) )
1307 allocate( temp_org(ka_org, ia_org, ja_org ) )
1308 allocate( pres_org(ka_org, ia_org, ja_org ) )
1309 allocate( dens_org(ka_org, ia_org, ja_org ) )
1310 allocate( qtrc_org(ka_org, ia_org, ja_org,
qa) )
1312 allocate( qv_org(ka_org, ia_org, ja_org ) )
1313 allocate( rh_org(ka_org, ia_org, ja_org ) )
1314 allocate( qhyd_org(ka_org, ia_org, ja_org,
n_hyd) )
1315 allocate( qnum_org(ka_org, ia_org, ja_org,
n_hyd) )
1317 allocate( rotc_org(ia_org, ja_org, 2) )
1319 allocate( igrd(
ia,
ja, itp_nh_a) )
1320 allocate( jgrd(
ia,
ja, itp_nh_a) )
1321 allocate( hfact(
ia,
ja, itp_nh_a) )
1322 allocate( kgrd(
ka, 2,
ia,
ja, itp_nh_a) )
1323 allocate( vfact(
ka,
ia,
ja, itp_nh_a) )
1328 lon_org(i,j) = lon_all(i-1+is_org,j-1+js_org)
1329 lat_org(i,j) = lat_all(i-1+is_org,j-1+js_org)
1333 deallocate( lon_all )
1334 deallocate( lat_all )
1336 if ( mapping_info%mapping_name /=
"" )
then
1338 call mapprojection_rotcoef( &
1339 ia_org, 1, ia_org, ja_org, 1, ja_org, &
1340 lon_org(:,:), lat_org(:,:), &
1341 mapping_info%mapping_name, &
1343 rotc_org(:,:,1), rotc_org(:,:,2) )
1345 rotc_org(:,:,1) = 1.0_rp
1346 rotc_org(:,:,2) = 0.0_rp
1349 first_atmos = .true.
1352 end subroutine parentatmossetup
1356 subroutine parentatmosfinalize( &
1362 character(len=*),
intent(in) :: inputtype
1365 select case(inputtype)
1368 if ( do_read_atmos )
then
1382 deallocate( rotc_org )
1384 deallocate( lon_org )
1385 deallocate( lat_org )
1386 deallocate( cz_org )
1391 deallocate( pt_org )
1392 deallocate( temp_org )
1393 deallocate( pres_org )
1394 deallocate( dens_org )
1395 deallocate( qtrc_org )
1397 deallocate( qv_org )
1398 deallocate( rh_org )
1399 deallocate( qhyd_org )
1400 deallocate( qnum_org )
1403 end subroutine parentatmosfinalize
1408 subroutine parentatmosopen( &
1416 character(len=*),
intent(in) :: inputtype
1417 character(len=*),
intent(in) :: basename_org
1418 character(len=*),
intent(in) :: basename_num
1422 select case(inputtype)
1425 if ( do_read_atmos )
then
1435 end subroutine parentatmosopen
1439 subroutine parentatmosinput( &
1483 thermodyn_qdry => atmos_thermodyn_qdry, &
1484 thermodyn_r => atmos_thermodyn_r, &
1485 thermodyn_cp => atmos_thermodyn_cp, &
1486 thermodyn_rhot2pres => atmos_thermodyn_rhot2pres, &
1487 thermodyn_temp_pres2pott => atmos_thermodyn_temp_pres2pott, &
1488 thermodyn_specific_heat => atmos_thermodyn_specific_heat
1490 psat => atmos_saturation_psat_liq
1492 hydrostatic_buildrho_real => atmos_hydrostatic_buildrho_real
1516 mapprojection_lonlat2xy
1521 character(len=*),
intent(in) :: inputtype
1522 character(len=*),
intent(in) :: basename_num
1523 integer,
intent(in) :: dims(6)
1524 integer,
intent(in) :: istep
1525 logical,
intent(in) :: sfc_diagnoses
1526 logical,
intent(in) :: under_sfc
1527 logical,
intent(in) :: same_mptype
1528 logical,
intent(in) :: skip_vcheck
1529 logical,
intent(in) :: qtrc_flag(
qa)
1531 real(
rp),
intent(out) :: dens(
ka,
ia,
ja)
1532 real(
rp),
intent(out) :: momz(
ka,
ia,
ja)
1533 real(
rp),
intent(out) :: momx(
ka,
ia,
ja)
1534 real(
rp),
intent(out) :: momy(
ka,
ia,
ja)
1535 real(
rp),
intent(out) :: rhot(
ka,
ia,
ja)
1537 real(
rp),
intent(out) :: velz(
ka,
ia,
ja)
1538 real(
rp),
intent(out) :: velx(
ka,
ia,
ja)
1539 real(
rp),
intent(out) :: vely(
ka,
ia,
ja)
1540 real(
rp),
intent(out) :: pott(
ka,
ia,
ja)
1541 real(
rp),
intent(out) :: pres(
ka,
ia,
ja)
1551 real(
rp) :: u_on_map, v_on_map
1553 real(
rp) :: qdry(ka_org,ia_org,ja_org)
1554 real(
rp) :: rtot(ka_org,ia_org,ja_org)
1555 real(
rp) :: cptot(ka_org,ia_org,ja_org)
1556 real(
rp) :: cvtot(ka_org,ia_org,ja_org)
1557 real(
rp) :: qtot, p_sat, qm
1558 real(
rp) :: rhot_tmp
1560 integer :: lm_layer(ia_org,ja_org)
1562 real(
rp) :: x_org(ia_org,ja_org)
1563 real(
rp) :: y_org(ia_org,ja_org)
1564 logical :: zonal, pole
1569 logical :: same_mptype_
1574 logical :: qnum_flag
1581 integer ::
k, i, j, iq
1586 if ( do_read_atmos )
then
1587 select case(inputtype)
1590 ia_org, is_org, ie_org, &
1591 ja_org, js_org, je_org, &
1601 qtrc_org(:,:,:,:), &
1604 qhyd_org(:,:,:,:), &
1605 qnum_org(:,:,:,:), &
1615 same_mptype_ = same_mptype
1618 ia_org, is_org, ie_org, &
1619 ja_org, js_org, je_org, &
1630 qhyd_org(:,:,:,:), &
1631 qtrc_org(:,:,:,:), &
1638 same_mptype_ = .false.
1643 if ( sfc_diagnoses )
then
1650 if ( .not. temp2pt )
then
1651 log_error(
"ParentAtmosInput",*)
'When RH is read, TEMP is necessary'
1660 if ( temp_org(
k,i,j) > undef .and. rh_org(
k,i,j) > undef .and. pres_org(
k,i,j) > undef )
then
1661 call psat( temp_org(
k,i,j), p_sat )
1662 qm = epsvap * rh_org(
k,i,j) * 0.01_rp * p_sat &
1663 / ( pres_org(
k,i,j) - rh_org(
k,i,j) * 0.01_rp * p_sat )
1664 qv_org(
k,i,j) = qm / ( 1.0_rp + qm )
1666 qv_org(
k,i,j) = undef
1676 qv_org(
k,i,j) = undef
1684 select case( upper_qv_type )
1690 if ( qv_org(
k,i,j) == undef ) qv_org(
k,i,j) = qv_org(
k-1,i,j)
1699 if ( qv_org(
k,i,j) == undef ) qv_org(
k,i,j) = 0.0_rp
1704 log_error(
"ParentAtmosInput",*)
'upper_qv_type in PARAM_MKINIT_REAL is invalid! ', trim(upper_qv_type)
1708 if ( mixing_ratio )
then
1715 if ( qv_org(
k,i,j) > undef )
then
1716 qtot = qtot + qv_org(
k,i,j)
1719 if ( qhyd_org(
k,i,j,iq) > undef )
then
1720 qtot = qtot + qhyd_org(
k,i,j,iq)
1723 if( qv_org(
k,i,j) > undef .and. qtot > 0.0_rp )
then
1724 qv_org(
k,i,j) = qv_org(
k,i,j) / ( 1.0_rp + qtot )
1726 qv_org(
k,i,j) = undef
1729 if ( qhyd_org(
k,i,j,iq) > undef .and. qtot > 0.0_rp )
then
1730 qhyd_org(
k,i,j,iq) = qhyd_org(
k,i,j,iq) / ( 1.0_rp + qtot )
1732 qhyd_org(
k,i,j,iq) = 0.0_rp
1741 if ( .not. same_mptype_ )
then
1742 if ( qnum_flag )
then
1744 qv_org(:,:,:), qhyd_org(:,:,:,:), &
1746 qnum=qnum_org(:,:,:,:) )
1749 qv_org(:,:,:), qhyd_org(:,:,:,:), &
1757 qtrc_org(
k,i,j,iq) = undef
1760 if ( qv_org(
k,i,j) == undef ) qtrc_org(
k,i,j,iq) = undef
1767 if ( pt_dry .and. .not. temp2pt )
then
1769 log_error(
'ParentAtmosInput',*)
'PRES is required'
1776 temp_org(
k,i,j) = pt_org(
k,i,j) * ( pres_org(
k,i,j) / pre00 )**(rdry/cpdry)
1783 if ( temp2pt .or. nopres .or. nodens )
then
1784 call thermodyn_specific_heat( &
1785 ka_org, 3, ka_org, ia_org, 1, ia_org, ja_org, 1, ja_org,
qa, &
1786 qtrc_org(:,:,:,:), &
1788 qdry(:,:,:), rtot(:,:,:), cvtot(:,:,:), cptot(:,:,:) )
1793 log_error(
'ParentAtmosInput',*)
'If TEMP is read, PRES is required'
1800 if ( temp_org(
k,i,j) == undef )
then
1801 pt_org(
k,i,j) = undef
1803 call thermodyn_temp_pres2pott( &
1804 temp_org(
k,i,j), pres_org(
k,i,j), &
1805 cptot(
k,i,j), rtot(
k,i,j), &
1815 log_error(
'ParentAtmosInput',*)
'If PRES does not exist, DENS is required'
1823 if ( pt_org(
k,i,j) == undef )
then
1824 pres_org(
k,i,j) = undef
1826 rhot_tmp = pt_org(
k,i,j) * dens_org(
k,i,j)
1827 call thermodyn_rhot2pres( &
1828 rhot_tmp, cvtot(
k,i,j), cptot(
k,i,j), rtot(
k,i,j), &
1836 if ( nodens .and. use_file_density )
then
1837 log_error(
'ParentAtmosInput',*)
'DENS is required when USE_FILE_DENSITY is true'
1848 if( pres_org(
k,i,j) == undef )
then
1849 lm_layer(i,j) =
k + 1
1856 if ( sfc_diagnoses )
then
1858 if ( .not. under_sfc )
then
1864 .not. (cz_org(2,i,j) > undef .and. cz_org(
k,i,j) > cz_org(2,i,j) ) .or. &
1865 .not. (pres_org(2,i,j) > undef .and. pres_org(
k,i,j) > pres_org(2,i,j) ) &
1883 if ( cz_org(2,i,j) > undef .and. &
1884 ( .not. under_sfc .or. cz_org(2,i,j) < cz_org(
k,i,j) ) )
then
1885 dz = cz_org(
k,i,j) - cz_org(2,i,j)
1886 if ( qv_org(2,i,j) > undef ) qv_org(2,i,j) = qtrc_org(
k,i,j,
qs_mp)
1887 if ( temp_org(2,i,j) > undef .and. pres_org(2,i,j) > undef )
then
1888 rtot(2,i,j) = rdry * ( 1.0_rp + epstvap * qv_org(2,i,j) )
1889 dens_org(2,i,j) = pres_org(2,i,j) / ( rtot(2,i,j) * temp_org(2,i,j) )
1890 else if ( pres_org(2,i,j) > undef )
then
1891 dens_org(2,i,j) = - ( pres_org(
k,i,j) - pres_org(2,i,j) ) * 2.0_rp / ( grav * dz ) &
1893 rtot(2,i,j) = rdry * ( 1.0_rp + epstvap * qv_org(2,i,j) )
1894 temp_org(2,i,j) = pres_org(2,i,j) / ( rtot(2,i,j) * dens_org(2,i,j) )
1895 else if ( temp_org(2,i,j) > undef )
then
1896 rtot(2,i,j) = rdry * ( 1.0_rp + epstvap * qv_org(2,i,j) )
1897 dens_org(2,i,j) = ( pres_org(
k,i,j) + grav * dens_org(
k,i,j) * dz * 0.5_rp ) &
1898 / ( rtot(2,i,j) * temp_org(2,i,j) - grav * dz * 0.5_rp )
1899 pres_org(2,i,j) = dens_org(2,i,j) * rtot(2,i,j) * temp_org(2,i,j)
1901 temp_org(2,i,j) = temp_org(
k,i,j) + laps * dz
1902 rtot(2,i,j) = rdry * ( 1.0_rp + epstvap * qv_org(2,i,j) )
1903 dens_org(2,i,j) = ( pres_org(
k,i,j) + grav * dens_org(
k,i,j) * dz * 0.5_rp ) &
1904 / ( rtot(2,i,j) * temp_org(2,i,j) - grav * dz * 0.5_rp )
1905 pres_org(2,i,j) = dens_org(2,i,j) * rtot(2,i,j) * temp_org(2,i,j)
1907 cptot(2,i,j) = cpdry + ( cpvap - cpdry ) * qv_org(2,i,j)
1908 pt_org(2,i,j) = temp_org(2,i,j) * ( pre00 / pres_org(2,i,j) )**(rtot(2,i,j)/cptot(2,i,j))
1913 cz_org(2,i,j) = cz_org(
k,i,j)
1914 w_org(2,i,j) = w_org(
k,i,j)
1915 u_org(2,i,j) = u_org(
k,i,j)
1916 v_org(2,i,j) = v_org(
k,i,j)
1917 pres_org(2,i,j) = pres_org(
k,i,j)
1918 pt_org(2,i,j) = pt_org(
k,i,j)
1919 dens_org(2,i,j) = dens_org(
k,i,j)
1920 qtrc_org(2,i,j,:) = qtrc_org(
k,i,j,:)
1933 if ( pres_org(1,i,j) > undef )
then
1934 temp_org(1,i,j) = temp_org(2,i,j) + laps * cz_org(2,i,j)
1935 rtot(1,i,j) = rdry * ( 1.0_rp + epstvap * qv_org(2,i,j) )
1936 cptot(1,i,j) = cpdry + ( cpvap - cpdry ) * qv_org(2,i,j)
1937 dens_org(1,i,j) = pres_org(1,i,j) / ( rtot(1,i,j) * temp_org(1,i,j) )
1938 pt_org(1,i,j) = temp_org(1,i,j) * ( pre00 / pres_org(1,i,j) )**(rtot(1,i,j)/cptot(1,i,j))
1939 cz_org(1,i,j) = 0.0_rp
1940 w_org(1,i,j) = w_org(2,i,j)
1941 u_org(1,i,j) = u_org(2,i,j)
1942 v_org(1,i,j) = v_org(2,i,j)
1943 qtrc_org(1,i,j,:) = qtrc_org(2,i,j,:)
1945 cz_org(1,i,j) = undef
1946 w_org(1,i,j) = undef
1947 u_org(1,i,j) = undef
1948 v_org(1,i,j) = undef
1949 pres_org(1,i,j) = undef
1950 pt_org(1,i,j) = undef
1951 dens_org(1,i,j) = undef
1952 qtrc_org(1,i,j,:) = undef
1962 cz_org(1:2,i,j) = undef
1963 w_org(1:2,i,j) = undef
1964 u_org(1:2,i,j) = undef
1965 v_org(1:2,i,j) = undef
1966 pres_org(1:2,i,j) = undef
1967 temp_org(1:2,i,j) = undef
1968 dens_org(1:2,i,j) = undef
1969 qtrc_org(1:2,i,j,:) = undef
1981 if ( serial_atmos )
then
1982 if ( first_atmos .or. update_coord )
then
1983 call comm_bcast( ka_org, ia_org, ja_org, cz_org )
1985 call comm_bcast( ka_org, ia_org, ja_org, pres_org )
1986 call comm_bcast( ka_org, ia_org, ja_org, w_org )
1987 call comm_bcast( ka_org, ia_org, ja_org, u_org )
1988 call comm_bcast( ka_org, ia_org, ja_org, v_org )
1989 call comm_bcast( ka_org, ia_org, ja_org, pt_org )
1990 call comm_bcast( ka_org, ia_org, ja_org, dens_org )
1991 call comm_bcast( ka_org, ia_org, ja_org,
qa, qtrc_org )
1992 call comm_bcast( uvmet )
2002 if ( qtrc_org(
k,i,j,iq) .ne. undef )
then
2003 qtrc_org(
k,i,j,iq) = max( qtrc_org(
k,i,j,iq), 0.0_rp )
2013 if ( first_atmos .or. update_coord )
then
2023 skip_z = skip_vcheck )
2025 select case( itp_type_a )
2026 case ( i_intrp_linear )
2028 if ( ia_org == 1 .or. ja_org == 1 )
then
2029 log_error(
"ParentAtmosInput",*)
'LINER interpolation requires nx, ny > 1'
2030 log_error_cont(*)
'Use "DIST-WEIGHT" as INTRP_TYPE of PARAM_MKINIT_REAL_ATMOS'
2037 lat_org(i,j) = sign( min( abs(lat_org(i,j)), pi * 0.499999_rp ), lat_org(i,j) )
2041 call mapprojection_lonlat2xy( ia_org, 1, ia_org, &
2042 ja_org, 1, ja_org, &
2048 zonal = ( maxval(lon_org) - minval(lon_org) ) > 2.0_rp * pi * 0.9_rp
2049 pole = ( maxval(lat_org) > pi * 0.5_rp * 0.9_rp ) .or. ( minval(lat_org) < - pi * 0.5_rp * 0.9_rp )
2050 call interp_factor3d( ka_org, 1, ka_org, &
2054 x_org(:,:), y_org(:,:), &
2063 flag_extrap = .false., &
2067 case ( i_intrp_dstwgt )
2069 call interp_factor3d( itp_nh_a, &
2070 ka_org, 1, ka_org, &
2085 flag_extrap = .false. )
2092 ka_org, 1, ka_org, &
2096 igrd(:,:,:), jgrd(:,:,:), &
2100 cz_org(:,:,:), cz(:,:,:), &
2104 threshold_undef = 1.0_rp, &
2105 wsum = wsum(:,:,:), &
2106 val2 = work(:,:,:) )
2113 if ( w(
k,i,j) .ne. undef )
then
2118 do k = kref-1,
ks, -1
2119 w(
k,i,j) = w(
k+1,i,j) * log( ( cz(
k,i,j) - topo(i,j) ) / z0m(i,j) ) / log( ( cz(
k+1,i,j) - topo(i,j) ) / z0m(i,j) ) * ( 1.0_rp - wsum(
k,i,j) ) &
2120 + work(
k,i,j) * wsum(
k,i,j)
2123 if ( w(
k,i,j) == undef ) w(
k,i,j) = w(
k-1,i,j)
2127 if ( filter_niter > 0 )
then
2129 w(:,:,:), filter_order, filter_niter )
2130 call comm_vars8( w(:,:,:), 1 )
2131 call comm_wait ( w(:,:,:), 1, .false. )
2134 if ( .not. uvmet )
then
2141 if ( u_org(
k,i,j) > undef .and. v_org(
k,i,j) > undef )
then
2142 u_on_map = u_org(
k,i,j) * rotc_org(i,j,1) - v_org(
k,i,j) * rotc_org(i,j,2)
2143 v_on_map = u_org(
k,i,j) * rotc_org(i,j,2) + v_org(
k,i,j) * rotc_org(i,j,1)
2145 u_org(
k,i,j) = u_on_map
2146 v_org(
k,i,j) = v_on_map
2155 ka_org, 1, ka_org, &
2159 igrd(:,:,:), jgrd(:,:,:), &
2163 cz_org(:,:,:), cz(:,:,:), &
2167 threshold_undef = 1.0_rp, &
2168 wsum = wsum(:,:,:), &
2169 val2 = work(:,:,:) )
2175 if ( u(
k,i,j) .ne. undef )
then
2180 do k = kref-1,
ks, -1
2181 u(
k,i,j) = u(
k+1,i,j) * log( ( cz(
k,i,j) - topo(i,j) ) / z0m(i,j) ) / log( ( cz(
k+1,i,j) - topo(i,j) ) / z0m(i,j) ) * ( 1.0_rp - wsum(
k,i,j) ) &
2182 + work(
k,i,j) * wsum(
k,i,j)
2185 if ( u(
k,i,j) == undef ) u(
k,i,j) = u(
k-1,i,j)
2189 if ( filter_niter > 0 )
then
2191 u(:,:,:), filter_order, filter_niter )
2192 call comm_vars8( u(:,:,:), 1 )
2193 call comm_wait ( u(:,:,:), 1, .false. )
2197 ka_org, 1, ka_org, &
2201 igrd(:,:,:), jgrd(:,:,:), &
2205 cz_org(:,:,:), cz(:,:,:), &
2209 threshold_undef = 1.0_rp, &
2210 wsum = wsum(:,:,:), &
2211 val2 = work(:,:,:) )
2217 if ( v(
k,i,j) .ne. undef )
then
2222 do k = kref-1,
ks, -1
2223 v(
k,i,j) = v(
k+1,i,j) * log( ( cz(
k,i,j) - topo(i,j) ) / z0m(i,j) ) / log( ( cz(
k+1,i,j) - topo(i,j) ) / z0m(i,j) ) * ( 1.0_rp - wsum(
k,i,j) ) &
2224 + work(
k,i,j) * wsum(
k,i,j)
2227 if ( v(
k,i,j) == undef ) v(
k,i,j) = v(
k-1,i,j)
2231 if ( filter_niter > 0 )
then
2233 v(:,:,:), filter_order, filter_niter )
2234 call comm_vars8( v(:,:,:), 1 )
2235 call comm_wait ( v(:,:,:), 1, .false. )
2244 u_on_map = u(
k,i,j) * rotc(i,j,1) + v(
k,i,j) * rotc(i,j,2)
2245 v_on_map = -u(
k,i,j) * rotc(i,j,2) + v(
k,i,j) * rotc(i,j,1)
2258 velz(
k,i,j) = 0.5_rp * ( w(
k+1,i,j) + w(
k,i,j) )
2267 velx(
k,i,j) = 0.5_rp * ( u(
k,i+1,j) + u(
k,i,j) )
2276 velx(
k,i,j) = u(
k,i,j)
2284 vely(
k,i,j) = 0.5_rp * ( v(
k,i,j+1) + v(
k,i,j) )
2293 vely(
k,i,j) = v(
k,i,j)
2300 velz( 1:
ks-1,i,j) = 0.0_rp
2301 velz(
ke :
ka ,i,j) = 0.0_rp
2302 velx( 1:
ks-1,i,j) = 0.0_rp
2303 velx(
ke+1:
ka ,i,j) = 0.0_rp
2304 vely( 1:
ks-1,i,j) = 0.0_rp
2305 vely(
ke+1:
ka ,i,j) = 0.0_rp
2309 call comm_vars8( velz(:,:,:), 1 )
2310 call comm_vars8( velx(:,:,:), 2 )
2311 call comm_vars8( vely(:,:,:), 3 )
2312 call comm_wait ( velz(:,:,:), 1, .false. )
2313 call comm_wait ( velx(:,:,:), 2, .false. )
2314 call comm_wait ( vely(:,:,:), 3, .false. )
2317 ka_org, 1, ka_org, &
2321 igrd(:,:,:), jgrd(:,:,:), &
2325 cz_org(:,:,:), cz(:,:,:), &
2329 threshold_undef = 1.0_rp, &
2330 wsum = wsum(:,:,:), &
2331 val2 = work(:,:,:) )
2336 if ( pott(
k,i,j) == undef .and. pott(
k-1,i,j) .ne. undef ) pott(
k,i,j) = pott(
k-1,i,j)
2339 if ( pott(
k,i,j) == undef )
then
2340 pott(
k,i,j) = pott(
k+1,i,j) * ( 1.0_rp - wsum(
k,i,j) ) &
2341 + work(
k,i,j) * wsum(
k,i,j)
2344 pott( 1:
ks-1,i,j) = undef
2345 pott(
ke+1:
ka ,i,j) = undef
2348 if ( filter_niter > 0 )
then
2350 pott(:,:,:), filter_order, filter_niter )
2351 call comm_vars8( pott(:,:,:), 1 )
2352 call comm_wait ( pott(:,:,:), 1, .false. )
2357 if ( ( iq <
qs_mp .or. iq >
qe_mp ) .and. ( .not. qtrc_flag(iq) ) )
then
2362 qtrc(
k,i,j,iq) = undef
2370 ka_org, 1, ka_org, &
2374 igrd(:,:,:), jgrd(:,:,:), &
2378 cz_org(:,:,:), cz(:,:,:), &
2379 qtrc_org(:,:,:,iq), &
2382 threshold_undef = 1.0_rp, &
2383 wsum = wsum(:,:,:), &
2384 val2 = work(:,:,:) )
2389 if ( qtrc(
k,i,j,iq) == undef .and. qtrc(
k-1,i,j,iq) > undef ) qtrc(
k,i,j,iq) = qtrc(
k-1,i,j,iq)
2392 if ( qtrc(
k,i,j,iq) == undef .and. qtrc(
k+1,i,j,iq) > undef )
then
2393 qtrc(
k,i,j,iq) = qtrc(
k+1,i,j,iq) * ( 1.0_rp - wsum(
k,i,j) ) &
2394 + work(
k,i,j) * wsum(
k,i,j)
2398 qtrc(
k,i,j,iq) = max( qtrc(
k,i,j,iq), 0.0_rp )
2400 qtrc( 1:
ks-1,i,j,iq) = 0.0_rp
2401 qtrc(
ke+1:
ka ,i,j,iq) = 0.0_rp
2404 if ( filter_niter > 0 )
then
2414 qtrc(:,:,:,iq), filter_order, filter_niter, &
2415 limiter_sign = one(:,:,:) )
2416 call comm_vars8( qtrc(:,:,:,iq), 1 )
2417 call comm_wait ( qtrc(:,:,:,iq), 1, .false. )
2422 ka_org, 1, ka_org, &
2459 qv(
k,i,j) = qtrc(
k,i,j,
i_qv)
2461 qc(
k,i,j) = qc(
k,i,j) + qtrc(
k,i,j,iq)
2473 pres2(
k,i,j) = pres(
k,i,j)
2478 if ( use_file_density )
then
2480 ka_org, 1, ka_org, &
2484 igrd(:,:,:), jgrd(:,:,:), &
2488 cz_org(:,:,:), cz(:,:,:), &
2491 threshold_undef = 1.0_rp, &
2492 wsum = wsum(:,:,:), &
2493 val2 = work(:,:,:) )
2494 call hydrostatic_buildrho_real(
ka,
ks,
ke,
ia, 1,
ia,
ja, 1,
ja, &
2495 pott(:,:,:), qv(:,:,:), qc(:,:,:), &
2498 dens2(:,:,:), temp(:,:,:) )
2503 if ( dens(
k,i,j) == undef )
then
2504 dens(
k,i,j) = dens2(
k,i,j) * ( 1.0_rp - wsum(
k,i,j) ) &
2505 + work(
k,i,j) * wsum(
k,i,j)
2512 call hydrostatic_buildrho_real(
ka,
ks,
ke,
ia, 1,
ia,
ja, 1,
ja, &
2513 pott(:,:,:), qv(:,:,:), qc(:,:,:), &
2516 dens(:,:,:), temp(:,:,:) )
2519 if ( filter_niter > 0 )
then
2521 dens(:,:,:), filter_order, filter_niter, &
2522 limiter_sign = one(:,:,:) )
2523 call comm_vars8( dens(:,:,:), 1 )
2524 call comm_wait ( dens(:,:,:), 1, .false. )
2531 if ( pres(
k,i,j) == undef ) pres(
k,i,j) = pres2(
k,i,j)
2540 dens( 1:
ks-1,i,j) = 0.0_rp
2541 dens(
ke+1:
ka ,i,j) = 0.0_rp
2549 momz(
k,i,j) = velz(
k,i,j) * 0.5_rp * ( dens(
k+1,i,j) + dens(
k,i,j) )
2558 momx(
k,i,j) = velx(
k,i,j) * 0.5_rp * ( dens(
k,i+1,j) + dens(
k,i,j) )
2567 momx(
k,i,j) = velx(
k,i,j) * dens(
k,i,j)
2575 momy(
k,i,j) = vely(
k,i,j) * 0.5_rp * ( dens(
k,i,j+1) + dens(
k,i,j) )
2584 momy(
k,i,j) = vely(
k,i,j) * dens(
k,i,j)
2592 rhot(
k,i,j) = pott(
k,i,j) * dens(
k,i,j)
2600 momz( 1:
ks-1,i,j) = 0.0_rp
2601 momz(
ke :
ka ,i,j) = 0.0_rp
2602 momx( 1:
ks-1,i,j) = 0.0_rp
2603 momx(
ke+1:
ka ,i,j) = 0.0_rp
2604 momy( 1:
ks-1,i,j) = 0.0_rp
2605 momy(
ke+1:
ka ,i,j) = 0.0_rp
2609 call comm_vars8( momz(:,:,:), 1 )
2610 call comm_vars8( momx(:,:,:), 2 )
2611 call comm_vars8( momy(:,:,:), 3 )
2612 call comm_wait ( momz(:,:,:), 1, .false. )
2613 call comm_wait ( momx(:,:,:), 2, .false. )
2614 call comm_wait ( momy(:,:,:), 3, .false. )
2616 first_atmos = .false.
2621 end subroutine parentatmosinput
2625 subroutine boundaryatmossetup( &
2644 character(len=*),
intent(in) :: basename
2645 character(len=*),
intent(in) :: title
2646 character(len=*),
intent(in) :: datatype
2647 real(
dp),
intent(in) :: timeintv
2648 logical,
intent(in) :: qtrc_flag(
qa)
2649 integer,
intent(out) :: fid
2650 integer,
intent(out) :: vid(5+
qa)
2658 'DENS',
'Reference Density',
'kg/m3',
'ZXYT', datatype, &
2662 'VELZ',
'Reference VELZ',
'm/s',
'ZHXYT', datatype, &
2666 'VELX',
'Reference VELX',
'm/s',
'ZXHYT', datatype, &
2670 'VELY',
'Reference VELY',
'm/s',
'ZXYHT', datatype, &
2674 'PT',
'Reference PT',
'K',
'ZXYT', datatype, &
2683 timeintv = timeintv )
2688 if ( .not. qtrc_flag(iq) ) cycle
2693 timeintv = timeintv )
2699 end subroutine boundaryatmossetup
2703 subroutine boundaryatmosoutput( &
2715 file_cartesc_write_var
2721 real(
rp),
intent(in) :: dens(
ka,
ia,
ja)
2722 real(
rp),
intent(in) :: velz(
ka,
ia,
ja)
2723 real(
rp),
intent(in) :: velx(
ka,
ia,
ja)
2724 real(
rp),
intent(in) :: vely(
ka,
ia,
ja)
2725 real(
rp),
intent(in) :: pott(
ka,
ia,
ja)
2727 logical,
intent(in) :: qtrc_flag(
qa)
2728 integer,
intent(in) :: fid
2729 integer,
intent(in) :: vid(5+
qa)
2730 real(
dp),
intent(in) :: timeintv
2731 integer,
intent(in) :: istep
2741 timeofs = real(istep-1,kind=
dp) * timeintv
2744 work(:,:,:,1) = dens(:,:,:)
2745 call file_cartesc_write_var( fid, vid(1), work(:,:,:,:),
'DENS',
'ZXYT', timeintv, timeofs=timeofs )
2747 work(:,:,:,1) = velz(:,:,:)
2748 call file_cartesc_write_var( fid, vid(2), work(:,:,:,:),
'VELZ',
'ZHXYT', timeintv, timeofs=timeofs )
2750 work(:,:,:,1) = velx(:,:,:)
2751 call file_cartesc_write_var( fid, vid(3), work(:,:,:,:),
'VELX',
'ZXHYT', timeintv, timeofs=timeofs )
2753 work(:,:,:,1) = vely(:,:,:)
2754 call file_cartesc_write_var( fid, vid(4), work(:,:,:,:),
'VELY',
'ZXYHT', timeintv, timeofs=timeofs )
2756 work(:,:,:,1) = pott(:,:,:)
2757 call file_cartesc_write_var( fid, vid(5), work(:,:,:,:),
'PT',
'ZXYT', timeintv, timeofs=timeofs )
2760 call file_cartesc_write_var( fid, vid(5+iq),qtrc(:,:,:,iq:iq),
tracer_name(iq), &
2761 'ZXYT', timeintv, timeofs=timeofs )
2766 if ( .not. qtrc_flag(iq) ) cycle
2767 call file_cartesc_write_var( fid, vid(5+iq),qtrc(:,:,:,iq:iq),
tracer_name(iq), &
2768 'ZXYT', timeintv, timeofs=timeofs )
2774 end subroutine boundaryatmosoutput
2778 subroutine parentsurfacesetup( &
2783 basename_org_land, &
2784 basename_org_ocean, &
2789 use_file_landwater, &
2793 intrp_land_sfc_temp, &
2795 intrp_ocean_sfc_temp )
2810 integer,
intent(out) :: ldims(3)
2811 integer,
intent(out) :: odims(2)
2812 integer,
intent(out) :: lmdlid
2813 integer,
intent(out) :: omdlid
2814 integer,
intent(out) :: timelen_land
2815 integer,
intent(out) :: timelen_ocean
2817 character(len=*),
intent(in) :: basename_org_land
2818 character(len=*),
intent(in) :: basename_org_ocean
2819 character(len=*),
intent(in) :: basename_land
2820 character(len=*),
intent(in) :: basename_ocean
2821 character(len=*),
intent(in) :: filetype_land
2822 character(len=*),
intent(in) :: filetype_ocean
2823 logical,
intent(in) :: use_file_landwater
2824 integer,
intent(in) :: intrp_iter_max
2825 character(len=*),
intent(in) :: intrp_land_temp
2826 character(len=*),
intent(in) :: intrp_land_water
2827 character(len=*),
intent(in) :: intrp_land_sfc_temp
2828 character(len=*),
intent(in) :: intrp_ocean_temp
2829 character(len=*),
intent(in) :: intrp_ocean_sfc_temp
2831 real(
rp),
allocatable :: lon_all(:,:)
2832 real(
rp),
allocatable :: lat_all(:,:)
2834 real(
rp) :: lon_min, lon_max
2835 real(
rp) :: lat_min, lat_max
2842 log_info(
"ParentSurfaceSetup",*)
'Setup'
2847 log_error(
"ParentSurfaceSetup",*)
'LKMAX less than 4: ',
lkmax
2848 log_error_cont(*)
'in Real Case, LKMAX should be set more than 4'
2856 do_read_land = .false.
2858 do_read_land = .true.
2861 select case(filetype_land)
2868 basename_org_land, &
2870 use_file_landwater, &
2880 basename_org_land, &
2885 log_error(
"ParentSurfaceSetup",*)
'Unsupported FILE TYPE:', trim(filetype_land)
2895 if ( serial_land )
then
2896 call comm_bcast( 3, ldims(:) )
2897 call comm_bcast( timelen_land )
2899 if ( .not. do_read_land )
then
2900 allocate( lon_all(ldims(2), ldims(3)) )
2901 allocate( lat_all(ldims(2), ldims(3)) )
2903 call comm_bcast( ldims(2), ldims(3), lon_all )
2904 call comm_bcast( ldims(2), ldims(3), lat_all )
2912 call get_ijrange( lis_org, lie_org, ljs_org, lje_org, &
2913 ldims(2), ldims(3), &
2914 lon_min, lon_max, lat_min, lat_max, &
2916 lis_org = max( lis_org - intrp_iter_max, 1 )
2917 lie_org = min( lie_org + intrp_iter_max, ldims(2) )
2918 ljs_org = max( ljs_org - intrp_iter_max, 1 )
2919 lje_org = min( lje_org + intrp_iter_max, ldims(3) )
2923 lka_org = lke_org - lks_org + 1
2924 lia_org = lie_org - lis_org + 1
2925 lja_org = lje_org - ljs_org + 1
2927 allocate( llon_org(lia_org, lja_org) )
2928 allocate( llat_org(lia_org, lja_org) )
2933 llon_org(i,j) = lon_all(i-1+lis_org,j-1+ljs_org)
2934 llat_org(i,j) = lat_all(i-1+lis_org,j-1+ljs_org)
2938 deallocate( lon_all )
2939 deallocate( lat_all )
2942 select case( intrp_land_temp )
2944 i_intrp_land_temp = i_intrp_off
2946 i_intrp_land_temp = i_intrp_mask
2948 i_intrp_land_temp = i_intrp_fill
2950 log_error(
"ParentSurfaceSetup",*)
'INTRP_LAND_TEMP is invalid. ', intrp_land_temp
2953 select case( intrp_land_sfc_temp )
2955 i_intrp_land_sfc_temp = i_intrp_off
2957 i_intrp_land_sfc_temp = i_intrp_mask
2959 i_intrp_land_sfc_temp = i_intrp_fill
2961 log_error(
"ParentSurfaceSetup",*)
'INTRP_LAND_SFC_TEMP is invalid. ', intrp_land_sfc_temp
2964 select case( intrp_land_water )
2966 i_intrp_land_water = i_intrp_off
2968 i_intrp_land_water = i_intrp_mask
2970 i_intrp_land_water = i_intrp_fill
2972 log_error(
"ParentSurfaceSetup",*)
'INTRP_LAND_WATER is invalid. ', intrp_land_water
2976 select case( lmdlid )
2978 i_intrp_land_temp = i_intrp_mask
2979 i_intrp_land_sfc_temp = i_intrp_mask
2980 i_intrp_land_water = i_intrp_mask
2987 do_read_ocean = .false.
2989 do_read_ocean = .true.
2992 select case(filetype_ocean)
2998 basename_org_ocean, &
3008 basename_org_ocean, &
3012 log_error(
"ParentSurfaceSetup",*)
'Unsupported FILE TYPE:', trim(filetype_ocean)
3022 if ( serial_ocean )
then
3023 call comm_bcast( 2, odims(:) )
3024 call comm_bcast( timelen_ocean )
3026 if ( .not. do_read_ocean )
then
3027 allocate( lon_all(odims(1), odims(2)) )
3028 allocate( lat_all(odims(1), odims(2)) )
3030 call comm_bcast( odims(1), odims(2), lon_all )
3031 call comm_bcast( odims(1), odims(2), lat_all )
3039 call get_ijrange( ois_org, oie_org, ojs_org, oje_org, &
3040 odims(1), odims(2), &
3041 lon_min, lon_max, lat_min, lat_max, &
3043 ois_org = max( ois_org - intrp_iter_max, 1 )
3044 oie_org = min( oie_org + intrp_iter_max, odims(1) )
3045 ojs_org = max( ojs_org - intrp_iter_max, 1 )
3046 oje_org = min( oje_org + intrp_iter_max, odims(2) )
3048 oia_org = oie_org - ois_org + 1
3049 oja_org = oje_org - ojs_org + 1
3051 allocate( olon_org(oia_org, oja_org) )
3052 allocate( olat_org(oia_org, oja_org) )
3057 olon_org(i,j) = lon_all(i-1+ois_org,j-1+ojs_org)
3058 olat_org(i,j) = lat_all(i-1+ois_org,j-1+ojs_org)
3062 deallocate( lon_all )
3063 deallocate( lat_all )
3065 select case( intrp_ocean_temp )
3067 i_intrp_ocean_temp = i_intrp_off
3069 i_intrp_ocean_temp = i_intrp_mask
3071 i_intrp_ocean_temp = i_intrp_fill
3073 log_error(
"ParentSurfaceSetup",*)
'INTRP_OCEAN_TEMP is invalid. ', intrp_ocean_temp
3076 select case( intrp_ocean_sfc_temp )
3078 i_intrp_ocean_sfc_temp = i_intrp_off
3080 i_intrp_ocean_sfc_temp = i_intrp_mask
3082 i_intrp_ocean_sfc_temp = i_intrp_fill
3084 log_error(
"ParentSurfaceSetup",*)
'INTRP_OCEAN_SFC_TEMP is invalid. ', intrp_ocean_sfc_temp
3088 select case( omdlid )
3090 i_intrp_ocean_temp = i_intrp_mask
3091 i_intrp_ocean_sfc_temp = i_intrp_mask
3095 allocate( oigrd(
ia,
ja, itp_nh_a) )
3096 allocate( ojgrd(
ia,
ja, itp_nh_a) )
3097 allocate( ohfact(
ia,
ja, itp_nh_a) )
3099 allocate( hfact_ol(oia_org, oja_org, itp_nh_ol) )
3100 allocate( igrd_ol(oia_org, oja_org, itp_nh_ol) )
3101 allocate( jgrd_ol(oia_org, oja_org, itp_nh_ol) )
3104 end subroutine parentsurfacesetup
3108 subroutine parentsurfaceopen( &
3109 filetype_land, filetype_ocean, &
3110 basename_org_land, basename_org_ocean, &
3111 basename_land, basename_ocean )
3116 character(len=*),
intent(in) :: filetype_land
3117 character(len=*),
intent(in) :: filetype_ocean
3118 character(len=*),
intent(in) :: basename_org_land
3119 character(len=*),
intent(in) :: basename_org_ocean
3120 character(len=*),
intent(in) :: basename_land
3121 character(len=*),
intent(in) :: basename_ocean
3123 select case ( filetype_land )
3130 select case ( filetype_ocean )
3138 end subroutine parentsurfaceopen
3141 subroutine parentsurfacefinalize( &
3149 character(len=*),
intent(in) :: filetype_land
3150 character(len=*),
intent(in) :: filetype_ocean
3154 log_info(
"ParentSurfaceFinalize",*)
'Finalize'
3158 if( serial_land )
then
3160 do_read_land = .true.
3162 do_read_land = .false.
3165 do_read_land = .true.
3168 select case(trim(filetype_land))
3171 if ( do_read_ocean )
then
3181 log_error(
"ParentSurfaceFinalize",*)
'Unsupported FILE TYPE:', trim(filetype_land)
3189 if( serial_ocean )
then
3191 do_read_ocean = .true.
3193 do_read_ocean = .false.
3196 do_read_ocean = .true.
3199 select case(trim(filetype_ocean))
3202 if ( do_read_ocean )
then
3212 log_error(
"ParentSurfaceFinalize",*)
'Unsupported FILE TYPE:', trim(filetype_ocean)
3218 deallocate( llon_org )
3219 deallocate( llat_org )
3221 deallocate( olon_org )
3222 deallocate( olat_org )
3226 deallocate( ohfact )
3228 deallocate( hfact_ol )
3229 deallocate( igrd_ol )
3230 deallocate( jgrd_ol )
3232 first_surface = .true.
3235 end subroutine parentsurfacefinalize
3239 subroutine boundarysurfacesetup( &
3254 character(len=*),
intent(in) :: basename
3255 character(len=*),
intent(in) :: title
3256 real(
dp),
intent(in) :: timeintv
3257 logical,
intent(in) :: multi_ocean
3258 logical,
intent(in) :: multi_land
3259 integer,
intent(out) :: fid
3260 integer,
intent(out) :: vid(10)
3262 character(len=H_SHORT) :: boundary_out_dtype =
'DEFAULT'
3267 if ( multi_land )
then
3269 'LAND_TEMP',
'Reference Land Temperature',
'K', &
3270 'LXYT', boundary_out_dtype, &
3274 'LAND_WATER',
'Reference Land Moisture',
'm3/m3', &
3275 'LXYT', boundary_out_dtype, &
3279 'LAND_SFC_TEMP',
'Reference Land Surface Temperature',
'K', &
3280 'XYT', boundary_out_dtype, &
3285 if ( multi_ocean )
then
3287 'OCEAN_TEMP',
'Reference Ocean Temperature',
'K', &
3288 'OXYT', boundary_out_dtype, &
3292 'OCEAN_SFC_TEMP',
'Reference Ocean Surface Temperature',
'K', &
3293 'XYT', boundary_out_dtype, &
3297 'OCEAN_SFC_Z0',
'Reference Ocean Surface Z0',
'm', &
3298 'XYT', boundary_out_dtype, &
3306 end subroutine boundarysurfacesetup
3310 subroutine parentsurfaceinput( &
3311 tg, strg, lst, albg, &
3312 tc_urb, qc_urb, uc_urb, ust, albu, &
3315 lmask_org, omask_org, &
3316 tw, sst, albw, z0w, &
3317 basename_land, basename_ocean, &
3318 mdlid_land, mdlid_ocean, &
3320 use_file_landwater, &
3321 init_landwater_ratio, &
3322 ! init_landwater_ratio_each, &
3323 init_ocean_alb_lw, &
3324 init_ocean_alb_sw, &
3327 soilwater_ds2vc_flag, &
3328 elevation_correction_land, &
3329 elevation_correction_ocean, &
3333 DENS, MOMX, MOMY, RHOT, QTRC )
3363 real(
rp),
intent(inout) :: tg (
lka,
ia,
ja)
3364 real(
rp),
intent(inout) :: strg(
lka,
ia,
ja)
3365 real(
rp),
intent(inout) :: lst (
ia,
ja)
3367 real(
rp),
intent(inout) :: tc_urb(
ia,
ja)
3368 real(
rp),
intent(inout) :: qc_urb(
ia,
ja)
3369 real(
rp),
intent(inout) :: uc_urb(
ia,
ja)
3370 real(
rp),
intent(inout) :: ust (
ia,
ja)
3372 real(
rp),
intent(inout) :: lst_ocean(oia_org,oja_org)
3373 real(
rp),
intent(inout) :: tw (
ia,
ja)
3374 real(
rp),
intent(inout) :: lz_org(lka_org)
3375 real(
rp),
intent(inout) :: topo_org(lia_org,lja_org)
3376 real(
rp),
intent(inout) :: lmask_org(lia_org,lja_org)
3377 real(
rp),
intent(inout) :: omask_org(oia_org,oja_org)
3378 real(
rp),
intent(out) :: sst (
ia,
ja)
3380 real(
rp),
intent(out) :: z0w (
ia,
ja)
3381 character(len=*),
intent(in) :: basename_land
3382 character(len=*),
intent(in) :: basename_ocean
3383 integer,
intent(in) :: mdlid_land
3384 integer,
intent(in) :: mdlid_ocean
3385 integer,
intent(in) :: ldims(3)
3386 integer,
intent(in) :: odims(2)
3387 logical,
intent(in) :: use_file_landwater
3388 real(
rp),
intent(in) :: init_landwater_ratio
3391 real(
rp),
intent(in) :: init_ocean_alb_lw
3392 real(
rp),
intent(in) :: init_ocean_alb_sw
3393 real(
rp),
intent(in) :: init_ocean_z0w
3394 integer,
intent(in) :: intrp_iter_max
3395 logical,
intent(in) :: soilwater_ds2vc_flag
3396 logical,
intent(in) :: elevation_correction_land
3397 logical,
intent(in) :: elevation_correction_ocean
3398 integer,
intent(in) :: oistep
3399 integer,
intent(in) :: listep
3400 logical,
intent(in) :: multi_land
3401 logical,
intent(in) :: urban_do
3403 real(
rp),
intent(in) :: dens(
ka,
ia,
ja)
3404 real(
rp),
intent(in) :: momx(
ka,
ia,
ja)
3405 real(
rp),
intent(in) :: momy(
ka,
ia,
ja)
3406 real(
rp),
intent(in) :: rhot(
ka,
ia,
ja)
3410 real(
rp) :: tg_org (lka_org,lia_org,lja_org)
3411 real(
rp) :: strg_org (lka_org,lia_org,lja_org)
3412 real(
rp) :: smds_org (lka_org,lia_org,lja_org)
3413 real(
rp) :: lst_org ( lia_org,lja_org)
3414 real(
rp) :: ust_org ( lia_org,lja_org)
3418 real(
rp) :: tw_org (oia_org,oja_org)
3419 real(
rp) :: sst_org (oia_org,oja_org)
3420 real(
rp) :: z0w_org (oia_org,oja_org)
3422 real(
rp) :: omask (oia_org,oja_org)
3425 real(
rp) :: work(lia_org,lja_org)
3432 if ( do_read_land .and. ( first_surface .or. multi_land ) )
then
3434 select case( mdlid_land )
3438 lka_org, lks_org, lke_org, &
3439 lia_org, lis_org, lie_org, &
3440 lja_org, ljs_org, lje_org, &
3442 lst_org, ust_org, albg_org, &
3443 topo_org, lmask_org, &
3445 use_file_landwater, &
3452 lka_org, lks_org, lke_org, &
3453 lia_org, lis_org, lie_org, &
3454 lja_org, ljs_org, lje_org, &
3455 tg_org, strg_org, smds_org, &
3458 topo_org, lmask_org, &
3462 use_file_landwater, &
3475 if ( serial_land .and. ( first_surface .or. multi_land ) )
then
3476 call comm_bcast( lka_org, lia_org, lja_org, tg_org )
3477 if ( use_waterratio )
then
3478 call comm_bcast( lka_org, lia_org, lja_org, smds_org )
3480 call comm_bcast( lka_org, lia_org, lja_org, strg_org )
3482 call comm_bcast( lia_org, lja_org, lst_org )
3483 if ( urban_do )
call comm_bcast( lia_org, lja_org, ust_org )
3485 call comm_bcast( lia_org, lja_org, topo_org )
3486 call comm_bcast( lia_org, lja_org, lmask_org )
3487 call comm_bcast( lka_org, lz_org )
3494 if ( do_read_ocean )
then
3496 select case( mdlid_ocean )
3500 oia_org, ois_org, oie_org, &
3501 oja_org, ojs_org, oje_org, &
3503 albw_org, z0w_org, &
3511 oia_org, ois_org, oie_org, &
3512 oja_org, ojs_org, oje_org, &
3515 basename_ocean, odims, &
3528 if ( serial_ocean )
then
3529 call comm_bcast( oia_org, oja_org, tw_org )
3530 call comm_bcast( oia_org, oja_org, sst_org )
3533 call comm_bcast( oia_org, oja_org, z0w_org )
3534 call comm_bcast( oia_org, oja_org, omask_org )
3541 if ( first_surface )
then
3543 if ( lia_org .ne. oia_org &
3544 .or. lja_org .ne. oja_org )
then
3548 outer:
do j = 1, lja_org
3550 if ( llon_org(i,j) .ne. olon_org(i,j) &
3551 .or. llat_org(i,j) .ne. olat_org(i,j) )
then
3559 if ( ol_interp )
then
3561 call interp_factor2d( itp_nh_ol, &
3576 if ( i_intrp_ocean_temp .ne. i_intrp_off )
then
3577 select case( i_intrp_ocean_temp )
3578 case( i_intrp_mask )
3579 call make_mask( omask, tw_org, oia_org, oja_org, landdata=.false.)
3583 if ( omask_org(i,j) .ne. undef ) omask(i,j) = omask_org(i,j)
3586 case( i_intrp_fill )
3587 call make_mask( omask, tw_org, oia_org, oja_org, landdata=.false.)
3589 call interp_oceanland_data(tw_org, omask, oia_org, oja_org, .false., intrp_iter_max)
3593 if ( i_intrp_ocean_sfc_temp .ne. i_intrp_off )
then
3594 select case( i_intrp_ocean_sfc_temp )
3595 case( i_intrp_mask )
3596 call make_mask( omask, sst_org, oia_org, oja_org, landdata=.false.)
3600 if ( omask_org(i,j) .ne. undef ) omask(i,j) = omask_org(i,j)
3603 case( i_intrp_fill )
3604 call make_mask( omask, sst_org, oia_org, oja_org, landdata=.false.)
3606 call interp_oceanland_data(sst_org, omask, oia_org, oja_org, .false., intrp_iter_max)
3609 if ( first_surface .or. multi_land )
then
3612 lka_org, lia_org, lja_org, &
3614 tg(:,:,:), strg(:,:,:), &
3615 lst(:,:), albg(:,:,:,:), &
3616 tg_org, strg_org, smds_org, &
3617 lst_org, albg_org, &
3622 lz_org, llon_org, llat_org, &
3623 lcz, cx, cy, lon, lat, &
3624 maskval_tg, maskval_strg, &
3625 init_landwater_ratio, &
3627 use_file_landwater, &
3629 soilwater_ds2vc_flag, &
3630 elevation_correction_land, &
3637 if ( topo_org(i,j) > undef )
then
3638 work(i,j) = lst_org(i,j) + topo_org(i,j) * laps
3640 work(i,j) = lst_org(i,j)
3645 if ( ol_interp )
then
3659 lst_ocean(i,j) = work(i,j)
3670 sst_org(:,:), tw_org(:,:), &
3671 albw_org(:,:,:,:), z0w_org(:,:), &
3673 elevation_correction_ocean, &
3674 init_ocean_alb_lw, init_ocean_alb_sw, &
3677 sst(:,:), tw(:,:), &
3678 albw(:,:,:,:), z0w(:,:) )
3681 if ( first_surface .or. multi_land )
then
3686 if( abs(lsmask_nest(i,j)-0.0_rp) < eps )
then
3694 if ( urban_do .and. first_surface )
then
3696 dens, momx, momy, rhot, qtrc, &
3697 tc_urb(:,:), qc_urb(:,:), uc_urb(:,:), &
3698 ust(:,:), albu(:,:,:,:) )
3702 first_surface = .false.
3708 end subroutine parentsurfaceinput
3712 subroutine boundarysurfaceoutput( &
3732 file_cartesc_write_var
3738 real(
rp),
intent(in) :: strg(
lka,
ia,
ja,1)
3739 real(
rp),
intent(in) :: lst(
ia,
ja,1)
3740 real(
rp),
intent(in) :: tw(1,
ia,
ja,1)
3741 real(
rp),
intent(in) :: sst(
ia,
ja,1)
3742 real(
rp),
intent(in) :: z0(
ia,
ja,1)
3743 logical,
intent(in) :: multi_ocean
3744 logical,
intent(in) :: multi_land
3745 integer,
intent(in) :: fid
3746 integer,
intent(in) :: vid(10)
3747 real(
dp),
intent(in) :: timeintv
3748 integer,
intent(in) :: istep
3755 timeofs = (istep - 1) * timeintv
3757 if ( multi_land )
then
3758 call file_cartesc_write_var( fid, vid(1), tg(:,:,:,:),
'LAND_TEMP',
'LXYT', timeintv, timeofs=timeofs )
3759 call file_cartesc_write_var( fid, vid(2), strg(:,:,:,:),
'LAND_WATER',
'LXYT', timeintv, timeofs=timeofs )
3760 call file_cartesc_write_var( fid, vid(3), lst(:,:,:),
'LAND_SFC_TEMP',
'XYT', timeintv, timeofs=timeofs )
3763 if ( multi_ocean )
then
3764 call file_cartesc_write_var( fid, vid(6), tw(:,:,:,:),
'OCEAN_TEMP',
'OXYT', timeintv, timeofs=timeofs )
3765 call file_cartesc_write_var( fid, vid(7), sst(:,:,:),
'OCEAN_SFC_TEMP',
'XYT', timeintv, timeofs=timeofs )
3766 call file_cartesc_write_var( fid, vid(10), z0(:,:,:),
' OCEAN_SFC_Z0',
'XYT', timeintv, timeofs=timeofs )
3772 end subroutine boundarysurfaceoutput
3777 kmax, imax, jmax, oimax,ojmax, &
3778 tg, strg, lst, albg, &
3779 tg_org, strg_org, smds_org, &
3780 lst_org, albg_org, &
3782 lmask_org, lsmask_nest, &
3784 lz_org, llon_org, llat_org, &
3787 maskval_tg, maskval_strg, &
3788 init_landwater_ratio, &
3789 ! init_landwater_ratio_each, &
3790 use_file_landwater, &
3792 soilwater_ds2vc_flag, &
3793 elevation_correction, &
3811 mapprojection_lonlat2xy
3825 integer,
intent(in) :: kmax, imax, jmax
3826 integer,
intent(in) :: oimax, ojmax
3827 real(RP),
intent(out) :: tg(LKMAX,IA,JA)
3828 real(RP),
intent(out) :: strg(LKMAX,IA,JA)
3829 real(RP),
intent(out) :: lst(IA,JA)
3830 real(RP),
intent(out) :: albg(IA,JA,N_RAD_DIR,N_RAD_RGN)
3831 real(RP),
intent(inout) :: tg_org(kmax,imax,jmax)
3832 real(RP),
intent(inout) :: strg_org(kmax,imax,jmax)
3833 real(RP),
intent(inout) :: smds_org(kmax,imax,jmax)
3834 real(RP),
intent(inout) :: lst_org(imax,jmax)
3835 real(RP),
intent(inout) :: albg_org(imax,jmax,N_RAD_DIR,N_RAD_RGN)
3836 real(RP),
intent(inout) :: sst_org(oimax,ojmax)
3837 real(RP),
intent(in) :: lmask_org(imax,jmax)
3838 real(RP),
intent(in) :: lsmask_nest(IA,JA)
3839 real(RP),
intent(in) :: topo_org(imax,jmax)
3840 real(RP),
intent(in) :: lz_org(kmax)
3841 real(RP),
intent(in) :: llon_org(imax,jmax)
3842 real(RP),
intent(in) :: llat_org(imax,jmax)
3843 real(RP),
intent(in) :: LCZ(LKMAX)
3844 real(RP),
intent(in) :: CX(IA)
3845 real(RP),
intent(in) :: CY(JA)
3846 real(RP),
intent(in) :: LON(IA,JA)
3847 real(RP),
intent(in) :: LAT(IA,JA)
3848 real(RP),
intent(in) :: maskval_tg
3849 real(RP),
intent(in) :: maskval_strg
3850 real(RP),
intent(in) :: init_landwater_ratio
3852 logical,
intent(in) :: use_file_landwater
3853 logical,
intent(in) :: use_waterratio
3854 logical,
intent(in) :: soilwater_ds2vc_flag
3855 logical,
intent(in) :: elevation_correction
3856 integer,
intent(in) :: intrp_iter_max
3857 logical,
intent(in) :: ol_interp
3859 real(RP) :: lmask(imax,jmax)
3860 real(RP) :: smds(LKMAX,IA,JA)
3863 real(RP) :: hfact_l(imax,jmax,itp_nh_ol)
3864 integer :: igrd_l (imax,jmax,itp_nh_ol)
3865 integer :: jgrd_l (imax,jmax,itp_nh_ol)
3866 real(RP) :: lX_org (imax,jmax)
3867 real(RP) :: lY_org (imax,jmax)
3868 logical :: zonal, pole
3869 integer :: igrd ( IA,JA,itp_nh_l)
3870 integer :: jgrd ( IA,JA,itp_nh_l)
3871 real(RP) :: hfact( IA,JA,itp_nh_l)
3872 integer :: kgrdl (LKMAX,2,IA,JA,itp_nh_l)
3873 real(RP) :: vfactl(LKMAX, IA,JA,itp_nh_l)
3876 real(RP) :: sst_land(imax,jmax)
3877 real(RP) :: work (imax,jmax)
3878 real(RP) :: work2(imax,jmax)
3880 real(RP) :: lz3d_org(kmax,imax,jmax)
3881 real(RP) :: lcz_3D(LKMAX,IA,JA)
3884 real(RP) :: topo(IA,JA)
3887 real(RP) :: one2d(IA,JA)
3888 real(RP) :: one3d(LKMAX,IA,JA)
3890 integer :: k, i, j, m, n
3894 if ( i_intrp_land_sfc_temp .ne. i_intrp_off )
then
3895 select case( i_intrp_land_sfc_temp )
3896 case( i_intrp_mask )
3897 call make_mask( lmask, lst_org, imax, jmax, landdata=.true.)
3901 if ( lmask_org(i,j) .ne. undef ) lmask(i,j) = lmask_org(i,j)
3904 case( i_intrp_fill )
3905 call make_mask( lmask, lst_org, imax, jmax, landdata=.true.)
3907 log_error(
"land_interporation",*)
'INTRP_LAND_SFC_TEMP is invalid.'
3910 call interp_oceanland_data(lst_org, lmask, imax, jmax, .true., intrp_iter_max)
3913 if ( ol_interp )
then
3915 call interp_factor2d( itp_nh_ol, &
3939 sst_land(i,j) = sst_org(i,j)
3947 if ( topo_org(i,j) > undef + eps )
then
3948 sst_land(i,j) = sst_land(i,j) - topo_org(i,j) * laps
3963 if( albg_org(i,j,m,
i_r_ir ) == undef ) albg_org(i,j,m,
i_r_ir ) = 0.03_rp
3964 if( albg_org(i,j,m,
i_r_nir) == undef ) albg_org(i,j,m,
i_r_nir) = 0.22_rp
3965 if( albg_org(i,j,m,
i_r_vis) == undef ) albg_org(i,j,m,
i_r_vis) = 0.22_rp
3971 if ( i_intrp_land_temp .ne. i_intrp_off )
then
3976 work(i,j) = tg_org(k,i,j)
3979 select case( i_intrp_land_temp )
3980 case( i_intrp_mask )
3981 call make_mask( lmask, work, imax, jmax, landdata=.true.)
3985 if ( lmask_org(i,j) .ne. undef ) lmask(i,j) = lmask_org(i,j)
3988 case( i_intrp_fill )
3989 call make_mask( lmask, work, imax, jmax, landdata=.true.)
3991 call interp_oceanland_data( work, lmask, imax, jmax, .true., intrp_iter_max )
3997 tg_org(k,i,j) = work(i,j)
4008 lz3d_org(:,i,j) = lz_org(:)
4015 lcz_3d(:,i,j) = lcz(:)
4019 select case( itp_type_l )
4020 case ( i_intrp_linear )
4022 if ( imax == 1 .or. jmax == 1 )
then
4023 log_error(
"land_interporation",*)
'LINER interpolation requires nx, ny > 1'
4024 log_error_cont(*)
'Use "DIST-WEIGHT" as INTRP_TYPE of PARAM_MKINIT_REAL_LAND'
4031 work(i,j) = sign( min( abs(llat_org(i,j)), pi * 0.499999_rp ), llat_org(i,j) )
4035 call mapprojection_lonlat2xy( imax, 1, imax, jmax, 1, jmax, &
4036 llon_org(:,:), work(:,:), &
4037 lx_org(:,:), ly_org(:,:) )
4039 zonal = ( maxval(llon_org) - minval(llon_org) ) > 2.0_rp * pi * 0.9_rp
4040 pole = ( maxval(llat_org) > pi * 0.5_rp * 0.9_rp ) .or. ( minval(llat_org) < - pi * 0.5_rp * 0.9_rp )
4041 call interp_factor3d( kmax, 1, kmax, &
4055 flag_extrap = .true., &
4059 case ( i_intrp_dstwgt )
4061 call interp_factor3d( itp_nh_l, &
4069 lon(:,:), lat(:,:), &
4076 flag_extrap = .true. )
4088 if ( filter_niter > 0 )
then
4090 lst(:,:), filter_order, filter_niter )
4091 call comm_vars8( lst(:,:), 1 )
4092 call comm_wait ( lst(:,:), 1, .false. )
4096 if ( filter_niter > 0 )
then
4114 albg_org(:,:,m,n), &
4116 if ( filter_niter > 0 )
then
4118 albg(:,:,m,n), filter_order, filter_niter, &
4119 limiter_sign = one2d(:,:) )
4120 call comm_vars8( albg(:,:,m,n), 1 )
4121 call comm_wait ( albg(:,:,m,n), 1, .false. )
4144 tg(lkmax,i,j) = tg(lkmax-1,i,j)
4152 if ( filter_niter > 0 )
then
4153 call filter_hyperdiff( lkmax, 1, lkmax, ia,
isb,
ieb, ja,
jsb,
jeb, &
4154 tg(:,:,:), filter_order, filter_niter )
4155 call comm_vars8( tg(:,:,:), 1 )
4156 call comm_wait ( tg(:,:,:), 1, .false. )
4161 if ( elevation_correction )
then
4170 if ( filter_niter > 0 )
then
4172 topo(:,:), filter_order, filter_niter )
4173 call comm_vars8( topo(:,:), 1 )
4174 call comm_wait ( topo(:,:), 1, .false. )
4181 if ( topo(i,j) > undef + eps )
then
4183 lst(i,j) = lst(i,j) - tdiff
4185 tg(k,i,j) = tg(k,i,j) - tdiff
4196 if( use_file_landwater )
then
4198 if ( use_waterratio )
then
4200 if ( i_intrp_land_water .ne. i_intrp_off )
then
4205 work(i,j) = smds_org(k,i,j)
4208 select case( i_intrp_land_water )
4209 case( i_intrp_mask )
4210 call make_mask( lmask, work, imax, jmax, landdata=.true.)
4214 if ( lmask_org(i,j) .ne. undef ) lmask(i,j) = lmask_org(i,j)
4217 case( i_intrp_fill )
4218 call make_mask( lmask, work, imax, jmax, landdata=.true.)
4220 call interp_oceanland_data(work, lmask, imax, jmax, .true., intrp_iter_max)
4225 work2(i,j) = init_landwater_ratio
4233 smds_org(k,i,j) = work(i,j)
4255 strg(k,:,:) =
convert_ws2vwc( smds(k,:,:), critical=soilwater_ds2vc_flag )
4260 if ( i_intrp_land_water .ne. i_intrp_off )
then
4265 work(i,j) = strg_org(k,i,j)
4268 select case( i_intrp_land_water )
4269 case( i_intrp_mask )
4270 call make_mask( lmask, work, imax, jmax, landdata=.true.)
4274 if ( lmask_org(i,j) .ne. undef ) lmask(i,j) = lmask_org(i,j)
4277 case( i_intrp_fill )
4278 call make_mask( lmask, work, imax, jmax, landdata=.true.)
4280 call interp_oceanland_data(work, lmask, imax, jmax, .true., intrp_iter_max)
4284 lmask(i,j) = maskval_strg
4292 strg_org(k,i,j) = work(i,j)
4323 strg(k,i,j) = max( min( strg(k,i,j), 1.0_rp ), 0.0_rp )
4328 if ( filter_niter > 0 )
then
4333 one3d(k,i,j) = 1.0_rp
4337 call filter_hyperdiff( lkmax, 1, lkmax-1, ia,
isb,
ieb, ja,
jsb,
jeb, &
4338 strg(:,:,:), filter_order, filter_niter, &
4339 limiter_sign = one3d(:,:,:) )
4340 call comm_vars8( strg(:,:,:), 1 )
4341 call comm_wait ( strg(:,:,:), 1, .false. )
4347 strg(lkmax,i,j) = strg(lkmax-1,i,j)
4358 work(i,j) = init_landwater_ratio
4362 strg(k,:,:) =
convert_ws2vwc( work(:,:), critical=soilwater_ds2vc_flag )
4373 sst_org, tw_org, albw_org, z0w_org, &
4375 elevation_correction_ocean, &
4376 init_ocean_alb_lw, init_ocean_alb_sw, &
4379 sst, tw, albw, z0w )
4392 mapprojection_lonlat2xy
4397 integer,
intent(in) :: imax, jmax
4398 real(RP),
intent(in) :: sst_org (imax,jmax)
4399 real(RP),
intent(in) :: tw_org (imax,jmax)
4400 real(RP),
intent(inout) :: albw_org(imax,jmax,N_RAD_DIR,N_RAD_RGN)
4401 real(RP),
intent(inout) :: z0w_org (imax,jmax)
4402 real(RP),
intent(in) :: CX(IA)
4403 real(RP),
intent(in) :: CY(JA)
4404 logical,
intent(in) :: elevation_correction_ocean
4405 real(RP),
intent(in) :: init_ocean_alb_lw
4406 real(RP),
intent(in) :: init_ocean_alb_sw
4407 real(RP),
intent(in) :: init_ocean_z0w
4408 logical,
intent(in) :: first_surface
4410 real(RP),
intent(out) :: sst (IA,JA)
4411 real(RP),
intent(out) :: tw (IA,JA)
4412 real(RP),
intent(out) :: albw(IA,JA,N_RAD_DIR,N_RAD_RGN)
4413 real(RP),
intent(out) :: z0w (IA,JA)
4416 real(RP) :: oX_org(imax,jmax)
4417 real(RP) :: oY_org(imax,jmax)
4418 logical :: zonal, pole
4420 real(RP) :: one(IA,JA)
4423 integer :: i, j, m, n
4429 if ( albw_org(i,j,m,
i_r_ir ) == undef ) albw_org(i,j,m,
i_r_ir ) = init_ocean_alb_lw
4430 if ( albw_org(i,j,m,
i_r_nir) == undef ) albw_org(i,j,m,
i_r_nir) = init_ocean_alb_sw
4431 if ( albw_org(i,j,m,
i_r_vis) == undef ) albw_org(i,j,m,
i_r_vis) = init_ocean_alb_sw
4432 if ( albw_org(i,j,m,
i_r_vis) == undef ) albw_org(i,j,m,
i_r_vis) = init_ocean_alb_sw
4434 if ( z0w_org(i,j) == undef ) z0w_org(i,j) = init_ocean_z0w
4438 if ( first_surface )
then
4442 select case( itp_type_a )
4443 case ( i_intrp_linear )
4445 if ( imax == 1 .or. jmax == 1 )
then
4446 log_error(
"ocean_interporation",*)
'LINER interpolation requires nx, ny > 1'
4447 log_error_cont(*)
'Use "DIST-WEIGHT" as INTRP_TYPE of PARAM_MKINIT_REAL_OCEAN'
4454 olat_org(i,j) = sign( min( abs(olat_org(i,j)), pi * 0.499999_rp ), olat_org(i,j) )
4458 call mapprojection_lonlat2xy( imax, 1, imax, jmax, 1, jmax, &
4459 olon_org(:,:), olat_org(:,:), &
4460 ox_org(:,:), oy_org(:,:) )
4462 zonal = ( maxval(olon_org) - minval(olon_org) ) > 2.0_rp * pi * 0.9_rp
4463 pole = ( maxval(olat_org) > pi * 0.5_rp * 0.9_rp ) .or. ( minval(olat_org) < - pi * 0.5_rp * 0.9_rp )
4464 call interp_factor2d( imax, jmax, &
4475 case ( i_intrp_dstwgt )
4477 call interp_factor2d( itp_nh_o, &
4482 lon(:,:), lat(:,:), &
4500 if ( filter_niter > 0 )
then
4502 tw(:,:), filter_order, filter_niter )
4503 call comm_vars8( tw(:,:), 1 )
4504 call comm_wait ( tw(:,:), 1, .false. )
4515 if ( filter_niter > 0 )
then
4517 sst(:,:), filter_order, filter_niter )
4518 call comm_vars8( sst(:,:), 1 )
4519 call comm_wait ( sst(:,:), 1, .false. )
4523 if ( elevation_correction_ocean )
then
4530 sst(i,j) = sst(i,j) - tdiff
4531 tw(i,j) = tw(i,j) - tdiff
4538 if ( filter_niter > 0 )
then
4556 albw_org(:,:,m,n), &
4558 if ( filter_niter > 0 )
then
4560 albw(:,:,m,n), filter_order, filter_niter, &
4561 limiter_sign = one(:,:) )
4562 call comm_vars8( albw(:,:,m,n), 1 )
4563 call comm_wait ( albw(:,:,m,n), 1, .false. )
4577 if ( filter_niter > 0 )
then
4579 z0w(:,:), filter_order, filter_niter, &
4580 limiter_sign = one(:,:) )
4581 call comm_vars8( z0w(:,:), 1 )
4582 call comm_wait ( z0w(:,:), 1, .false. )
4592 DENS, MOMX, MOMY, RHOT, &
4594 tc_urb, qc_urb, uc_urb, &
4599 thermodyn_specific_heat => atmos_thermodyn_specific_heat, &
4600 thermodyn_rhot2temp_pres => atmos_thermodyn_rhot2temp_pres
4605 real(RP),
intent(in) :: lst (IA,JA)
4606 real(RP),
intent(in) :: albg (IA,JA,N_RAD_DIR,N_RAD_RGN)
4607 real(RP),
intent(in) :: DENS(KA,IA,JA)
4608 real(RP),
intent(in) :: MOMX(KA,IA,JA)
4609 real(RP),
intent(in) :: MOMY(KA,IA,JA)
4610 real(RP),
intent(in) :: RHOT(KA,IA,JA)
4611 real(RP),
intent(in) :: QTRC(KA,IA,JA,QA)
4612 real(RP),
intent(out) :: tc_urb(IA,JA)
4613 real(RP),
intent(out) :: qc_urb(IA,JA)
4614 real(RP),
intent(out) :: uc_urb(IA,JA)
4615 real(RP),
intent(out) :: ust (IA,JA)
4616 real(RP),
intent(out) :: albu (IA,JA,N_RAD_DIR,N_RAD_RGN)
4618 real(RP) :: temp, pres
4632 call thermodyn_specific_heat( qa, &
4635 qdry, rtot, cvtot, cptot )
4636 call thermodyn_rhot2temp_pres( dens(
ks,i,j), rhot(
ks,i,j), rtot, cvtot, cptot, &
4640 if (
i_qv > 0 )
then
4641 qc_urb(i,j) = qtrc(
ks,i,j,
i_qv)
4643 qc_urb(i,j) = 0.0_rp
4651 uc_urb(i,j) = max(sqrt( ( momx(
ks,i,j) / (dens(
ks,i+1, j)+dens(
ks,i,j)) * 2.0_rp )**2.0_rp &
4652 + ( momy(
ks,i,j) / (dens(
ks, i,j+1)+dens(
ks,i,j)) * 2.0_rp )**2.0_rp ), &
4658 uc_urb(ia,j) = max(sqrt( ( momx(
ks,ia,j) / dens(
ks,ia,j ) )**2.0_rp &
4659 + ( momy(
ks,ia,j) / (dens(
ks,ia,j+1)+dens(
ks,ia,j)) * 2.0_rp )**2.0_rp ), &
4664 uc_urb(i,ja) = max(sqrt( ( momx(
ks,i,ja) / (dens(
ks,i+1,ja)+dens(
ks,i,ja)) * 2.0_rp )**2.0_rp &
4665 + ( momy(
ks,i,ja) / dens(
ks,i ,ja) )**2.0_rp ), 0.01_rp)
4667 uc_urb(ia,ja) = max(sqrt( ( momx(
ks,ia,ja) / dens(
ks,ia,ja) )**2.0_rp &
4668 + ( momy(
ks,ia,ja) / dens(
ks,ia,ja) )**2.0_rp ), 0.01_rp)
4670 call comm_vars8( uc_urb, 1 )
4671 call comm_wait ( uc_urb, 1, .false. )
4749 albu(i,j,:,:) = albg(i,j,:,:)
4767 real(RP),
intent(out) :: gmask(:,:)
4768 real(RP),
intent(in) :: data(:,:)
4769 integer,
intent(in) :: nx
4770 integer,
intent(in) :: ny
4771 logical,
intent(in) :: landdata
4797 if( abs(
data(i,j) - undef) < sqrt(eps) )
then
4806 subroutine interp_oceanland_data( &
4818 integer,
intent(in) :: nx
4819 integer,
intent(in) :: ny
4820 real(RP),
intent(inout) :: data (nx,ny)
4821 real(RP),
intent(in) :: lsmask(nx,ny)
4822 logical,
intent(in) :: landdata
4823 integer,
intent(in) :: iter_max
4825 integer :: mask (nx,ny)
4826 integer :: mask_prev(nx,ny)
4827 real(RP) :: data_prev(nx,ny)
4828 real(RP) :: tmp, cnt, sw
4829 integer :: mask_target
4831 integer :: num_land, num_ocean, num_replaced
4832 integer :: istr, iend, jstr, jend
4833 integer :: i, j, ii, jj, ite
4837 log_info(
"interp_OceanLand_data",*)
'Interpolation'
4839 if ( landdata )
then
4840 log_info(
"interp_OceanLand_data",*)
'target mask : LAND'
4843 log_info(
"interp_OceanLand_data",*)
'target mask : OCEAN'
4854 mask(i,j) = int( 0.5_rp - sign(0.5_rp,abs(lsmask(i,j)-1.0_rp)-eps) )
4855 num_land = num_land + ( mask(i,j) )
4856 num_ocean = num_ocean + ( 1-mask(i,j) )
4860 log_progress(
'(1x,A,I3.3,A,2I8)')
'ite=', 0,
', (land,ocean) = ', num_land, num_ocean
4863 do ite = 1, iter_max
4868 mask_prev(i,j) = mask(i,j)
4869 data_prev(i,j) =
data(i,j)
4880 if( mask(i,j) == mask_target ) cycle
4892 sw = 0.5_rp - sign(0.5_rp,real(abs(mask_prev(ii,jj)-mask_target),kind=rp)-eps)
4894 tmp = tmp + sw * data_prev(ii,jj)
4899 if ( cnt >= 3.0_rp )
then
4900 data(i,j) = tmp / cnt
4901 mask(i,j) = mask_target
4903 num_replaced = num_replaced + 1
4909 if ( landdata )
then
4910 num_land = num_land + num_replaced
4911 num_ocean = num_ocean - num_replaced
4913 num_land = num_land - num_replaced
4914 num_ocean = num_ocean + num_replaced
4919 if( num_replaced == 0 )
exit
4923 log_progress(
'(1x,A,I3.3,A,2I8)')
'ite=', ite,
', (land,ocean) = ', num_land, num_ocean
4928 if ( abs(mask(i,j)-mask_target) > eps )
data(i,j) = undef
4934 end subroutine interp_oceanland_data
4941 real(RP),
intent(inout) :: data(:,:)
4942 real(RP),
intent(in) :: maskval
4943 real(RP),
intent(in) :: frac_land(:,:)
4949 if( abs(frac_land(i,j)-0.0_rp) < eps )
then
4964 real(RP),
intent(inout) :: data(:,:)
4965 real(RP),
intent(in) :: maskval(:,:)
4966 integer,
intent(in) :: nx, ny
4967 character(len=*),
intent(in) :: elem
4977 if( abs(
data(i,j) - undef) < sqrt(eps) )
then
4978 if( abs(maskval(i,j) - undef) < sqrt(eps) )
then
4979 log_error(
"replace_misval_map",*)
"data for mask of "//trim(elem)//
"(",i,
",",j,
") includes missing value."
4983 data(i,j) = maskval(i,j)
4990 log_error_cont(*)
"Please check input data of SKINTEMP or SST. "
4998 IS_org, IE_org, JS_org, JE_org, &
5000 LON_min, LON_max, LAT_min, LAT_max, &
5007 integer,
intent(out) :: IS_org
5008 integer,
intent(out) :: IE_org
5009 integer,
intent(out) :: JS_org
5010 integer,
intent(out) :: JE_org
5012 integer,
intent(in) :: IA_org
5013 integer,
intent(in) :: JA_org
5014 real(RP),
intent(in) :: LON_min, LON_max
5015 real(RP),
intent(in) :: LAT_min, LAT_max
5016 real(RP),
intent(in) :: LON_all(IA_org,JA_org)
5017 real(RP),
intent(in) :: LAT_all(IA_org,JA_org)
5019 real(RP) :: min, max
5021 logical :: LON_mask(IA_org)
5022 logical :: LAT_mask(JA_org)
5026 if ( lon_min < minval( lon_all ) .or. lon_max > maxval( lon_all ) )
then
5031 min = maxval( minval( lon_all(:,:), dim=2 ), mask=all( lon_all(:,:) < lon_min, dim=2 ) )
5032 max = minval( maxval( lon_all(:,:), dim=2 ), mask=all( lon_all(:,:) > lon_max, dim=2 ) )
5033 lon_mask(:) = any( lon_all(:,:) - min > -eps, dim=2 ) .AND. any( lon_all(:,:) - max < eps, dim=2 )
5035 if( lon_mask(i) )
then
5040 do i = ia_org, 1, -1
5041 if( lon_mask(i) )
then
5048 if ( lat_min < minval( lat_all ) .or. lat_max > maxval( lat_all ) )
then
5051 log_error(
"get_IJrange",*)
"unexpected error", lat_min, lat_max, minval( lat_all ), maxval( lat_all )
5054 min = maxval( minval( lat_all(:,:), dim=1 ), mask=all( lat_all(:,:) < lat_min, dim=1 ) )
5055 max = minval( maxval( lat_all(:,:), dim=1 ), mask=all( lat_all(:,:) > lat_max, dim=1 ) )
5056 lat_mask(:) = any( lat_all(:,:) - min > -eps, dim=1 ) .AND. any( lat_all(:,:) - max < eps, dim=1 )
5058 if( lat_mask(j) )
then
5063 do j = ja_org, 1, -1
5064 if( lat_mask(j) )
then