57 private :: parentatmossetup
58 private :: parentatmosopen
59 private :: parentatmosinput
60 private :: boundaryatmossetup
61 private :: boundaryatmosoutput
63 private :: parentsurfacesetup
64 private :: parentsurfaceinput
65 private :: parentsurfaceboundary
66 private :: interp_oceanland_data
72 integer,
public,
parameter ::
iscale = 1
75 integer,
public,
parameter ::
igrads = 4
77 integer,
private :: ia_org, is_org, ie_org
78 integer,
private :: ja_org, js_org, je_org
79 integer,
private :: ka_org
81 real(
rp),
private,
allocatable :: lon_org (:,:)
82 real(
rp),
private,
allocatable :: lat_org (:,:)
83 real(
rp),
private,
allocatable :: cz_org (:,:,:)
85 real(
rp),
private,
allocatable :: w_org (:,:,:)
86 real(
rp),
private,
allocatable :: u_org (:,:,:)
87 real(
rp),
private,
allocatable :: v_org (:,:,:)
88 real(
rp),
private,
allocatable :: dens_org(:,:,:)
89 real(
rp),
private,
allocatable :: pott_org(:,:,:)
90 real(
rp),
private,
allocatable :: temp_org(:,:,:)
91 real(
rp),
private,
allocatable :: pres_org(:,:,:)
92 real(
rp),
private,
allocatable :: qtrc_org (:,:,:,:)
93 real(
rp),
private,
allocatable :: qv_org (:,:,:)
94 real(
rp),
private,
allocatable :: qhyd_org (:,:,:,:)
95 real(
rp),
private,
allocatable :: qnum_org (:,:,:,:)
97 real(
rp),
private,
allocatable :: rn222_org(:,:,:)
99 real(
rp),
private,
allocatable :: tw_org (:,:)
100 real(
rp),
private,
allocatable :: sst_org (:,:)
101 real(
rp),
private,
allocatable :: albw_org (:,:,:,:)
102 real(
rp),
private,
allocatable :: olon_org (:,:)
103 real(
rp),
private,
allocatable :: olat_org (:,:)
104 real(
rp),
private,
allocatable :: omask_org(:,:)
106 integer,
private :: itp_nh_a = 4
107 integer,
private :: itp_nh_l = 4
108 integer,
private :: itp_nh_o = 4
109 integer,
private :: itp_nh_ol = 5
111 integer,
private,
parameter :: i_intrp_linear = 0
112 integer,
private,
parameter :: i_intrp_dstwgt = 1
113 integer,
private :: itp_type_a
114 integer,
private :: itp_type_l
115 integer,
private :: itp_type_o
117 integer,
private,
allocatable :: igrd ( :,:,:)
118 integer,
private,
allocatable :: jgrd ( :,:,:)
119 real(
rp),
private,
allocatable :: hfact( :,:,:)
120 integer,
private,
allocatable :: kgrd (:,:,:,:,:)
121 real(
rp),
private,
allocatable :: vfact(:, :,:,:)
123 integer,
private,
allocatable :: oigrd (:,:,:)
124 integer,
private,
allocatable :: ojgrd (:,:,:)
125 real(
rp),
private,
allocatable :: ohfact(:,:,:)
127 logical,
private :: ol_interp
128 real(
rp),
private,
allocatable :: hfact_ol(:,:,:)
129 integer,
private,
allocatable :: igrd_ol (:,:,:)
130 integer,
private,
allocatable :: jgrd_ol (:,:,:)
133 logical,
private :: serial_atmos
134 logical,
private :: serial_land
135 logical,
private :: serial_ocean
136 logical,
private :: read_by_myproc_atmos
137 logical,
private :: do_read_land
138 logical,
private :: do_read_ocean
140 logical,
private :: temp2pott
141 logical,
private :: update_coord
142 logical,
private :: use_waterratio
144 integer,
private,
parameter :: i_intrp_off = 0
145 integer,
private,
parameter :: i_intrp_mask = 1
146 integer,
private,
parameter :: i_intrp_fill = 2
148 integer,
private :: i_intrp_land_temp
149 integer,
private :: i_intrp_land_water
150 integer,
private :: i_intrp_land_sfc_temp
151 integer,
private :: i_intrp_ocean_temp
152 integer,
private :: i_intrp_ocean_sfc_temp
155 real(
rp),
private,
parameter :: maskval_tg = 298.0_rp
156 real(
rp),
private,
parameter :: maskval_strg = 0.02_rp
161 integer,
private :: number_of_files = 1
162 integer,
private :: number_of_tsteps = 1
163 integer,
private :: number_of_skip_tsteps = 0
165 logical,
private :: serial_proc_read = .true.
167 character(len=H_LONG),
private :: filetype_org =
''
168 character(len=H_LONG),
private :: basename_org =
''
169 logical,
private :: basename_add_num = .false.
171 character(len=H_LONG),
private :: basename_boundary =
''
172 logical,
private :: boundary_postfix_timelabel = .false.
173 character(len=H_LONG),
private :: boundary_title =
'SCALE-RM BOUNDARY CONDITION for REAL CASE'
174 character(len=H_SHORT),
private :: boundary_dtype =
'DEFAULT'
175 real(
dp),
private :: boundary_update_dt = 0.0_dp
177 integer,
private :: filter_order = 8
178 integer,
private :: filter_niter = 0
180 logical,
private :: use_file_density = .false.
181 logical,
private :: same_mp_type = .false.
183 character(len=H_SHORT),
private :: intrp_type =
"LINEAR"
187 logical,
private :: first_atmos = .true.
188 logical,
private :: first_surface = .true.
207 atmos_thermodyn_specific_heat
210 logical :: use_sfc_diagnoses = .false.
211 logical :: use_data_under_sfc = .true.
212 logical :: use_nonhydro_dens_boundary = .false.
213 logical :: skip_vertical_range_check = .false.
216 namelist / param_mkinit_real_atmos / &
219 number_of_skip_tsteps, &
225 boundary_postfix_timelabel, &
228 boundary_update_dt, &
232 use_nonhydro_dens_boundary, &
234 use_data_under_sfc, &
237 skip_vertical_range_check
239 character(len=H_LONG) :: basename_mod
240 character(len=H_LONG) :: basename_out_mod
241 character(len=19) :: timelabel
247 integer :: vid_atmos(5+
qa)
267 integer :: ifile, istep, t, tall
268 integer ::
k, i, j, iq
273 log_info(
'REALINPUT_atmos',*)
'Setup'
277 read(
io_fid_conf,nml=param_mkinit_real_atmos,iostat=ierr)
279 log_info(
"REALINPUT_atmos",*)
'Not found namelist. Default used.'
280 elseif( ierr > 0 )
then
281 log_error(
"REALINPUT_atmos",*)
'Not appropriate names in namelist PARAM_MKINIT_REAL_ATMOS. Check!'
284 log_nml(param_mkinit_real_atmos)
286 if ( boundary_update_dt <= 0.0_dp )
then
287 log_error(
"REALINPUT_atmos",*)
'BOUNDARY_UPDATE_DT is necessary in real case preprocess'
291 if ( filetype_org ==
'GrADS' )
then
292 basename_mod = trim(basename_org)
294 if ( number_of_files > 1 .OR. basename_add_num )
then
295 basename_mod = trim(basename_org)//
'_00000'
297 basename_mod = trim(basename_org)
301 select case( intrp_type )
304 itp_type_a = i_intrp_linear
305 case (
"DIST-WEIGHT" )
307 itp_type_a = i_intrp_dstwgt
309 log_error(
"REALINPUT_atmos",*)
'Unsupported type of INTRP_TYPE : ', trim(intrp_type)
310 log_error_cont(*)
' It must be "LINEAR" or "DIST-WEIGHT"'
314 call parentatmossetup( filetype_org, &
321 if ( timelen > 0 )
then
322 number_of_tsteps = timelen
326 log_info(
"REALINPUT_atmos",*)
'Number of temporal data in each file : ', number_of_tsteps
328 do ifile = 1, number_of_files
330 if ( filetype_org ==
'GrADS' )
then
331 if ( number_of_files > 1 .OR. basename_add_num )
then
332 write(basename_mod,
'(A,I5.5)')
'_', ifile-1
337 if ( number_of_files > 1 .OR. basename_add_num )
then
338 write(basename_mod,
'(A,A,I5.5)') trim(basename_org),
'_', ifile-1
340 basename_mod = trim(basename_org)
345 log_info(
"REALINPUT_atmos",*)
'read external data from : ', trim(basename_mod)
347 call parentatmosopen( filetype_org, &
351 do istep = 1, number_of_tsteps
353 tall = number_of_tsteps * (ifile-1) + istep
354 t = tall - number_of_skip_tsteps
357 log_progress(
'(1x,A,I4,A,I5,A,I6,A)') &
358 '[file,step,cons.] = [', ifile,
',', istep,
',', tall,
'] ...skip.'
362 if ( t == 1 .OR. basename_boundary /=
'' )
then
364 log_progress(
'(1x,A,I4,A,I5,A,I6,A)') &
365 '[file,step,cons.] = [', ifile,
',', istep,
',', tall,
']'
368 call parentatmosinput( filetype_org, &
373 use_data_under_sfc, &
375 skip_vertical_range_check, &
388 log_progress(
'(1x,A,I4,A,I5,A,I6,A)') &
389 '[file,step,cons.] = [', ifile,
',', istep,
',', tall,
'] ...skip.'
395 log_info(
"REALINPUT_atmos",*)
'store initial state.'
401 dens(
k,i,j) = dens_in(
k,i,j)
402 momz(
k,i,j) = momz_in(
k,i,j)
403 momx(
k,i,j) = momx_in(
k,i,j)
404 momy(
k,i,j) = momy_in(
k,i,j)
405 rhot(
k,i,j) = rhot_in(
k,i,j)
415 qtrc(
k,i,j,iq) = qtrc_in(
k,i,j,iq)
424 if ( basename_boundary /=
'' )
then
427 if ( boundary_postfix_timelabel )
then
429 basename_out_mod = trim(basename_boundary)//
'_'//trim(timelabel)
431 basename_out_mod = trim(basename_boundary)
434 call boundaryatmossetup( basename_out_mod, &
437 boundary_update_dt, &
442 if ( use_nonhydro_dens_boundary )
then
443 call atmos_thermodyn_specific_heat(
ka,
ks,
ke,
ia, 1,
ia,
ja, 1,
ja,
qa, &
446 qdry(:,:,:), rtot(:,:,:), cvtot(:,:,:), cptot(:,:,:) )
451 dens_in(
k,i,j) = ( pres_in(
k,i,j) / p00 )**( cvtot(
k,i,j) / cptot(
k,i,j) ) * p00 / ( rtot(
k,i,j) * pott_in(
k,i,j) )
457 call boundaryatmosoutput( dens_in(:,:,:), &
465 boundary_update_dt, &
538 logical :: use_file_landwater = .true.
539 real(
rp) :: init_landwater_ratio = 0.5_rp
541 real(
rp) :: init_ocean_alb_lw = 0.04_rp
542 real(
rp) :: init_ocean_alb_sw = 0.10_rp
543 real(
rp) :: init_ocean_z0w = 1.0e-3_rp
544 character(len=H_SHORT) :: intrp_land_temp =
'off'
545 character(len=H_SHORT) :: intrp_land_water =
'off'
546 character(len=H_SHORT) :: intrp_land_sfc_temp =
'off'
547 character(len=H_SHORT) :: intrp_ocean_temp =
'off'
548 character(len=H_SHORT) :: intrp_ocean_sfc_temp =
'off'
549 integer :: intrp_iter_max = 100
550 character(len=H_SHORT) :: soilwater_ds2vc =
'limit'
551 logical :: soilwater_ds2vc_flag
552 logical :: elevation_correction = .true.
553 logical :: elevation_correction_land
554 logical :: elevation_correction_ocean
556 namelist / param_mkinit_real_land / &
559 number_of_skip_tsteps, &
564 boundary_postfix_timelabel, &
566 boundary_update_dt, &
567 use_file_landwater, &
568 init_landwater_ratio, &
573 intrp_land_sfc_temp, &
578 elevation_correction, &
581 namelist / param_mkinit_real_ocean / &
584 number_of_skip_tsteps, &
589 boundary_postfix_timelabel, &
591 boundary_update_dt, &
597 intrp_ocean_sfc_temp, &
603 character(len=H_LONG) :: filetype_land
604 character(len=H_LONG) :: filetype_ocean
605 character(len=H_LONG) :: basename_land
606 character(len=H_LONG) :: basename_ocean
607 character(len=5) :: num =
''
610 real(
rp),
allocatable :: land_temp_org (:,:,:,:)
611 real(
rp),
allocatable :: land_water_org (:,:,:,:)
612 real(
rp),
allocatable :: land_sfc_temp_org (:,:,:)
613 real(
rp),
allocatable :: land_sfc_albedo_org(:,:,:,:,:)
616 real(
rp) :: urban_tc_org(
ia,
ja)
617 real(
rp) :: urban_qc_org(
ia,
ja)
618 real(
rp) :: urban_uc_org(
ia,
ja)
619 real(
rp) :: urban_sfc_temp_org(
ia,
ja)
623 real(
rp),
allocatable :: ocean_temp_org (:,:,:,:)
624 real(
rp),
allocatable :: ocean_sfc_temp_org (:,:,:)
625 real(
rp),
allocatable :: ocean_sfc_albedo_org(:,:,:,:,:)
626 real(
rp),
allocatable :: ocean_sfc_z0_org (:,:,:)
628 integer :: number_of_files_land = 1
629 integer :: number_of_files_ocean = 1
630 integer :: number_of_tsteps_land = 1
631 integer :: number_of_tsteps_ocean = 1
632 integer :: number_of_skip_tsteps_land = 0
633 integer :: number_of_skip_tsteps_ocean = 0
635 character(len=H_LONG) :: basename_boundary_land =
''
636 character(len=H_LONG) :: basename_boundary_ocean =
''
637 logical :: boundary_postfix_timelabel_land = .false.
638 logical :: boundary_postfix_timelabel_ocean = .false.
639 character(len=H_LONG) :: boundary_title_land =
'SCALE-RM BOUNDARY CONDITION for REAL CASE'
640 character(len=H_LONG) :: boundary_title_ocean =
'SCALE-RM BOUNDARY CONDITION for REAL CASE'
641 real(
dp) :: boundary_update_dt_land = 0.0_dp
642 real(
dp) :: boundary_update_dt_ocean = 0.0_dp
643 logical :: basename_add_num_land
644 logical :: basename_add_num_ocean
646 integer :: mdlid_land, mdlid_ocean
647 integer :: ldims(3), odims(2)
649 integer :: totaltimesteps = 1
651 integer :: skip_steps, skip_steps_land
654 character(len=H_LONG) :: basename_out_mod
655 character(len=19) :: timelabel
658 logical :: multi_land
659 logical :: multi_ocean
661 integer :: ns, ne, nsl, nel
662 integer :: idir, irgn
664 integer ::
k, i, j, n
673 if ( .not. land_flag .or. .not.
ocean_do )
then
674 log_error(
"REALINPUT_surface",*)
'OCEAN_ and LAND_DYN_TYPE must be set'
679 log_info(
'REALINPUT_surface',*)
'Setup LAND'
686 read(
io_fid_conf,nml=param_mkinit_real_land,iostat=ierr)
688 log_info(
"REALINPUT_surface",*)
'Not found namelist. Default used.'
689 elseif( ierr > 0 )
then
690 log_error(
"REALINPUT_surface",*)
'Not appropriate names in namelist PARAM_MKINIT_REAL_LAND. Check!'
693 log_nml(param_mkinit_real_land)
695 number_of_files_land = number_of_files
696 number_of_tsteps_land = number_of_tsteps
697 number_of_skip_tsteps_land = number_of_skip_tsteps
698 filetype_land = filetype_org
699 basename_add_num_land = basename_add_num
700 basename_boundary_land = basename_boundary
701 boundary_postfix_timelabel_land = boundary_postfix_timelabel
702 boundary_title_land = boundary_title
703 boundary_update_dt_land = boundary_update_dt
704 elevation_correction_land = elevation_correction
706 if ( filetype_land .ne.
"GrADS" .and. ( number_of_files > 1 .OR. basename_add_num_land ) )
then
707 basename_land = trim(basename_org)//
"_00000"
709 basename_land = trim(basename_org)
724 select case( soilwater_ds2vc )
726 soilwater_ds2vc_flag = .true.
728 soilwater_ds2vc_flag = .false.
730 log_error(
"REALINPUT_surface",*)
'Unsupported SOILWATER_DS2CV TYPE:', trim(soilwater_ds2vc)
734 serial_land = serial_proc_read
736 select case( intrp_type )
739 itp_type_l = i_intrp_linear
740 case (
"DIST-WEIGHT" )
742 itp_type_l = i_intrp_dstwgt
744 log_error(
"REALINPUT_surface",*)
'Unsupported type of INTRP_TYPE : ', trim(intrp_type)
745 log_error_cont(*)
' It must be "LINEAR" or "DIST-WEIGHT"'
752 log_info(
'REALINPUT_surface',*)
'Setup OCEAN'
756 read(
io_fid_conf,nml=param_mkinit_real_ocean,iostat=ierr)
758 log_info(
"REALINPUT_surface",*)
'Not found namelist. Default used.'
759 elseif( ierr > 0 )
then
760 log_error(
"REALINPUT_surface",*)
'Not appropriate names in namelist PARAM_MKINIT_REAL_OCEAN. Check!'
763 log_nml(param_mkinit_real_ocean)
765 number_of_files_ocean = number_of_files
766 number_of_tsteps_ocean = number_of_tsteps
767 number_of_skip_tsteps_ocean = number_of_skip_tsteps
768 filetype_ocean = filetype_org
769 basename_add_num_ocean = basename_add_num
770 basename_boundary_ocean = basename_boundary
771 boundary_postfix_timelabel_ocean = boundary_postfix_timelabel
772 boundary_title_ocean = boundary_title
773 boundary_update_dt_ocean = boundary_update_dt
774 elevation_correction_ocean = elevation_correction
776 if ( filetype_ocean .ne.
"GrADS" .and. ( number_of_files > 1 .OR. basename_add_num_ocean ) )
then
777 basename_ocean = trim(basename_org)//
"_00000"
779 basename_ocean = trim(basename_org)
782 serial_ocean = serial_proc_read
784 select case( intrp_type )
787 itp_type_o = i_intrp_linear
788 case (
"DIST-WEIGHT" )
790 itp_type_o = i_intrp_dstwgt
792 log_error(
"REALINPUT_surface",*)
'Unsupported type of INTRP_TYPE : ', trim(intrp_type)
793 log_error_cont(*)
' It must be "LINEAR" or "DIST-WEIGHT"'
799 multi_land = ( number_of_files_land * number_of_tsteps_land - number_of_skip_tsteps_land ) > 1
800 multi_ocean = basename_boundary_ocean .ne.
''
802 if ( ( multi_land .and. multi_ocean ) .AND. &
803 ( ( number_of_files_land .NE. number_of_files_ocean ) .OR. &
804 ( number_of_tsteps_land .NE. number_of_tsteps_ocean ) .OR. &
805 ( number_of_skip_tsteps_land .NE. number_of_skip_tsteps_ocean ) .OR. &
806 ( basename_boundary_land .NE. basename_boundary_ocean ) .OR. &
807 ( boundary_postfix_timelabel_land .NEQV. boundary_postfix_timelabel_ocean ) .OR. &
808 ( boundary_title_land .NE. boundary_title_ocean ) .OR. &
809 ( boundary_update_dt_land .NE. boundary_update_dt_ocean ) ) )
then
810 log_error(
"REALINPUT_surface",*)
'The following LAND/OCEAN parameters must be consistent due to technical problem:'
811 log_error_cont(*)
' NUMBER_OF_FILES, NUMBER_OF_TSTEPS, NUMBER_OF_SKIP_TSTEPS,'
812 log_error_cont(*)
' BASENAME_BOUNDARY, BOUNDARY_POSTFIX_TIMELABEL, BOUNDARY_TITLE, BOUNDARY_UPDATE_DT.'
816 call parentsurfacesetup( ldims, odims, &
824 use_file_landwater, &
827 intrp_land_sfc_temp, &
829 intrp_ocean_sfc_temp )
831 if ( timelen > 0 )
then
832 number_of_tsteps_ocean = timelen
835 totaltimesteps = number_of_files_ocean * number_of_tsteps_ocean
837 if ( multi_land )
then
838 allocate( land_temp_org(
lkmax,
ia,
ja, 1+number_of_skip_tsteps_land:totaltimesteps) )
839 allocate( land_water_org(
lkmax,
ia,
ja, 1+number_of_skip_tsteps_land:totaltimesteps) )
840 allocate( land_sfc_temp_org(
ia,
ja, 1+number_of_skip_tsteps_land:totaltimesteps) )
843 allocate( land_temp_org(
lkmax,
ia,
ja, 1) )
844 allocate( land_water_org(
lkmax,
ia,
ja, 1) )
845 allocate( land_sfc_temp_org(
ia,
ja, 1) )
849 allocate( ocean_temp_org(
okmax,
ia,
ja, 1+number_of_skip_tsteps_ocean:totaltimesteps) )
850 allocate( ocean_sfc_temp_org(
ia,
ja, 1+number_of_skip_tsteps_ocean:totaltimesteps) )
852 allocate( ocean_sfc_z0_org(
ia,
ja, 1+number_of_skip_tsteps_ocean:totaltimesteps) )
854 if ( mdlid_ocean ==
igrads )
then
859 do n = 1, number_of_files_ocean
861 if ( number_of_files_land > 1 .OR. basename_add_num_land )
then
862 write(num,
'(I5.5)') n-1
863 basename_land = trim(basename_org)//
"_"//num
865 basename_land = trim(basename_org)
867 if ( number_of_files_ocean > 1 .OR. basename_add_num_ocean )
then
868 write(num,
'(I5.5)') n-1
869 basename_ocean = trim(basename_org)//
"_"//num
871 basename_ocean = trim(basename_org)
875 log_info(
"REALINPUT_surface",*)
'Target File Name (Land) : ', trim(basename_land)
876 log_info(
"REALINPUT_surface",*)
'Target File Name (Ocean): ', trim(basename_ocean)
877 log_info(
"REALINPUT_surface",*)
'Time Steps in One File : ', number_of_tsteps
879 ns = number_of_tsteps_ocean * (n - 1) + 1
880 ne = ns + (number_of_tsteps_ocean - 1)
882 if ( ne <= number_of_skip_tsteps_ocean )
then
883 log_info(
"REALINPUT_surface",*)
' SKIP'
887 skip_steps = max(number_of_skip_tsteps_ocean - ns + 1, 0)
888 ns = max(ns, number_of_skip_tsteps_ocean+1)
890 skip_steps_land = max(number_of_skip_tsteps_land - ns + 1, 0)
892 if ( multi_land )
then
901 call parentsurfaceinput( land_temp_org(:,:,:, nsl:nel), &
902 land_water_org(:,:,:, nsl:nel), &
903 land_sfc_temp_org(:,:, nsl:nel), &
904 land_sfc_albedo_org(:,:,:,:,nsl:nel), &
908 urban_sfc_temp_org(:,:), &
909 urban_sfc_albedo_org(:,:,:,:), &
910 ocean_temp_org(
oks,:,:, ns:ne), &
911 ocean_sfc_temp_org( :,:, ns:ne), &
912 ocean_sfc_albedo_org( :,:,:,:,ns:ne), &
913 ocean_sfc_z0_org( :,:, ns:ne), &
914 basename_land, basename_ocean, &
915 mdlid_land, mdlid_ocean, &
917 use_file_landwater, &
918 init_landwater_ratio, &
920 init_ocean_alb_lw, init_ocean_alb_sw, &
923 soilwater_ds2vc_flag, &
924 elevation_correction_land, &
925 elevation_correction_ocean, &
926 multi_land, multi_ocean, &
927 number_of_tsteps_ocean, &
928 skip_steps_land, skip_steps, &
932 if( .not. ( multi_land .or. multi_ocean ) )
exit
938 ns = number_of_skip_tsteps_ocean + 1
939 if ( multi_land )
then
972 land_sfc_albedo(i,j,idir,irgn) = land_sfc_albedo_org(i,j,idir,irgn,nsl)
1001 urban_tr(i,j) = urban_sfc_temp_org(i,j)
1002 urban_tb(i,j) = urban_sfc_temp_org(i,j)
1003 urban_tg(i,j) = urban_sfc_temp_org(i,j)
1040 if( basename_boundary_ocean /=
'' )
then
1041 totaltimesteps = totaltimesteps - number_of_skip_tsteps_ocean
1042 if ( totaltimesteps > 1 )
then
1043 if ( boundary_update_dt_ocean <= 0.0_dp )
then
1044 log_error(
"REALINPUT_surface",*)
'BOUNDARY_UPDATE_DT is necessary in real case preprocess'
1048 if ( boundary_postfix_timelabel_ocean )
then
1050 basename_out_mod = trim(basename_boundary_ocean)//
'_'//trim(timelabel)
1052 basename_out_mod = trim(basename_boundary_ocean)
1055 if ( multi_land )
then
1063 call parentsurfaceboundary( land_temp_org(:,:,:,nsl:nel), &
1064 land_water_org(:,:,:,nsl:nel), &
1065 land_sfc_temp_org( :,:,nsl:nel), &
1066 ocean_temp_org(:,:,:,ns:ne), &
1067 ocean_sfc_temp_org( :,:,ns:ne), &
1068 ocean_sfc_z0_org( :,:,ns:ne), &
1070 boundary_update_dt_ocean, &
1072 boundary_title_ocean, &
1078 deallocate( land_temp_org )
1079 deallocate( land_water_org )
1080 deallocate( land_sfc_temp_org )
1081 deallocate( land_sfc_albedo_org )
1082 deallocate( ocean_temp_org )
1083 deallocate( ocean_sfc_temp_org )
1084 deallocate( ocean_sfc_albedo_org )
1085 deallocate( ocean_sfc_z0_org )
1093 subroutine parentatmossetup( &
1097 use_file_density_in, &
1115 character(len=*),
intent(in) :: inputtype
1116 character(len=*),
intent(in) :: basename
1117 logical,
intent(in) :: serial_in
1118 logical,
intent(in) :: use_file_density_in
1119 integer,
intent(out) :: dims(6)
1120 integer,
intent(out) :: timelen
1123 serial_atmos = serial_in
1124 if ( serial_atmos )
then
1126 read_by_myproc_atmos = .true.
1128 read_by_myproc_atmos = .false.
1131 read_by_myproc_atmos = .true.
1134 select case(inputtype)
1137 serial_atmos = .false.
1138 read_by_myproc_atmos = .true.
1143 use_file_density = use_file_density_in
1145 update_coord = .false.
1149 if ( read_by_myproc_atmos )
then
1155 use_file_density = use_file_density_in
1157 update_coord = .true.
1161 if ( read_by_myproc_atmos )
then
1167 use_file_density = .false.
1169 update_coord = .true.
1185 log_error(
"ParentAtmosSetup",*)
'Unsupported type of input data : ', trim(inputtype)
1190 if ( serial_atmos )
then
1191 call comm_bcast( dims(:), 6 )
1192 call comm_bcast( timelen )
1195 allocate( igrd(
ia,
ja,itp_nh_a) )
1196 allocate( jgrd(
ia,
ja,itp_nh_a) )
1197 allocate( hfact(
ia,
ja,itp_nh_a) )
1198 allocate( kgrd(
ka,2,
ia,
ja,itp_nh_a) )
1199 allocate( vfact(
ka,
ia,
ja,itp_nh_a) )
1202 end subroutine parentatmossetup
1206 subroutine parentatmosopen( &
1227 character(len=*),
intent(in) :: inputtype
1228 character(len=*),
intent(in) :: basename
1229 integer,
intent(in) :: dims(6)
1231 real(
rp),
allocatable :: lon_all(:,:)
1232 real(
rp),
allocatable :: lat_all(:,:)
1234 real(
rp) :: lon_min, lon_max
1235 real(
rp) :: lat_min, lat_max
1237 logical :: lon_mask( dims(2) )
1238 logical :: lat_mask( dims(3) )
1243 select case(inputtype)
1245 ka_org = dims(1) + 2
1249 if( .NOT.
allocated( lon_org ) )
allocate( lon_org( ia_org, ja_org ) )
1250 if( .NOT.
allocated( lat_org ) )
allocate( lat_org( ia_org, ja_org ) )
1251 if( .NOT.
allocated( cz_org ) )
allocate( cz_org( ka_org, ia_org, ja_org ) )
1253 if ( read_by_myproc_atmos )
then
1262 if( .NOT.
allocated( lon_all ) )
allocate( lon_all( dims(2), dims(3) ) )
1263 if( .NOT.
allocated( lat_all ) )
allocate( lat_all( dims(2), dims(3) ) )
1265 if ( read_by_myproc_atmos )
then
1272 if ( serial_atmos )
then
1279 call comm_bcast( lon_all, dims(2), dims(3) )
1280 call comm_bcast( lat_all, dims(2), dims(3) )
1285 lon_min = maxval( minval( lon_all(:,:), dim=2 ), mask=all( lon_all(:,:) < lon_min, dim=2 ) )
1286 lon_max = minval( maxval( lon_all(:,:), dim=2 ), mask=all( lon_all(:,:) > lon_max, dim=2 ) )
1287 lon_mask(:) = any( lon_all(:,:) - lon_min > -eps, dim=2 ) .AND. any( lon_all(:,:) - lon_max < eps, dim=2 )
1289 if( lon_mask(i) ) then; is_org = i; exit;
endif
1291 do i = dims(2), 1, -1
1292 if( lon_mask(i) ) then; ie_org = i; exit;
endif
1298 lat_min = maxval( minval( lat_all(:,:), dim=1 ), mask=all( lat_all(:,:) < lat_min, dim=1 ) )
1299 lat_max = minval( maxval( lat_all(:,:), dim=1 ), mask=all( lat_all(:,:) > lat_max, dim=1 ) )
1300 lat_mask(:) = any( lat_all(:,:) - lat_min > -eps, dim=1 ) .AND. any( lat_all(:,:) - lat_max < eps, dim=1 )
1302 if( lat_mask(j) ) then; js_org = j; exit;
endif
1304 do j = dims(3), 1, -1
1305 if( lat_mask(j) ) then; je_org = j; exit;
endif
1309 ka_org = dims(1) + 2
1310 ia_org = ie_org - is_org + 1
1311 ja_org = je_org - js_org + 1
1313 if( .NOT.
allocated( lon_org ) )
allocate( lon_org( ia_org, ja_org ) )
1314 if( .NOT.
allocated( lat_org ) )
allocate( lat_org( ia_org, ja_org ) )
1315 if( .NOT.
allocated( cz_org ) )
allocate( cz_org( ka_org, ia_org, ja_org ) )
1319 lon_org(i,j) = lon_all(i-1+is_org,j-1+js_org)
1320 lat_org(i,j) = lat_all(i-1+is_org,j-1+js_org)
1325 ka_org = dims(1) + 2
1329 if( .NOT.
allocated( lon_org ) )
allocate( lon_org( ia_org, ja_org ) )
1330 if( .NOT.
allocated( lat_org ) )
allocate( lat_org( ia_org, ja_org ) )
1331 if( .NOT.
allocated( cz_org ) )
allocate( cz_org( ka_org, ia_org, ja_org ) )
1337 if( .NOT.
allocated( w_org ) )
allocate( w_org( ka_org, ia_org, ja_org ) )
1338 if( .NOT.
allocated( u_org ) )
allocate( u_org( ka_org, ia_org, ja_org ) )
1339 if( .NOT.
allocated( v_org ) )
allocate( v_org( ka_org, ia_org, ja_org ) )
1340 if( .NOT.
allocated( pott_org ) )
allocate( pott_org( ka_org, ia_org, ja_org ) )
1341 if( .NOT.
allocated( temp_org ) )
allocate( temp_org( ka_org, ia_org, ja_org ) )
1342 if( .NOT.
allocated( pres_org ) )
allocate( pres_org( ka_org, ia_org, ja_org ) )
1343 if( .NOT.
allocated( dens_org ) )
allocate( dens_org( ka_org, ia_org, ja_org ) )
1344 if( .NOT.
allocated( qtrc_org ) )
allocate( qtrc_org( ka_org, ia_org, ja_org,
qa ) )
1346 if( .NOT.
allocated( qv_org ) )
allocate( qv_org( ka_org, ia_org, ja_org ) )
1347 if( .NOT.
allocated( qhyd_org ) )
allocate( qhyd_org( ka_org, ia_org, ja_org,
n_hyd ) )
1348 if( .NOT.
allocated( qnum_org ) )
allocate( qnum_org( ka_org, ia_org, ja_org,
n_hyd ) )
1349 if( .NOT.
allocated( rn222_org ) )
allocate( rn222_org( ka_org, ia_org, ja_org ) )
1352 end subroutine parentatmosopen
1356 subroutine parentatmosinput( &
1391 thermodyn_qdry => atmos_thermodyn_qdry, &
1392 thermodyn_r => atmos_thermodyn_r, &
1393 thermodyn_cp => atmos_thermodyn_cp, &
1394 thermodyn_temp_pres2pott => atmos_thermodyn_temp_pres2pott
1396 hydrostatic_buildrho_real => atmos_hydrostatic_buildrho_real
1429 mapprojection_lonlat2xy
1434 character(len=*),
intent(in) :: inputtype
1435 character(len=*),
intent(in) :: basename
1436 integer,
intent(in) :: dims(6)
1437 integer,
intent(in) :: istep
1438 logical,
intent(in) :: sfc_diagnoses
1439 logical,
intent(in) :: under_sfc
1440 logical,
intent(in) :: same_mptype
1441 logical,
intent(in) :: skip_vcheck
1442 real(
rp),
intent(out) :: dens(
ka,
ia,
ja)
1443 real(
rp),
intent(out) :: momz(
ka,
ia,
ja)
1444 real(
rp),
intent(out) :: momx(
ka,
ia,
ja)
1445 real(
rp),
intent(out) :: momy(
ka,
ia,
ja)
1446 real(
rp),
intent(out) :: rhot(
ka,
ia,
ja)
1448 real(
rp),
intent(out) :: velz(
ka,
ia,
ja)
1449 real(
rp),
intent(out) :: velx(
ka,
ia,
ja)
1450 real(
rp),
intent(out) :: vely(
ka,
ia,
ja)
1451 real(
rp),
intent(out) :: pott(
ka,
ia,
ja)
1452 real(
rp),
intent(out) :: pres(
ka,
ia,
ja)
1462 real(
rp) :: u_on_map, v_on_map
1464 real(
rp) :: qdry, rtot, cptot
1466 real(
rp) :: x_org(ia_org,ja_org)
1467 real(
rp) :: y_org(ia_org,ja_org)
1468 logical :: zonal, pole
1473 logical :: same_mptype_ = .false.
1474 logical :: qnum_flag = .false.
1479 integer ::
k, i, j, iq
1484 if ( read_by_myproc_atmos )
then
1485 select case(inputtype)
1494 qtrc_org(:,:,:,:), &
1501 same_mptype_ = .true.
1510 qhyd_org(:,:,:,:), &
1516 ka_org, 1, ka_org, &
1517 ia_org, is_org, ie_org, &
1518 ja_org, js_org, je_org, &
1521 same_mptype_ = .false.
1530 qhyd_org(:,:,:,:), &
1531 qnum_org(:,:,:,:), &
1539 same_mptype_ = .false.
1545 dens_org(
k,i,j) = 0.0_rp
1562 if ( .not. same_mptype_ )
then
1567 qtrc_org(
k,i,j,:
qs_mp-1) = 0.0_rp
1568 qtrc_org(
k,i,j,
qe_mp+1:) = 0.0_rp
1572 if ( .not. sfc_diagnoses )
then
1573 if ( qnum_flag )
then
1575 qv_org(:,:,:), qhyd_org(:,:,:,:), &
1577 qnum=qnum_org(:,:,:,:) )
1580 qv_org(:,:,:), qhyd_org(:,:,:,:), &
1590 if ( qv_org(
k,i,j) == undef ) qtrc_org(
k,i,j,
qs_mp:
qe_mp) = undef
1595 if ( qnum_flag )
then
1597 qv_org(:,:,:), qhyd_org(:,:,:,:), &
1599 qnum=qnum_org(:,:,:,:) )
1602 qv_org(:,:,:), qhyd_org(:,:,:,:), &
1613 qtrc_org(
k,i,j,
qs_ch) = rn222_org(
k,i,j)
1619 if ( temp2pott )
then
1625 if ( temp_org(
k,i,j) == undef )
then
1626 pott_org(
k,i,j) = undef
1628 call thermodyn_qdry(
qa, qtrc_org(
k,i,j,:),
tracer_mass(:), qdry )
1629 call thermodyn_r (
qa, qtrc_org(
k,i,j,:),
tracer_r(:), qdry, rtot )
1630 call thermodyn_cp (
qa, qtrc_org(
k,i,j,:),
tracer_cp(:), qdry, cptot )
1631 call thermodyn_temp_pres2pott( temp_org(
k,i,j), pres_org(
k,i,j), cptot, rtot, &
1645 if ( serial_atmos )
then
1646 if ( first_atmos .OR. update_coord )
then
1647 call comm_bcast( lon_org, dims(2), dims(3) )
1648 call comm_bcast( lat_org, dims(2), dims(3) )
1649 call comm_bcast( cz_org, dims(1)+2, dims(2), dims(3) )
1652 call comm_bcast( w_org , dims(1)+2, dims(2), dims(3) )
1653 call comm_bcast( u_org , dims(1)+2, dims(2), dims(3) )
1654 call comm_bcast( v_org , dims(1)+2, dims(2), dims(3) )
1655 call comm_bcast( pott_org, dims(1)+2, dims(2), dims(3) )
1656 call comm_bcast( pres_org, dims(1)+2, dims(2), dims(3) )
1657 call comm_bcast( dens_org, dims(1)+2, dims(2), dims(3) )
1658 call comm_bcast( qtrc_org, dims(1)+2, dims(2), dims(3),
qa )
1669 if ( qtrc_org(
k,i,j,iq) .ne. undef )
then
1670 qtrc_org(
k,i,j,iq) = max( qtrc_org(
k,i,j,iq), 0.0_rp )
1680 if ( first_atmos .OR. update_coord )
then
1690 skip_z = skip_vcheck )
1692 select case( itp_type_a )
1693 case ( i_intrp_linear )
1695 if ( ia_org == 1 .or. ja_org == 1 )
then
1696 log_error(
"ParentAtmosInput",*)
'LINER interpolation requires nx, ny > 1'
1697 log_error_cont(*)
'Use "DIST-WEIGHT" as INTRP_TYPE of PARAM_MKINIT_REAL_ATMOS'
1704 lat_org(i,j) = sign( min( abs(lat_org(i,j)), pi * 0.499999_rp ), lat_org(i,j) )
1708 call mapprojection_lonlat2xy( ia_org, 1, ia_org, &
1709 ja_org, 1, ja_org, &
1715 zonal = ( maxval(lon_org) - minval(lon_org) ) > 2.0_rp * pi * 0.9_rp
1716 pole = ( maxval(lat_org) > pi * 0.5_rp * 0.9_rp ) .or. ( minval(lat_org) < - pi * 0.5_rp * 0.9_rp )
1717 call interp_factor3d( ka_org, 1, ka_org, &
1721 x_org(:,:), y_org(:,:), &
1730 flag_extrap = .false., &
1734 case ( i_intrp_dstwgt )
1736 call interp_factor3d( itp_nh_a, &
1737 ka_org, 1, ka_org, &
1752 flag_extrap = .false. )
1759 ka_org, 1, ka_org, &
1763 igrd(:,:,:), jgrd(:,:,:), &
1767 cz_org(:,:,:), cz(:,:,:), &
1771 threshold_undef = 1.0_rp, &
1772 wsum = wsum(:,:,:), &
1773 val2 = work(:,:,:) )
1780 if ( w(
k,i,j) .ne. undef )
then
1785 do k = kref-1,
ks, -1
1786 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) ) &
1787 + work(
k,i,j) * wsum(
k,i,j)
1790 if ( w(
k,i,j) == undef ) w(
k,i,j) = w(
k-1,i,j)
1794 if ( filter_niter > 0 )
then
1796 w(:,:,:), filter_order, filter_niter )
1797 call comm_vars8( w(:,:,:), 1 )
1798 call comm_wait ( w(:,:,:), 1, .false. )
1802 ka_org, 1, ka_org, &
1806 igrd(:,:,:), jgrd(:,:,:), &
1810 cz_org(:,:,:), cz(:,:,:), &
1814 threshold_undef = 1.0_rp, &
1815 wsum = wsum(:,:,:), &
1816 val2 = work(:,:,:) )
1822 if ( u(
k,i,j) .ne. undef )
then
1827 do k = kref-1,
ks, -1
1828 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) ) &
1829 + work(
k,i,j) * wsum(
k,i,j)
1832 if ( u(
k,i,j) == undef ) u(
k,i,j) = u(
k-1,i,j)
1836 if ( filter_niter > 0 )
then
1838 u(:,:,:), filter_order, filter_niter )
1839 call comm_vars8( u(:,:,:), 1 )
1840 call comm_wait ( u(:,:,:), 1, .false. )
1844 ka_org, 1, ka_org, &
1848 igrd(:,:,:), jgrd(:,:,:), &
1852 cz_org(:,:,:), cz(:,:,:), &
1856 threshold_undef = 1.0_rp, &
1857 wsum = wsum(:,:,:), &
1858 val2 = work(:,:,:) )
1864 if ( v(
k,i,j) .ne. undef )
then
1869 do k = kref-1,
ks, -1
1870 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) ) &
1871 + work(
k,i,j) * wsum(
k,i,j)
1874 if ( v(
k,i,j) == undef ) v(
k,i,j) = v(
k-1,i,j)
1878 if ( filter_niter > 0 )
then
1880 v(:,:,:), filter_order, filter_niter )
1881 call comm_vars8( v(:,:,:), 1 )
1882 call comm_wait ( v(:,:,:), 1, .false. )
1891 u_on_map = u(
k,i,j) * rotc(i,j,1) + v(
k,i,j) * rotc(i,j,2)
1892 v_on_map = -u(
k,i,j) * rotc(i,j,2) + v(
k,i,j) * rotc(i,j,1)
1905 velz(
k,i,j) = 0.5_rp * ( w(
k+1,i,j) + w(
k,i,j) )
1914 velx(
k,i,j) = 0.5_rp * ( u(
k,i+1,j) + u(
k,i,j) )
1923 velx(
k,i,j) = u(
k,i,j)
1931 vely(
k,i,j) = 0.5_rp * ( v(
k,i,j+1) + v(
k,i,j) )
1940 vely(
k,i,j) = v(
k,i,j)
1947 velz( 1:
ks-1,i,j) = 0.0_rp
1948 velz(
ke :
ka ,i,j) = 0.0_rp
1949 velx( 1:
ks-1,i,j) = 0.0_rp
1950 velx(
ke+1:
ka ,i,j) = 0.0_rp
1951 vely( 1:
ks-1,i,j) = 0.0_rp
1952 vely(
ke+1:
ka ,i,j) = 0.0_rp
1956 call comm_vars8( velz(:,:,:), 1 )
1957 call comm_vars8( velx(:,:,:), 2 )
1958 call comm_vars8( vely(:,:,:), 3 )
1959 call comm_wait ( velz(:,:,:), 1, .false. )
1960 call comm_wait ( velx(:,:,:), 2, .false. )
1961 call comm_wait ( vely(:,:,:), 3, .false. )
1964 ka_org, 1, ka_org, &
1968 igrd(:,:,:), jgrd(:,:,:), &
1972 cz_org(:,:,:), cz(:,:,:), &
1976 threshold_undef = 1.0_rp, &
1977 wsum = wsum(:,:,:), &
1978 val2 = work(:,:,:) )
1983 if ( pott(
k,i,j) == undef .and. pott(
k-1,i,j) .ne. undef ) pott(
k,i,j) = pott(
k-1,i,j)
1986 if ( pott(
k,i,j) == undef )
then
1987 pott(
k,i,j) = pott(
k+1,i,j) * ( 1.0_rp - wsum(
k,i,j) ) &
1988 + work(
k,i,j) * wsum(
k,i,j)
1991 pott( 1:
ks-1,i,j) = undef
1992 pott(
ke+1:
ka ,i,j) = undef
1995 if ( filter_niter > 0 )
then
1997 pott(:,:,:), filter_order, filter_niter )
1998 call comm_vars8( pott(:,:,:), 1 )
1999 call comm_wait ( pott(:,:,:), 1, .false. )
2004 ka_org, 1, ka_org, &
2008 igrd(:,:,:), jgrd(:,:,:), &
2012 cz_org(:,:,:), cz(:,:,:), &
2013 qtrc_org(:,:,:,iq), &
2016 threshold_undef = 1.0_rp, &
2017 wsum = wsum(:,:,:), &
2018 val2 = work(:,:,:) )
2023 if ( qtrc(
k,i,j,iq) == undef .and. qtrc(
k-1,i,j,iq) .ne. undef ) qtrc(
k,i,j,iq) = qtrc(
k-1,i,j,iq)
2026 if ( qtrc(
k,i,j,iq) == undef )
then
2027 qtrc(
k,i,j,iq) = qtrc(
k+1,i,j,iq) * ( 1.0_rp - wsum(
k,i,j) ) &
2028 + work(
k,i,j) * wsum(
k,i,j)
2032 qtrc(
k,i,j,iq) = max( qtrc(
k,i,j,iq), 0.0_rp )
2034 qtrc( 1:
ks-1,i,j,iq) = 0.0_rp
2035 qtrc(
ke+1:
ka ,i,j,iq) = 0.0_rp
2038 if ( filter_niter > 0 )
then
2048 qtrc(:,:,:,iq), filter_order, filter_niter, &
2049 limiter_sign = one(:,:,:) )
2050 call comm_vars8( qtrc(:,:,:,iq), 1 )
2051 call comm_wait ( qtrc(:,:,:,iq), 1, .false. )
2056 ka_org, 1, ka_org, &
2093 qv(
k,i,j) = qtrc(
k,i,j,
i_qv)
2095 qc(
k,i,j) = qc(
k,i,j) + qtrc(
k,i,j,iq)
2107 pres2(
k,i,j) = pres(
k,i,j)
2112 if ( use_file_density )
then
2114 ka_org, 1, ka_org, &
2118 igrd(:,:,:), jgrd(:,:,:), &
2122 cz_org(:,:,:), cz(:,:,:), &
2125 threshold_undef = 1.0_rp, &
2126 wsum = wsum(:,:,:), &
2127 val2 = work(:,:,:) )
2128 call hydrostatic_buildrho_real(
ka,
ks,
ke,
ia, 1,
ia,
ja, 1,
ja, &
2129 pott(:,:,:), qv(:,:,:), qc(:,:,:), &
2132 dens2(:,:,:), temp(:,:,:) )
2137 if ( dens(
k,i,j) == undef )
then
2138 dens(
k,i,j) = dens2(
k,i,j) * ( 1.0_rp - wsum(
k,i,j) ) &
2139 + work(
k,i,j) * wsum(
k,i,j)
2146 call hydrostatic_buildrho_real(
ka,
ks,
ke,
ia, 1,
ia,
ja, 1,
ja, &
2147 pott(:,:,:), qv(:,:,:), qc(:,:,:), &
2150 dens(:,:,:), temp(:,:,:) )
2153 if ( filter_niter > 0 )
then
2155 dens(:,:,:), filter_order, filter_niter, &
2156 limiter_sign = one(:,:,:) )
2157 call comm_vars8( dens(:,:,:), 1 )
2158 call comm_wait ( dens(:,:,:), 1, .false. )
2165 if ( pres(
k,i,j) == undef ) pres(
k,i,j) = pres2(
k,i,j)
2174 dens( 1:
ks-1,i,j) = 0.0_rp
2175 dens(
ke+1:
ka ,i,j) = 0.0_rp
2183 momz(
k,i,j) = velz(
k,i,j) * 0.5_rp * ( dens(
k+1,i,j) + dens(
k,i,j) )
2192 momx(
k,i,j) = velx(
k,i,j) * 0.5_rp * ( dens(
k,i+1,j) + dens(
k,i,j) )
2201 momx(
k,i,j) = velx(
k,i,j) * dens(
k,i,j)
2209 momy(
k,i,j) = vely(
k,i,j) * 0.5_rp * ( dens(
k,i,j+1) + dens(
k,i,j) )
2218 momy(
k,i,j) = vely(
k,i,j) * dens(
k,i,j)
2226 rhot(
k,i,j) = pott(
k,i,j) * dens(
k,i,j)
2234 momz( 1:
ks-1,i,j) = 0.0_rp
2235 momz(
ke :
ka ,i,j) = 0.0_rp
2236 momx( 1:
ks-1,i,j) = 0.0_rp
2237 momx(
ke+1:
ka ,i,j) = 0.0_rp
2238 momy( 1:
ks-1,i,j) = 0.0_rp
2239 momy(
ke+1:
ka ,i,j) = 0.0_rp
2243 call comm_vars8( momz(:,:,:), 1 )
2244 call comm_vars8( momx(:,:,:), 2 )
2245 call comm_vars8( momy(:,:,:), 3 )
2246 call comm_wait ( momz(:,:,:), 1, .false. )
2247 call comm_wait ( momx(:,:,:), 2, .false. )
2248 call comm_wait ( momy(:,:,:), 3, .false. )
2250 first_atmos = .false.
2255 end subroutine parentatmosinput
2259 subroutine boundaryatmossetup( &
2280 character(len=*),
intent(in) :: basename
2281 character(len=*),
intent(in) :: title
2282 character(len=*),
intent(in) :: datatype
2283 real(
dp),
intent(in) :: timeintv
2284 integer,
intent(out) :: fid
2285 integer,
intent(out) :: vid(5+
qa)
2293 'DENS',
'Reference Density',
'kg/m3',
'ZXYT', datatype, &
2297 'VELZ',
'Reference VELZ',
'm/s',
'ZHXYT', datatype, &
2301 'VELX',
'Reference VELX',
'm/s',
'ZXHYT', datatype, &
2305 'VELY',
'Reference VELY',
'm/s',
'ZXYHT', datatype, &
2309 'PT',
'Reference PT',
'K',
'ZXYT', datatype, &
2318 timeintv = timeintv )
2326 timeintv = timeintv )
2332 end subroutine boundaryatmossetup
2336 subroutine boundaryatmosoutput( &
2348 file_cartesc_write_var
2357 real(
rp),
intent(in) :: dens(
ka,
ia,
ja)
2358 real(
rp),
intent(in) :: velz(
ka,
ia,
ja)
2359 real(
rp),
intent(in) :: velx(
ka,
ia,
ja)
2360 real(
rp),
intent(in) :: vely(
ka,
ia,
ja)
2361 real(
rp),
intent(in) :: pott(
ka,
ia,
ja)
2363 integer,
intent(in) :: fid
2364 integer,
intent(in) :: vid(5+
qa)
2365 real(
dp),
intent(in) :: timeintv
2366 integer,
intent(in) :: istep
2376 timeofs = real(istep-1,kind=
dp) * timeintv
2379 work(:,:,:,1) = dens(:,:,:)
2380 call file_cartesc_write_var( fid, vid(1), work(:,:,:,:),
'DENS',
'ZXYT', timeintv, timeofs=timeofs )
2382 work(:,:,:,1) = velz(:,:,:)
2383 call file_cartesc_write_var( fid, vid(2), work(:,:,:,:),
'VELZ',
'ZHXYT', timeintv, timeofs=timeofs )
2385 work(:,:,:,1) = velx(:,:,:)
2386 call file_cartesc_write_var( fid, vid(3), work(:,:,:,:),
'VELX',
'ZXHYT', timeintv, timeofs=timeofs )
2388 work(:,:,:,1) = vely(:,:,:)
2389 call file_cartesc_write_var( fid, vid(4), work(:,:,:,:),
'VELY',
'ZXYHT', timeintv, timeofs=timeofs )
2391 work(:,:,:,1) = pott(:,:,:)
2392 call file_cartesc_write_var( fid, vid(5), work(:,:,:,:),
'PT',
'ZXYT', timeintv, timeofs=timeofs )
2395 call file_cartesc_write_var( fid, vid(5+iq),qtrc(:,:,:,iq:iq),
tracer_name(iq), &
2396 'ZXYT', timeintv, timeofs=timeofs )
2400 call file_cartesc_write_var( fid, vid(5+iq),qtrc(:,:,:,iq:iq),
tracer_name(iq), &
2401 'ZXYT', timeintv, timeofs=timeofs )
2407 end subroutine boundaryatmosoutput
2411 subroutine parentsurfacesetup( &
2419 use_file_landwater, &
2422 intrp_land_sfc_temp, &
2424 intrp_ocean_sfc_temp )
2439 integer,
intent(out) :: ldims(3)
2440 integer,
intent(out) :: odims(2)
2441 integer,
intent(out) :: lmdlid
2442 integer,
intent(out) :: omdlid
2443 integer,
intent(out) :: timelen
2444 character(len=*),
intent(in) :: basename_land
2445 character(len=*),
intent(in) :: basename_ocean
2446 character(len=*),
intent(in) :: filetype_land
2447 character(len=*),
intent(in) :: filetype_ocean
2448 logical,
intent(in) :: use_file_landwater
2449 character(len=*),
intent(in) :: intrp_land_temp
2450 character(len=*),
intent(in) :: intrp_land_water
2451 character(len=*),
intent(in) :: intrp_land_sfc_temp
2452 character(len=*),
intent(in) :: intrp_ocean_temp
2453 character(len=*),
intent(in) :: intrp_ocean_sfc_temp
2457 log_info(
"ParentSurfaceSetup",*)
'Setup'
2462 log_error(
"ParentSurfaceSetup",*)
'LKMAX less than 4: ',
lkmax
2463 log_error_cont(*)
'in Real Case, LKMAX should be set more than 4'
2470 if( serial_land )
then
2472 do_read_land = .true.
2474 do_read_land = .false.
2477 do_read_land = .true.
2480 select case(trim(filetype_land))
2484 serial_land = .false.
2485 do_read_land = .true.
2487 use_waterratio = .false.
2494 use_waterratio = .false.
2508 use_file_landwater, &
2513 log_error(
"ParentSurfaceSetup",*)
'Unsupported FILE TYPE:', trim(filetype_land)
2518 if( serial_land )
then
2519 call comm_bcast( ldims(:), 3 )
2520 call comm_bcast( use_waterratio )
2524 select case( intrp_land_temp )
2526 i_intrp_land_temp = i_intrp_off
2528 i_intrp_land_temp = i_intrp_mask
2530 i_intrp_land_temp = i_intrp_fill
2532 log_error(
"ParentSurfaceSetup",*)
'INTRP_LAND_TEMP is invalid. ', intrp_land_temp
2535 select case( intrp_land_sfc_temp )
2537 i_intrp_land_sfc_temp = i_intrp_off
2539 i_intrp_land_sfc_temp = i_intrp_mask
2541 i_intrp_land_sfc_temp = i_intrp_fill
2543 log_error(
"ParentSurfaceSetup",*)
'INTRP_LAND_SFC_TEMP is invalid. ', intrp_land_sfc_temp
2546 select case( intrp_land_water )
2548 i_intrp_land_water = i_intrp_off
2550 i_intrp_land_water = i_intrp_mask
2552 i_intrp_land_water = i_intrp_fill
2554 log_error(
"ParentSurfaceSetup",*)
'INTRP_LAND_WATER is invalid. ', intrp_land_water
2558 select case( lmdlid )
2561 i_intrp_land_temp = i_intrp_mask
2562 i_intrp_land_sfc_temp = i_intrp_mask
2563 i_intrp_land_water = i_intrp_mask
2569 if( serial_ocean )
then
2571 do_read_ocean = .true.
2573 do_read_ocean = .false.
2576 do_read_ocean = .true.
2579 select case(trim(filetype_ocean))
2584 serial_ocean = .false.
2585 do_read_ocean = .true.
2587 update_coord = .false.
2594 update_coord = .true.
2608 update_coord = .false.
2612 log_error(
"ParentSurfaceSetup",*)
'Unsupported FILE TYPE:', trim(filetype_ocean)
2617 if( serial_ocean )
then
2618 call comm_bcast( odims(:), 2 )
2619 call comm_bcast( timelen )
2623 select case( intrp_ocean_temp )
2625 i_intrp_ocean_temp = i_intrp_off
2627 i_intrp_ocean_temp = i_intrp_mask
2629 i_intrp_ocean_temp = i_intrp_fill
2631 log_error(
"ParentSurfaceSetup",*)
'INTRP_OCEAN_TEMP is invalid. ', intrp_ocean_temp
2634 select case( intrp_ocean_sfc_temp )
2636 i_intrp_ocean_sfc_temp = i_intrp_off
2638 i_intrp_ocean_sfc_temp = i_intrp_mask
2640 i_intrp_ocean_sfc_temp = i_intrp_fill
2642 log_error(
"ParentSurfaceSetup",*)
'INTRP_OCEAN_SFC_TEMP is invalid. ', intrp_ocean_sfc_temp
2646 select case( omdlid )
2649 i_intrp_ocean_temp = i_intrp_mask
2650 i_intrp_ocean_sfc_temp = i_intrp_mask
2654 allocate( tw_org(odims(1),odims(2)) )
2655 allocate( sst_org(odims(1),odims(2)) )
2657 allocate( olon_org(odims(1),odims(2)) )
2658 allocate( olat_org(odims(1),odims(2)) )
2659 allocate( omask_org(odims(1),odims(2)) )
2661 allocate( oigrd(
ia,
ja,itp_nh_o) )
2662 allocate( ojgrd(
ia,
ja,itp_nh_o) )
2663 allocate( ohfact(
ia,
ja,itp_nh_o) )
2665 allocate( hfact_ol(odims(1),odims(2),itp_nh_ol) )
2666 allocate( igrd_ol(odims(1),odims(2),itp_nh_ol) )
2667 allocate( jgrd_ol(odims(1),odims(2),itp_nh_ol) )
2670 end subroutine parentsurfacesetup
2674 subroutine parentsurfaceinput( &
2675 tg, strg, lst, albg, &
2676 tc_urb, qc_urb, uc_urb, ust, albu, &
2677 tw, sst, albw, z0w, &
2678 basename_land, basename_ocean, &
2679 mdlid_land, mdlid_ocean, &
2681 use_file_landwater, &
2682 init_landwater_ratio, &
2683 ! init_landwater_ratio_each, &
2684 init_ocean_alb_lw, &
2685 init_ocean_alb_sw, &
2688 soilwater_ds2vc_flag, &
2689 elevation_correction_land, &
2690 elevation_correction_ocean, &
2691 multi_land, multi_ocean, &
2692 timelen, skiplen_land, skiplen, &
2733 real(
rp),
intent(inout) :: tg (:,:,:,:)
2734 real(
rp),
intent(inout) :: strg(:,:,:,:)
2735 real(
rp),
intent(inout) :: lst (:,:,:)
2736 real(
rp),
intent(inout) :: albg(:,:,:,:,:)
2737 real(
rp),
intent(inout) :: tc_urb(
ia,
ja)
2738 real(
rp),
intent(inout) :: qc_urb(
ia,
ja)
2739 real(
rp),
intent(inout) :: uc_urb(
ia,
ja)
2740 real(
rp),
intent(inout) :: ust (
ia,
ja)
2742 real(
rp),
intent(inout) :: tw (:,:,:)
2743 real(
rp),
intent(out) :: sst (:,:,:)
2744 real(
rp),
intent(out) :: albw(:,:,:,:,:)
2745 real(
rp),
intent(out) :: z0w (:,:,:)
2746 character(len=*),
intent(in) :: basename_land
2747 character(len=*),
intent(in) :: basename_ocean
2748 integer,
intent(in) :: mdlid_land
2749 integer,
intent(in) :: mdlid_ocean
2750 integer,
intent(in) :: ldims(3)
2751 integer,
intent(in) :: odims(2)
2752 logical,
intent(in) :: use_file_landwater
2753 real(
rp),
intent(in) :: init_landwater_ratio
2756 real(
rp),
intent(in) :: init_ocean_alb_lw
2757 real(
rp),
intent(in) :: init_ocean_alb_sw
2758 real(
rp),
intent(in) :: init_ocean_z0w
2759 integer,
intent(in) :: intrp_iter_max
2760 logical,
intent(in) :: soilwater_ds2vc_flag
2761 logical,
intent(in) :: elevation_correction_land
2762 logical,
intent(in) :: elevation_correction_ocean
2763 logical,
intent(in) :: multi_land
2764 logical,
intent(in) :: multi_ocean
2765 integer,
intent(in) :: timelen
2766 integer,
intent(in) :: skiplen_land
2767 integer,
intent(in) :: skiplen
2768 logical,
intent(in) :: urban_do
2771 real(
rp) :: tg_org (ldims(1),ldims(2),ldims(3))
2772 real(
rp) :: strg_org (ldims(1),ldims(2),ldims(3))
2773 real(
rp) :: smds_org (ldims(1),ldims(2),ldims(3))
2775 real(
rp) :: lst_org ( ldims(2),ldims(3))
2776 real(
rp) :: ust_org ( ldims(2),ldims(3))
2778 real(
rp) :: topo_org ( ldims(2),ldims(3))
2779 real(
rp) :: lmask_org( ldims(2),ldims(3))
2780 real(
rp) :: lz_org (ldims(1) )
2781 real(
rp) :: llon_org ( ldims(2),ldims(3))
2782 real(
rp) :: llat_org ( ldims(2),ldims(3))
2785 real(
rp) :: z0w_org ( odims(1),odims(2))
2786 real(
rp) :: omask ( odims(1),odims(2))
2787 real(
rp) :: lst_ocean( odims(1),odims(2))
2790 real(
rp) :: work(ldims(2),ldims(3))
2793 integer :: n, nn, nl, nnl
2796 if ( do_read_ocean )
then
2798 select case( mdlid_ocean )
2825 do n = skiplen+1, timelen
2830 if ( do_read_land .and. ( first_surface .or. multi_land ) )
then
2832 if ( multi_land )
then
2835 nl = skiplen_land + 1
2838 select case( mdlid_land )
2843 lst_org, ust_org, albg_org, &
2844 topo_org, lmask_org, &
2845 llon_org, llat_org, lz_org, &
2846 basename_land, ldims, &
2847 use_file_landwater, nl )
2853 lst_org, ust_org, albg_org, &
2854 topo_org, lmask_org, &
2855 llon_org, llat_org, lz_org, &
2856 basename_land, ldims, &
2857 use_file_landwater, nl )
2874 tg_org, strg_org, smds_org, &
2876 llon_org, llat_org, lz_org, &
2877 topo_org, lmask_org, &
2878 basename_land, ldims, &
2879 use_file_landwater, nl )
2891 if ( serial_land .and. ( first_surface .or. multi_land ) )
then
2892 call comm_bcast( tg_org, ldims(1), ldims(2), ldims(3) )
2893 if ( use_waterratio )
then
2894 call comm_bcast( smds_org, ldims(1), ldims(2), ldims(3) )
2896 call comm_bcast( strg_org, ldims(1), ldims(2), ldims(3) )
2898 call comm_bcast( lst_org, ldims(2), ldims(3) )
2899 if ( urban_do )
call comm_bcast( ust_org, ldims(2), ldims(3) )
2906 call comm_bcast( topo_org, ldims(2), ldims(3) )
2907 call comm_bcast( lmask_org, ldims(2), ldims(3) )
2908 call comm_bcast( llon_org, ldims(2), ldims(3) )
2909 call comm_bcast( llat_org, ldims(2), ldims(3) )
2910 call comm_bcast( lz_org, ldims(1) )
2917 if ( do_read_ocean )
then
2919 select case( mdlid_ocean )
2924 albw_org, z0w_org, &
2933 albw_org, z0w_org, &
2935 olon_org, olat_org, &
2936 basename_ocean, odims, &
2954 olon_org, olat_org, &
2955 basename_ocean, odims, &
2968 if ( serial_ocean )
then
2969 call comm_bcast( tw_org, odims(1), odims(2) )
2970 call comm_bcast( sst_org, odims(1), odims(2) )
2977 call comm_bcast( z0w_org, odims(1), odims(2) )
2978 call comm_bcast( omask_org, odims(1), odims(2) )
2979 if ( first_surface .or. update_coord )
then
2980 call comm_bcast( olon_org, odims(1), odims(2) )
2981 call comm_bcast( olat_org, odims(1), odims(2) )
2989 if ( first_surface .or. update_coord )
then
2991 if ( ldims(2) .ne. odims(1) &
2992 .or. ldims(3) .ne. odims(2) )
then
2996 outer:
do j = 1, ldims(3)
2998 if ( llon_org(i,j) .ne. olon_org(i,j) &
2999 .or. llat_org(i,j) .ne. olat_org(i,j) )
then
3007 if ( ol_interp )
then
3009 call interp_factor2d( itp_nh_ol, &
3010 ldims(2), ldims(3), &
3011 odims(1), odims(2), &
3023 if ( i_intrp_ocean_temp .ne. i_intrp_off )
then
3024 select case( i_intrp_ocean_temp )
3025 case( i_intrp_mask )
3026 call make_mask( omask, tw_org, odims(1), odims(2), landdata=.false.)
3030 if ( omask_org(i,j) .ne. undef ) omask(i,j) = omask_org(i,j)
3033 case( i_intrp_fill )
3034 call make_mask( omask, tw_org, odims(1), odims(2), landdata=.false.)
3036 call interp_oceanland_data(tw_org, omask, odims(1), odims(2), .false., intrp_iter_max)
3040 if ( i_intrp_ocean_sfc_temp .ne. i_intrp_off )
then
3041 select case( i_intrp_ocean_sfc_temp )
3042 case( i_intrp_mask )
3043 call make_mask( omask, sst_org, odims(1), odims(2), landdata=.false.)
3047 if ( omask_org(i,j) .ne. undef ) omask(i,j) = omask_org(i,j)
3050 case( i_intrp_fill )
3051 call make_mask( omask, sst_org, odims(1), odims(2), landdata=.false.)
3053 call interp_oceanland_data(sst_org, omask, odims(1), odims(2), .false., intrp_iter_max)
3056 if ( first_surface .or. multi_land )
then
3058 if ( multi_land )
then
3065 ldims(1), ldims(2), ldims(3), &
3066 odims(1), odims(2), &
3067 tg(:,:,:,nnl), strg(:,:,:,nnl), &
3068 lst(:,:,nnl), albg(:,:,:,:,nnl), &
3069 tg_org, strg_org, smds_org, &
3070 lst_org, albg_org, &
3075 lz_org, llon_org, llat_org, &
3076 lcz, cx, cy, lon, lat, &
3077 maskval_tg, maskval_strg, &
3078 init_landwater_ratio, &
3080 use_file_landwater, &
3082 soilwater_ds2vc_flag, &
3083 elevation_correction_land, &
3090 if ( topo_org(i,j) > undef + eps )
then
3091 work(i,j) = lst_org(i,j) + topo_org(i,j) * laps
3093 work(i,j) = lst_org(i,j)
3098 if ( ol_interp )
then
3101 ldims(2), ldims(3), &
3102 odims(1), odims(2), &
3112 lst_ocean(i,j) = work(i,j)
3123 sst_org(:,:), tw_org(:,:), &
3124 albw_org(:,:,:,:), z0w_org(:,:), &
3126 elevation_correction_ocean, &
3127 init_ocean_alb_lw, init_ocean_alb_sw, &
3129 first_surface, update_coord, &
3130 sst(:,:,nn), tw(:,:,nn), &
3131 albw(:,:,:,:,nn), z0w(:,:,nn) )
3134 if ( first_surface .or. multi_land )
then
3135 if ( multi_land )
then
3144 if( abs(lsmask_nest(i,j)-0.0_rp) < eps )
then
3145 lst(i,j,nnl) = sst(i,j,nn)
3152 if ( urban_do .and. first_surface )
then
3153 call urban_input( lst(:,:,nnl), albg(:,:,:,:,nnl), &
3154 tc_urb(:,:), qc_urb(:,:), uc_urb(:,:), &
3155 ust(:,:), albu(:,:,:,:) )
3159 first_surface = .false.
3164 if( .NOT. multi_ocean )
exit
3169 end subroutine parentsurfaceinput
3172 subroutine parentsurfaceboundary( &
3191 file_cartesc_write_var
3196 real(
rp),
intent(in) :: tg(:,:,:,:)
3197 real(
rp),
intent(in) :: strg(:,:,:,:)
3198 real(
rp),
intent(in) :: lst(:,:,:)
3199 real(
rp),
intent(in) :: tw(:,:,:,:)
3200 real(
rp),
intent(in) :: sst(:,:,:)
3201 real(
rp),
intent(in) :: z0(:,:,:)
3202 real(
dp),
intent(in) :: update_dt
3203 character(len=*),
intent(in) :: basename
3204 character(len=*),
intent(in) :: title
3205 integer,
intent(in) :: numsteps
3206 logical,
intent(in) :: multi_land
3208 character(len=H_SHORT) :: boundary_out_dtype =
'DEFAULT'
3209 integer :: nowdate(6)
3210 integer :: fid, vid(10)
3220 nowdate(1) = nowdate(1)
3224 if ( multi_land )
then
3226 'LAND_TEMP',
'Reference Land Temperature',
'K', &
3227 'LXYT', boundary_out_dtype, &
3229 timeintv=update_dt, nsteps=numsteps )
3231 'LAND_WATER',
'Reference Land Moisture',
'm3/m3', &
3232 'LXYT', boundary_out_dtype, &
3234 timeintv=update_dt, nsteps=numsteps )
3236 'LAND_SFC_TEMP',
'Reference Land Surface Temperature',
'K', &
3237 'XYT', boundary_out_dtype, &
3239 timeintv=update_dt, nsteps=numsteps )
3243 'OCEAN_TEMP',
'Reference Ocean Temperature',
'K', &
3244 'OXYT', boundary_out_dtype, &
3246 timeintv=update_dt, nsteps=numsteps )
3248 'OCEAN_SFC_TEMP',
'Reference Ocean Surface Temperature',
'K', &
3249 'XYT', boundary_out_dtype, &
3251 timeintv=update_dt, nsteps=numsteps )
3253 'OCEAN_SFC_Z0',
'Reference Ocean Surface Z0',
'm', &
3254 'XYT', boundary_out_dtype, &
3256 timeintv=update_dt, nsteps=numsteps )
3260 if ( multi_land )
then
3261 call file_cartesc_write_var( fid, vid(1), tg(:,:,:,ts:te),
'LAND_TEMP',
'LXYT', update_dt )
3262 call file_cartesc_write_var( fid, vid(2), strg(:,:,:,ts:te),
'LAND_WATER',
'LXYT', update_dt )
3263 call file_cartesc_write_var( fid, vid(3), lst( :,:,ts:te),
'LAND_SFC_TEMP',
'XYT', update_dt )
3266 call file_cartesc_write_var( fid, vid(6), tw(:,:,:,ts:te),
'OCEAN_TEMP',
'OXYT', update_dt )
3267 call file_cartesc_write_var( fid, vid(7), sst( :,:,ts:te),
'OCEAN_SFC_TEMP',
'XYT', update_dt )
3268 call file_cartesc_write_var( fid, vid(10), z0( :,:,ts:te),
'OCEAN_SFC_Z0',
'XYT', update_dt )
3273 end subroutine parentsurfaceboundary
3278 kmax, imax, jmax, oimax,ojmax, &
3279 tg, strg, lst, albg, &
3280 tg_org, strg_org, smds_org, &
3281 lst_org, albg_org, &
3283 lmask_org, lsmask_nest, &
3285 lz_org, llon_org, llat_org, &
3288 maskval_tg, maskval_strg, &
3289 init_landwater_ratio, &
3290 ! init_landwater_ratio_each, &
3291 use_file_landwater, &
3293 soilwater_ds2vc_flag, &
3294 elevation_correction, &
3312 mapprojection_lonlat2xy
3326 integer,
intent(in) :: kmax, imax, jmax
3327 integer,
intent(in) :: oimax, ojmax
3328 real(RP),
intent(out) :: tg(LKMAX,IA,JA)
3329 real(RP),
intent(out) :: strg(LKMAX,IA,JA)
3330 real(RP),
intent(out) :: lst(IA,JA)
3331 real(RP),
intent(out) :: albg(IA,JA,N_RAD_DIR,N_RAD_RGN)
3332 real(RP),
intent(inout) :: tg_org(kmax,imax,jmax)
3333 real(RP),
intent(inout) :: strg_org(kmax,imax,jmax)
3334 real(RP),
intent(inout) :: smds_org(kmax,imax,jmax)
3335 real(RP),
intent(inout) :: lst_org(imax,jmax)
3336 real(RP),
intent(inout) :: albg_org(imax,jmax,N_RAD_DIR,N_RAD_RGN)
3337 real(RP),
intent(inout) :: sst_org(oimax,ojmax)
3338 real(RP),
intent(in) :: lmask_org(imax,jmax)
3339 real(RP),
intent(in) :: lsmask_nest(IA,JA)
3340 real(RP),
intent(in) :: topo_org(imax,jmax)
3341 real(RP),
intent(in) :: lz_org(kmax)
3342 real(RP),
intent(in) :: llon_org(imax,jmax)
3343 real(RP),
intent(in) :: llat_org(imax,jmax)
3344 real(RP),
intent(in) :: LCZ(LKMAX)
3345 real(RP),
intent(in) :: CX(IA)
3346 real(RP),
intent(in) :: CY(JA)
3347 real(RP),
intent(in) :: LON(IA,JA)
3348 real(RP),
intent(in) :: LAT(IA,JA)
3349 real(RP),
intent(in) :: maskval_tg
3350 real(RP),
intent(in) :: maskval_strg
3351 real(RP),
intent(in) :: init_landwater_ratio
3353 logical,
intent(in) :: use_file_landwater
3354 logical,
intent(in) :: use_waterratio
3355 logical,
intent(in) :: soilwater_ds2vc_flag
3356 logical,
intent(in) :: elevation_correction
3357 integer,
intent(in) :: intrp_iter_max
3358 logical,
intent(in) :: ol_interp
3360 real(RP) :: lmask(imax,jmax)
3361 real(RP) :: smds(LKMAX,IA,JA)
3364 real(RP) :: hfact_l(imax,jmax,itp_nh_ol)
3365 integer :: igrd_l (imax,jmax,itp_nh_ol)
3366 integer :: jgrd_l (imax,jmax,itp_nh_ol)
3367 real(RP) :: lX_org (imax,jmax)
3368 real(RP) :: lY_org (imax,jmax)
3369 logical :: zonal, pole
3370 integer :: igrd ( IA,JA,itp_nh_l)
3371 integer :: jgrd ( IA,JA,itp_nh_l)
3372 real(RP) :: hfact( IA,JA,itp_nh_l)
3373 integer :: kgrdl (LKMAX,2,IA,JA,itp_nh_l)
3374 real(RP) :: vfactl(LKMAX, IA,JA,itp_nh_l)
3377 real(RP) :: sst_land(imax,jmax)
3378 real(RP) :: work (imax,jmax)
3379 real(RP) :: work2(imax,jmax)
3381 real(RP) :: lz3d_org(kmax,imax,jmax)
3382 real(RP) :: lcz_3D(LKMAX,IA,JA)
3385 real(RP) :: topo(IA,JA)
3388 real(RP) :: one2d(IA,JA)
3389 real(RP) :: one3d(LKMAX,IA,JA)
3391 integer :: k, i, j, m, n
3395 if ( i_intrp_land_sfc_temp .ne. i_intrp_off )
then
3396 select case( i_intrp_land_sfc_temp )
3397 case( i_intrp_mask )
3398 call make_mask( lmask, lst_org, imax, jmax, landdata=.true.)
3402 if ( lmask_org(i,j) .ne. undef ) lmask(i,j) = lmask_org(i,j)
3405 case( i_intrp_fill )
3406 call make_mask( lmask, lst_org, imax, jmax, landdata=.true.)
3408 log_error(
"land_interporation",*)
'INTRP_LAND_SFC_TEMP is invalid.'
3411 call interp_oceanland_data(lst_org, lmask, imax, jmax, .true., intrp_iter_max)
3414 if ( ol_interp )
then
3416 call interp_factor2d( itp_nh_ol, &
3440 sst_land(i,j) = sst_org(i,j)
3448 if ( topo_org(i,j) > undef + eps )
then
3449 sst_land(i,j) = sst_land(i,j) - topo_org(i,j) * laps
3464 if( albg_org(i,j,m,
i_r_ir ) == undef ) albg_org(i,j,m,
i_r_ir ) = 0.03_rp
3465 if( albg_org(i,j,m,
i_r_nir) == undef ) albg_org(i,j,m,
i_r_nir) = 0.22_rp
3466 if( albg_org(i,j,m,
i_r_vis) == undef ) albg_org(i,j,m,
i_r_vis) = 0.22_rp
3472 if ( i_intrp_land_temp .ne. i_intrp_off )
then
3477 work(i,j) = tg_org(k,i,j)
3480 select case( i_intrp_land_temp )
3481 case( i_intrp_mask )
3482 call make_mask( lmask, work, imax, jmax, landdata=.true.)
3486 if ( lmask_org(i,j) .ne. undef ) lmask(i,j) = lmask_org(i,j)
3489 case( i_intrp_fill )
3490 call make_mask( lmask, work, imax, jmax, landdata=.true.)
3492 call interp_oceanland_data( work, lmask, imax, jmax, .true., intrp_iter_max )
3498 tg_org(k,i,j) = work(i,j)
3509 lz3d_org(:,i,j) = lz_org(:)
3516 lcz_3d(:,i,j) = lcz(:)
3520 select case( itp_type_l )
3521 case ( i_intrp_linear )
3523 if ( imax == 1 .or. jmax == 1 )
then
3524 log_error(
"land_interporation",*)
'LINER interpolation requires nx, ny > 1'
3525 log_error_cont(*)
'Use "DIST-WEIGHT" as INTRP_TYPE of PARAM_MKINIT_REAL_LAND'
3532 work(i,j) = sign( min( abs(llat_org(i,j)), pi * 0.499999_rp ), llat_org(i,j) )
3536 call mapprojection_lonlat2xy( imax, 1, imax, jmax, 1, jmax, &
3537 llon_org(:,:), work(:,:), &
3538 lx_org(:,:), ly_org(:,:) )
3540 zonal = ( maxval(llon_org) - minval(llon_org) ) > 2.0_rp * pi * 0.9_rp
3541 pole = ( maxval(llat_org) > pi * 0.5_rp * 0.9_rp ) .or. ( minval(llat_org) < - pi * 0.5_rp * 0.9_rp )
3542 call interp_factor3d( kmax, 1, kmax, &
3556 flag_extrap = .true., &
3560 case ( i_intrp_dstwgt )
3562 call interp_factor3d( itp_nh_l, &
3570 lon(:,:), lat(:,:), &
3577 flag_extrap = .true. )
3589 if ( filter_niter > 0 )
then
3591 lst(:,:), filter_order, filter_niter )
3592 call comm_vars8( lst(:,:), 1 )
3593 call comm_wait ( lst(:,:), 1, .false. )
3597 if ( filter_niter > 0 )
then
3615 albg_org(:,:,m,n), &
3617 if ( filter_niter > 0 )
then
3619 albg(:,:,m,n), filter_order, filter_niter, &
3620 limiter_sign = one2d(:,:) )
3621 call comm_vars8( albg(:,:,m,n), 1 )
3622 call comm_wait ( albg(:,:,m,n), 1, .false. )
3645 tg(lkmax,i,j) = tg(lkmax-1,i,j)
3653 if ( filter_niter > 0 )
then
3654 call filter_hyperdiff( lkmax, 1, lkmax, ia,
isb,
ieb, ja,
jsb,
jeb, &
3655 tg(:,:,:), filter_order, filter_niter )
3656 call comm_vars8( tg(:,:,:), 1 )
3657 call comm_wait ( tg(:,:,:), 1, .false. )
3662 if ( elevation_correction )
then
3671 if ( filter_niter > 0 )
then
3673 topo(:,:), filter_order, filter_niter )
3674 call comm_vars8( topo(:,:), 1 )
3675 call comm_wait ( topo(:,:), 1, .false. )
3682 if ( topo(i,j) > undef + eps )
then
3684 lst(i,j) = lst(i,j) - tdiff
3686 tg(k,i,j) = tg(k,i,j) - tdiff
3697 if( use_file_landwater )
then
3699 if ( use_waterratio )
then
3701 if ( i_intrp_land_water .ne. i_intrp_off )
then
3706 work(i,j) = smds_org(k,i,j)
3709 select case( i_intrp_land_water )
3710 case( i_intrp_mask )
3711 call make_mask( lmask, work, imax, jmax, landdata=.true.)
3715 if ( lmask_org(i,j) .ne. undef ) lmask(i,j) = lmask_org(i,j)
3718 case( i_intrp_fill )
3719 call make_mask( lmask, work, imax, jmax, landdata=.true.)
3721 call interp_oceanland_data(work, lmask, imax, jmax, .true., intrp_iter_max)
3726 work2(i,j) = init_landwater_ratio
3734 smds_org(k,i,j) = work(i,j)
3756 strg(k,:,:) =
convert_ws2vwc( smds(k,:,:), critical=soilwater_ds2vc_flag )
3761 if ( i_intrp_land_water .ne. i_intrp_off )
then
3766 work(i,j) = strg_org(k,i,j)
3769 select case( i_intrp_land_water )
3770 case( i_intrp_mask )
3771 call make_mask( lmask, work, imax, jmax, landdata=.true.)
3775 if ( lmask_org(i,j) .ne. undef ) lmask(i,j) = lmask_org(i,j)
3778 case( i_intrp_fill )
3779 call make_mask( lmask, work, imax, jmax, landdata=.true.)
3781 call interp_oceanland_data(work, lmask, imax, jmax, .true., intrp_iter_max)
3785 lmask(i,j) = maskval_strg
3793 strg_org(k,i,j) = work(i,j)
3824 strg(k,i,j) = max( min( strg(k,i,j), 1.0_rp ), 0.0_rp )
3829 if ( filter_niter > 0 )
then
3834 one3d(k,i,j) = 1.0_rp
3838 call filter_hyperdiff( lkmax, 1, lkmax-1, ia,
isb,
ieb, ja,
jsb,
jeb, &
3839 strg(:,:,:), filter_order, filter_niter, &
3840 limiter_sign = one3d(:,:,:) )
3841 call comm_vars8( strg(:,:,:), 1 )
3842 call comm_wait ( strg(:,:,:), 1, .false. )
3848 strg(lkmax,i,j) = strg(lkmax-1,i,j)
3859 work(i,j) = init_landwater_ratio
3863 strg(k,:,:) =
convert_ws2vwc( work(:,:), critical=soilwater_ds2vc_flag )
3874 sst_org, tw_org, albw_org, z0w_org, &
3876 elevation_correction_ocean, &
3877 init_ocean_alb_lw, init_ocean_alb_sw, &
3879 first_surface, update_coord, &
3880 sst, tw, albw, z0w )
3893 mapprojection_lonlat2xy
3898 integer,
intent(in) :: imax, jmax
3899 real(RP),
intent(in) :: sst_org (imax,jmax)
3900 real(RP),
intent(in) :: tw_org (imax,jmax)
3901 real(RP),
intent(inout) :: albw_org(imax,jmax,N_RAD_DIR,N_RAD_RGN)
3902 real(RP),
intent(inout) :: z0w_org (imax,jmax)
3903 real(RP),
intent(in) :: CX(IA)
3904 real(RP),
intent(in) :: CY(JA)
3905 logical,
intent(in) :: elevation_correction_ocean
3906 real(RP),
intent(in) :: init_ocean_alb_lw
3907 real(RP),
intent(in) :: init_ocean_alb_sw
3908 real(RP),
intent(in) :: init_ocean_z0w
3909 logical,
intent(in) :: first_surface
3910 logical,
intent(in) :: update_coord
3912 real(RP),
intent(out) :: sst (IA,JA)
3913 real(RP),
intent(out) :: tw (IA,JA)
3914 real(RP),
intent(out) :: albw(IA,JA,N_RAD_DIR,N_RAD_RGN)
3915 real(RP),
intent(out) :: z0w (IA,JA)
3918 real(RP) :: oX_org(imax,jmax)
3919 real(RP) :: oY_org(imax,jmax)
3920 logical :: zonal, pole
3922 real(RP) :: one(IA,JA)
3925 integer :: i, j, m, n
3931 if ( albw_org(i,j,m,
i_r_ir ) == undef ) albw_org(i,j,m,
i_r_ir ) = init_ocean_alb_lw
3932 if ( albw_org(i,j,m,
i_r_nir) == undef ) albw_org(i,j,m,
i_r_nir) = init_ocean_alb_sw
3933 if ( albw_org(i,j,m,
i_r_vis) == undef ) albw_org(i,j,m,
i_r_vis) = init_ocean_alb_sw
3934 if ( albw_org(i,j,m,
i_r_vis) == undef ) albw_org(i,j,m,
i_r_vis) = init_ocean_alb_sw
3936 if ( z0w_org(i,j) == undef ) z0w_org(i,j) = init_ocean_z0w
3940 if ( first_surface .or. update_coord )
then
3944 select case( itp_type_a )
3945 case ( i_intrp_linear )
3947 if ( imax == 1 .or. jmax == 1 )
then
3948 log_error(
"ocean_interporation",*)
'LINER interpolation requires nx, ny > 1'
3949 log_error_cont(*)
'Use "DIST-WEIGHT" as INTRP_TYPE of PARAM_MKINIT_REAL_OCEAN'
3956 olat_org(i,j) = sign( min( abs(olat_org(i,j)), pi * 0.499999_rp ), olat_org(i,j) )
3960 call mapprojection_lonlat2xy( imax, 1, imax, jmax, 1, jmax, &
3961 olon_org(:,:), olat_org(:,:), &
3962 ox_org(:,:), oy_org(:,:) )
3964 zonal = ( maxval(olon_org) - minval(olon_org) ) > 2.0_rp * pi * 0.9_rp
3965 pole = ( maxval(olat_org) > pi * 0.5_rp * 0.9_rp ) .or. ( minval(olat_org) < - pi * 0.5_rp * 0.9_rp )
3966 call interp_factor2d( imax, jmax, &
3977 case ( i_intrp_dstwgt )
3979 call interp_factor2d( itp_nh_o, &
3984 lon(:,:), lat(:,:), &
4001 if ( filter_niter > 0 )
then
4003 tw(:,:), filter_order, filter_niter )
4004 call comm_vars8( tw(:,:), 1 )
4005 call comm_wait ( tw(:,:), 1, .false. )
4016 if ( filter_niter > 0 )
then
4018 sst(:,:), filter_order, filter_niter )
4019 call comm_vars8( sst(:,:), 1 )
4020 call comm_wait ( sst(:,:), 1, .false. )
4024 if ( elevation_correction_ocean )
then
4031 sst(i,j) = sst(i,j) - tdiff
4032 tw(i,j) = tw(i,j) - tdiff
4039 if ( filter_niter > 0 )
then
4057 albw_org(:,:,m,n), &
4059 if ( filter_niter > 0 )
then
4061 albw(:,:,m,n), filter_order, filter_niter, &
4062 limiter_sign = one(:,:) )
4063 call comm_vars8( albw(:,:,m,n), 1 )
4064 call comm_wait ( albw(:,:,m,n), 1, .false. )
4078 if ( filter_niter > 0 )
then
4080 z0w(:,:), filter_order, filter_niter, &
4081 limiter_sign = one(:,:) )
4082 call comm_vars8( z0w(:,:), 1 )
4083 call comm_wait ( z0w(:,:), 1, .false. )
4093 tc_urb, qc_urb, uc_urb, &
4104 thermodyn_specific_heat => atmos_thermodyn_specific_heat, &
4105 thermodyn_rhot2temp_pres => atmos_thermodyn_rhot2temp_pres
4110 real(RP),
intent(in) :: lst (IA,JA)
4111 real(RP),
intent(in) :: albg (IA,JA,N_RAD_DIR,N_RAD_RGN)
4112 real(RP),
intent(out) :: tc_urb(IA,JA)
4113 real(RP),
intent(out) :: qc_urb(IA,JA)
4114 real(RP),
intent(out) :: uc_urb(IA,JA)
4115 real(RP),
intent(out) :: ust (IA,JA)
4116 real(RP),
intent(out) :: albu (IA,JA,N_RAD_DIR,N_RAD_RGN)
4118 real(RP) :: temp, pres
4132 call thermodyn_specific_heat(
qa, &
4135 qdry, rtot, cvtot, cptot )
4136 call thermodyn_rhot2temp_pres(
dens(
ks,i,j),
rhot(
ks,i,j), rtot, cvtot, cptot, &
4140 if (
i_qv > 0 )
then
4143 qc_urb(i,j) = 0.0_rp
4151 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 &
4158 uc_urb(ia,j) = max(sqrt( (
momx(
ks,ia,j) /
dens(
ks,ia,j ) )**2.0_rp &
4164 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 &
4165 + (
momy(
ks,i,ja) /
dens(
ks,i ,ja) )**2.0_rp ), 0.01_rp)
4167 uc_urb(ia,ja) = max(sqrt( (
momx(
ks,ia,ja) /
dens(
ks,ia,ja) )**2.0_rp &
4168 + (
momy(
ks,ia,ja) /
dens(
ks,ia,ja) )**2.0_rp ), 0.01_rp)
4170 call comm_vars8( uc_urb, 1 )
4171 call comm_wait ( uc_urb, 1, .false. )
4249 albu(i,j,:,:) = albg(i,j,:,:)
4267 real(RP),
intent(out) :: gmask(:,:)
4268 real(RP),
intent(in) :: data(:,:)
4269 integer,
intent(in) :: nx
4270 integer,
intent(in) :: ny
4271 logical,
intent(in) :: landdata
4297 if( abs(
data(i,j) - undef) < sqrt(eps) )
then
4306 subroutine interp_oceanland_data( &
4318 integer,
intent(in) :: nx
4319 integer,
intent(in) :: ny
4320 real(RP),
intent(inout) :: data (nx,ny)
4321 real(RP),
intent(in) :: lsmask(nx,ny)
4322 logical,
intent(in) :: landdata
4323 integer,
intent(in) :: iter_max
4325 integer :: mask (nx,ny)
4326 integer :: mask_prev(nx,ny)
4327 real(RP) :: data_prev(nx,ny)
4328 real(RP) :: tmp, cnt, sw
4329 integer :: mask_target
4331 integer :: num_land, num_ocean, num_replaced
4332 integer :: istr, iend, jstr, jend
4333 integer :: i, j, ii, jj, ite
4337 log_info(
"interp_OceanLand_data",*)
'Interpolation'
4339 if ( landdata )
then
4340 log_info(
"interp_OceanLand_data",*)
'target mask : LAND'
4343 log_info(
"interp_OceanLand_data",*)
'target mask : OCEAN'
4354 mask(i,j) = int( 0.5_rp - sign(0.5_rp,abs(lsmask(i,j)-1.0_rp)-eps) )
4355 num_land = num_land + ( mask(i,j) )
4356 num_ocean = num_ocean + ( 1-mask(i,j) )
4360 log_progress(
'(1x,A,I3.3,A,2I8)')
'ite=', 0,
', (land,ocean) = ', num_land, num_ocean
4363 do ite = 1, iter_max
4368 mask_prev(i,j) = mask(i,j)
4369 data_prev(i,j) =
data(i,j)
4380 if( mask(i,j) == mask_target ) cycle
4392 sw = 0.5_rp - sign(0.5_rp,real(abs(mask_prev(ii,jj)-mask_target),kind=rp)-eps)
4394 tmp = tmp + sw * data_prev(ii,jj)
4399 if ( cnt >= 3.0_rp )
then
4400 data(i,j) = tmp / cnt
4401 mask(i,j) = mask_target
4403 num_replaced = num_replaced + 1
4409 if ( landdata )
then
4410 num_land = num_land + num_replaced
4411 num_ocean = num_ocean - num_replaced
4413 num_land = num_land - num_replaced
4414 num_ocean = num_ocean + num_replaced
4419 if( num_replaced == 0 )
exit
4423 log_progress(
'(1x,A,I3.3,A,2I8)')
'ite=', ite,
', (land,ocean) = ', num_land, num_ocean
4428 if ( abs(mask(i,j)-mask_target) > eps )
data(i,j) = undef
4434 end subroutine interp_oceanland_data
4441 real(RP),
intent(inout) :: data(:,:)
4442 real(RP),
intent(in) :: maskval
4443 real(RP),
intent(in) :: frac_land(:,:)
4449 if( abs(frac_land(i,j)-0.0_rp) < eps )
then
4464 real(RP),
intent(inout) :: data(:,:)
4465 real(RP),
intent(in) :: maskval(:,:)
4466 integer,
intent(in) :: nx, ny
4467 character(len=*),
intent(in) :: elem
4477 if( abs(
data(i,j) - undef) < sqrt(eps) )
then
4478 if( abs(maskval(i,j) - undef) < sqrt(eps) )
then
4479 log_error(
"replace_misval_map",*)
"data for mask of "//trim(elem)//
"(",i,
",",j,
") includes missing value."
4483 data(i,j) = maskval(i,j)
4490 log_error_cont(*)
"Please check input data of SKINTEMP or SST. "