50 integer,
parameter :: num_item_list_atom = 25
51 integer,
parameter :: num_item_list_land = 12
52 integer,
parameter :: num_item_list_ocean = 10
53 character(len=H_SHORT) :: item_list_atom (num_item_list_atom)
54 character(len=H_SHORT) :: item_list_land (num_item_list_land)
55 character(len=H_SHORT) :: item_list_ocean(num_item_list_ocean)
56 data item_list_atom /
'lon',
'lat',
'plev',
'DENS',
'U',
'V',
'W',
'T',
'HGT',
'QV',
'QC',
'QR',
'QI',
'QS',
'QG',
'RH', &
57 'MSLP',
'PSFC',
'U10',
'V10',
'T2',
'Q2',
'RH2',
'topo',
'RN222' /
58 data item_list_land /
'lsmask',
'lon',
'lat',
'lon_sfc',
'lat_sfc',
'llev', &
59 'STEMP',
'SMOISVC',
'SMOISDS',
'SKINT',
'topo',
'topo_sfc' /
60 data item_list_ocean /
'lsmask',
'lsmask_sst',
'lon',
'lat',
'lon_sfc',
'lat_sfc',
'lon_sst',
'lat_sst',
'SKINT',
'SST'/
62 integer,
parameter :: num_item_list = 25
63 integer :: var_id(num_item_list,3)
65 integer,
parameter :: Ia_lon = 1
66 integer,
parameter :: Ia_lat = 2
67 integer,
parameter :: Ia_p = 3
68 integer,
parameter :: Ia_dens = 4
69 integer,
parameter :: Ia_u = 5
70 integer,
parameter :: Ia_v = 6
71 integer,
parameter :: Ia_w = 7
72 integer,
parameter :: Ia_t = 8
73 integer,
parameter :: Ia_hgt = 9
74 integer,
parameter :: Ia_qv = 10
75 integer,
parameter :: Ia_qc = 11
76 integer,
parameter :: Ia_qr = 12
77 integer,
parameter :: Ia_qi = 13
78 integer,
parameter :: Ia_qs = 14
79 integer,
parameter :: Ia_qg = 15
80 integer,
parameter :: Ia_rh = 16
81 integer,
parameter :: Ia_slp = 17
82 integer,
parameter :: Ia_ps = 18
83 integer,
parameter :: Ia_u10 = 19
84 integer,
parameter :: Ia_v10 = 20
85 integer,
parameter :: Ia_t2 = 21
86 integer,
parameter :: Ia_q2 = 22
87 integer,
parameter :: Ia_rh2 = 23
88 integer,
parameter :: Ia_topo = 24
89 integer,
parameter :: Ia_rn222 = 25
91 integer,
parameter :: Il_lsmask = 1
92 integer,
parameter :: Il_lon = 2
93 integer,
parameter :: Il_lat = 3
94 integer,
parameter :: Il_lon_sfc = 4
95 integer,
parameter :: Il_lat_sfc = 5
96 integer,
parameter :: Il_lz = 6
97 integer,
parameter :: Il_stemp = 7
98 integer,
parameter :: Il_smoisvc = 8
99 integer,
parameter :: Il_smoisds = 9
100 integer,
parameter :: Il_skint = 10
101 integer,
parameter :: Il_topo = 11
102 integer,
parameter :: Il_topo_sfc= 12
104 integer,
parameter :: Io_lsmask = 1
105 integer,
parameter :: Io_lsmask_sst = 2
106 integer,
parameter :: Io_lon = 3
107 integer,
parameter :: Io_lat = 4
108 integer,
parameter :: Io_lon_sfc = 5
109 integer,
parameter :: Io_lat_sfc = 6
110 integer,
parameter :: Io_lon_sst = 7
111 integer,
parameter :: Io_lat_sst = 8
112 integer,
parameter :: Io_skint = 9
113 integer,
parameter :: Io_sst = 10
115 character(len=H_SHORT) :: upper_qv_type =
"ZERO"
121 integer :: outer_nx = -1
122 integer :: outer_ny = -1
123 integer :: outer_nz = -1
124 integer :: outer_nl = -1
126 integer :: outer_nx_sfc = -1
127 integer :: outer_ny_sfc = -1
129 integer :: outer_nx_sst = -1
130 integer :: outer_ny_sst = -1
132 integer :: file_id_atm, file_id_ocn, file_id_lnd
143 file_grads_get_shape, &
146 integer,
intent(out) :: dims(6)
147 character(len=*),
intent(in) :: basename
149 namelist / param_mkinit_real_grads / &
154 character(len=H_SHORT) :: item
160 log_info(
"ParentAtmosSetupGrADS",*)
'Setup'
164 read(
io_fid_conf,nml=param_mkinit_real_grads,iostat=ierr)
167 log_error(
"ParentAtmosSetupGrADS",*)
'Not appropriate names in namelist PARAM_MKINIT_REAL_GrADS. Check!'
170 log_nml(param_mkinit_real_grads)
173 if ( basename ==
"" )
then
174 log_error(
"ParentAtmosSetupGrADS",*)
'"BASENAME_ORG" is not specified in "PARAM_MKINIT_ATMOS_GRID_CARTESC_REAL_ATMOS"!', trim(basename)
181 call file_grads_get_shape( file_id_atm,
"U", &
197 do ielem = 1, num_item_list_atom
198 item = item_list_atom(ielem)
204 do ielem = 1, num_item_list_atom
205 item = item_list_atom(ielem)
208 case(
'DENS',
'W',
'QC',
'QR',
'QI',
'QS',
'QG',
'MSLP',
'PSFC',
'U10',
'V10',
'T2',
'topo',
'RN222')
209 if ( var_id(ielem,1) < 0 )
then
210 log_warn(
"ParentAtmosSetupGrADS",*) trim(item),
' is not found & will be estimated.'
214 if ( var_id(ia_qv,1) < 0 )
then
215 if( var_id(ia_rh,1) > 0 )
then
216 if ( var_id(ia_t,1) < 0 .or. var_id(ia_p,1) < 0 )
then
217 log_error(
"ParentAtmosSetupGrADS",*)
'Temperature and pressure are required to convert from RH to QV ! '
221 log_error(
"ParentAtmosSetupGrADS",*)
'Not found in grads namelist! : QV and RH'
229 if ( var_id(ia_q2,1) < 0 )
then
230 if ( var_id(ia_rh2,1) > 0 )
then
231 if ( var_id(ia_t2,1) < 0 .or. var_id(ia_ps,1) < 0 )
then
232 log_warn(
"ParentAtmosSetupGrADS",*)
'T2 and PSFC are required to convert from RH2 to Q2 !'
233 log_info_cont(*)
'Q2 will be copied from data at above level.'
234 var_id(ia_rh2,1) = -1
237 log_warn(
"ParentAtmosSetupGrADS",*)
'Q2 and RH2 are not found, Q2 will be estimated.'
240 var_id(ia_rh2,1) = -1
244 if ( var_id(ielem,1) < 0 )
then
245 log_error(
"ParentAtmosSetupGrADS",*)
'Not found in grads namelist! : ',trim(item_list_atom(ielem))
268 real(
rp),
intent(out) :: lon_org(:,:)
269 real(
rp),
intent(out) :: lat_org(:,:)
270 character(len=*),
intent(in) :: basename_num
271 integer,
intent(in) :: dims(6)
273 real(
rp) :: lon1d(dims(2)), lat1d(dims(3))
275 character(len=H_SHORT) :: item
277 integer :: i, j, ielem
281 loop_inputatmosgrads :
do ielem = 1, num_item_list_atom
283 if ( var_id(ielem,1) < 0 ) cycle
285 item = item_list_atom(ielem)
292 call file_grads_read( file_id_atm, var_id(ielem,1), &
297 lon_org(i,j) = lon1d(i) * d2r
301 call file_grads_read( file_id_atm, var_id(ielem,1), &
303 postfix = basename_num )
307 lon_org(i,j) = lon_org(i,j) * d2r
315 call file_grads_read( file_id_atm, var_id(ielem,1), &
320 lat_org(i,j) = lat1d(j) * d2r
324 call file_grads_read( file_id_atm, var_id(ielem,1), &
326 postfix = basename_num )
330 lat_org(i,j) = lat_org(i,j) * d2r
336 enddo loop_inputatmosgrads
386 psat => atmos_saturation_psat_liq
389 file_grads_get_shape, &
394 real(
rp),
intent(out) :: velz_org(:,:,:)
395 real(
rp),
intent(out) :: velx_org(:,:,:)
396 real(
rp),
intent(out) :: vely_org(:,:,:)
397 real(
rp),
intent(out) :: pres_org(:,:,:)
398 real(
rp),
intent(out) :: dens_org(:,:,:)
399 real(
rp),
intent(out) :: temp_org(:,:,:)
400 real(
rp),
intent(out) :: qv_org (:,:,:)
401 real(
rp),
intent(out) :: qhyd_org(:,:,:,:)
402 real(
rp),
intent(out) :: rn222_org(:,:,:)
403 real(
rp),
intent(out) :: cz_org(:,:,:)
404 character(len=*),
intent(in) :: basename_num
405 logical,
intent(in) :: sfc_diagnoses
406 logical,
intent(in) :: under_sfc
407 integer,
intent(in) :: ka_org
408 integer,
intent(in) :: ks_org
409 integer,
intent(in) :: ke_org
410 integer,
intent(in) :: ia_org
411 integer,
intent(in) :: is_org
412 integer,
intent(in) :: ie_org
413 integer,
intent(in) :: ja_org
414 integer,
intent(in) :: js_org
415 integer,
intent(in) :: je_org
416 integer,
intent(in) :: dims(6)
417 integer,
intent(in) :: nt
419 character(len=H_SHORT) :: item
421 integer :: lm_layer( ia_org, ja_org )
424 real(
rp) :: work( dims(1), dims(2), dims(3) )
426 logical :: pressure_coordinates
427 real(
rp) :: p_sat, qm, dz
428 real(
rp) :: rh( ia_org, ja_org )
432 integer :: i, j,
k, iq, ielem
439 dens_org(
k,i,j) = undef
440 pres_org(
k,i,j) = undef
441 velz_org(
k,i,j) = 0.0_rp
442 qv_org(
k,i,j) = 0.0_rp
443 qhyd_org(
k,i,j,:) = 0.0_rp
444 rn222_org(
k,i,j ) = 0.0_rp
450 loop_inputatmosgrads :
do ielem = 1, num_item_list_atom
452 if ( var_id(ielem,1) < 0 ) cycle
454 item = item_list_atom(ielem)
460 call file_grads_get_shape( file_id_atm, var_id(ielem,1), &
462 if ( ka_org-2 .ne. shape(1) )
then
463 log_error(
"ParentAtmosInputGrADS",*)
'"nz" must be equal to the default nz for ',trim(item), shape(1), ka_org-2
468 pressure_coordinates = .true.
469 call file_grads_get_shape( file_id_atm, var_id(ielem,1), &
471 if ( ka_org-2 .ne. shape(1) )
then
472 log_error(
"ParentAtmosInputGrADS",*)
'lnum must be same as the nz for plev! ',shape(1), ka_org-2
475 call file_grads_read( file_id_atm, var_id(ielem,1), &
476 work(:,dummy,dummy) )
481 pres_org(
k+2,i,j) = work(
k,dummy,dummy)
486 pressure_coordinates = .false.
487 call file_grads_read( file_id_atm, var_id(ielem,1), &
490 postfix = basename_num )
495 pres_org(
k+2,i,j) = work(
k,i-1+is_org,j-1+js_org)
502 call file_grads_get_shape( file_id_atm, var_id(ielem,1), &
504 if ( ka_org-2 .ne. shape(1) )
then
505 log_error(
"ParentAtmosInputGrADS",*)
'"nz" must be equal to the default nz for ',trim(item),
'. nz:',shape(1),
'> outer_nz:',ka_org-2
509 call file_grads_read( file_id_atm, var_id(ielem,1), &
512 postfix = basename_num )
517 dens_org(
k+2,i,j) = work(
k,i-1+is_org,j-1+js_org)
524 call file_grads_get_shape( file_id_atm, var_id(ielem,1), &
526 if ( ka_org-2 .ne. shape(1) )
then
527 log_error(
"ParentAtmosInputGrADS",*)
'"nz" must be equal to the default nz for ',trim(item),
'. nz:',shape(1),
'> outer_nz:',ka_org-2
531 call file_grads_read( file_id_atm, var_id(ielem,1), &
534 postfix = basename_num )
539 velx_org(
k+2,i,j) = work(
k,i-1+is_org,j-1+js_org)
541 velx_org(1:2,i,j) = 0.0_rp
547 call file_grads_get_shape( file_id_atm, var_id(ielem,1), &
549 if ( ka_org-2 .ne. shape(1) )
then
550 log_error(
"ParentAtmosInputGrADS",*)
'"nz" must be equal to the default nz for ',trim(item),
'. nz:',shape(1),
'> outer_nz:',ka_org-2
554 call file_grads_read( file_id_atm, var_id(ielem,1), &
557 postfix = basename_num )
562 vely_org(
k+2,i,j) = work(
k,i-1+is_org,j-1+js_org)
564 vely_org(1:2,i,j) = 0.0_rp
570 call file_grads_get_shape( file_id_atm, var_id(ielem,1), &
572 if ( ka_org-2 .ne. shape(1) )
then
573 log_error(
"ParentAtmosInputGrADS",*)
'"nz" must be equal to the default nz for ',trim(item),
'. nz:',shape(1),
'> outer_nz:',ka_org-2
577 call file_grads_read( file_id_atm, var_id(ielem,1), &
580 postfix = basename_num )
585 velz_org(
k+2,i,j) = work(
k,i-1+is_org,j-1+js_org)
587 velz_org(1:2,i,j) = 0.0_rp
593 call file_grads_get_shape( file_id_atm, var_id(ielem,1), &
595 if ( ka_org-2 .ne. shape(1) )
then
596 log_error(
"ParentAtmosInputGrADS",*)
'"nz" must be equal to the default nz for ',trim(item),
'. nz:',shape(1),
'> outer_nz:',ka_org-2
600 call file_grads_read( file_id_atm, var_id(ielem,1), &
603 postfix = basename_num )
608 temp_org(
k+2,i,j) = work(
k,i-1+is_org,j-1+js_org)
615 call file_grads_get_shape( file_id_atm, var_id(ielem,1), &
617 if ( ka_org-2 .ne. shape(1) )
then
618 log_error(
"ParentAtmosInputGrADS",*)
'"nz" must be equal to the default nz for ',trim(item),
'. nz:',shape(1),
'> outer_nz:',ka_org-2
623 call file_grads_get_shape( file_id_atm, var_id(ielem,1), &
625 if ( ka_org-2 .ne. shape(1) )
then
626 log_error(
"ParentAtmosInputGrADS",*)
'lnum must be same as the nz for HGT! ',ka_org-2, shape(1)
629 call file_grads_read( file_id_atm, var_id(ielem,1), &
630 work(:,dummy,dummy) )
634 cz_org(1,i,j) = 0.0_rp
636 cz_org(
k+2,i,j) = work(
k,dummy,dummy)
641 pressure_coordinates = .false.
642 call file_grads_read( file_id_atm, var_id(ielem,1), &
645 postfix = basename_num )
650 cz_org(
k+2,i,j) = work(
k,i-1+is_org,j-1+js_org)
652 cz_org(1,i,j) = 0.0_rp
659 call file_grads_get_shape( file_id_atm, var_id(ielem,1), &
662 call file_grads_read( file_id_atm, var_id(ielem,1), &
663 work(:shape(1),:,:), &
665 postfix = basename_num )
670 qv_org(
k+2,i,j) = work(
k,i-1+is_org,j-1+js_org)
675 if( ka_org-2 > shape(1) )
then
676 select case( upper_qv_type )
681 do k = shape(1)+1, ka_org-2
682 qv_org(
k+2,i,j) = qv_org(shape(1)+2,i,j)
689 log_error(
"ParentAtmosInputGrADS",*)
'upper_qv_type in PARAM_MKINIT_REAL_GrADS is invalid! ', upper_qv_type
696 call file_grads_get_shape( file_id_atm, var_id(ielem,1), &
699 call file_grads_read( file_id_atm, var_id(ielem,1), &
700 work(:shape(1),:,:), &
702 postfix = basename_num )
707 qhyd_org(
k+2,i,j,
i_hc) = work(
k,i-1+is_org,j-1+js_org)
716 call file_grads_get_shape( file_id_atm, var_id(ielem,1), &
719 call file_grads_read( file_id_atm, var_id(ielem,1), &
720 work(:shape(1),:,:), &
722 postfix = basename_num )
727 qhyd_org(
k+2,i,j,
i_hr) = work(
k,i-1+is_org,j-1+js_org)
736 call file_grads_get_shape( file_id_atm, var_id(ielem,1), &
739 call file_grads_read( file_id_atm, var_id(ielem,1), &
740 work(:shape(1),:,:), &
742 postfix = basename_num )
747 qhyd_org(
k+2,i,j,
i_hi) = work(
k,i-1+is_org,j-1+js_org)
756 call file_grads_get_shape( file_id_atm, var_id(ielem,1), &
759 call file_grads_read( file_id_atm, var_id(ielem,1), &
760 work(:shape(1),:,:), &
762 postfix = basename_num )
767 qhyd_org(
k+2,i,j,
i_hs) = work(
k,i-1+is_org,j-1+js_org)
776 call file_grads_get_shape( file_id_atm, var_id(ielem,1), &
779 call file_grads_read( file_id_atm, var_id(ielem,1), &
780 work(:shape(1),:,:), &
782 postfix = basename_num )
787 qhyd_org(
k+2,i,j,
i_hg) = work(
k,i-1+is_org,j-1+js_org)
796 call file_grads_get_shape( file_id_atm, var_id(ielem,1), &
799 call file_grads_read( file_id_atm, var_id(ielem,1), &
800 work(:shape(1),:,:), &
802 postfix = basename_num )
807 qv_org(
k+2,i,j) = work(
k,i-1+is_org,j-1+js_org)
817 if( qv_org(
k+1,i,j) .ne. undef )
then
818 rh(i,j) = qv_org(
k+2,i,j) / 100.0_rp
819 call psat( temp_org(
k+2,i,j), p_sat )
820 qm = epsvap * rh(i,j) * p_sat &
821 / ( pres_org(
k+2,i,j) - rh(i,j) * p_sat )
822 qv_org(
k+2,i,j) = qm / ( 1.0_rp + qm )
827 if( ka_org-2 > shape(1) )
then
828 select case( upper_qv_type )
834 do k = shape(1)+1, ka_org-2
835 call psat( temp_org(
k+2,i,j), p_sat )
836 qm = epsvap * rh(i,j) * p_sat &
837 / ( pres_org(
k+2,i,j) - rh(i,j) * p_sat )
838 qv_org(
k+2,i,j) = qm / ( 1.0_rp + qm )
839 qv_org(
k+2,i,j) = min(qv_org(
k+2,i,j),qv_org(
k+1,i,j))
846 log_error(
"ParentAtmosInputGrADS",*)
'upper_qv_type in PARAM_MKINIT_REAL_GrADS is invalid! ', upper_qv_type
853 call file_grads_read( file_id_atm, var_id(ielem,1), &
856 postfix = basename_num )
860 pres_org(1,i,j) = work(dummy,i-1+is_org,j-1+js_org)
866 call file_grads_read( file_id_atm, var_id(ielem,1), &
869 postfix = basename_num )
873 pres_org(2,i,j) = work(dummy,i-1+is_org,j-1+js_org)
879 if ( sfc_diagnoses )
then
880 call file_grads_read( file_id_atm, var_id(ielem,1), &
883 postfix = basename_num )
887 velx_org(2,i,j) = work(dummy,i-1+is_org,j-1+js_org)
894 if ( sfc_diagnoses )
then
895 call file_grads_read( file_id_atm, var_id(ielem,1), &
898 postfix = basename_num )
902 vely_org(2,i,j) = work(dummy,i-1+is_org,j-1+js_org)
909 if ( sfc_diagnoses )
then
910 call file_grads_read( file_id_atm, var_id(ielem,1), &
913 postfix = basename_num )
917 temp_org(2,i,j) = work(dummy,i-1+is_org,j-1+js_org)
924 if ( sfc_diagnoses )
then
925 call file_grads_read( file_id_atm, var_id(ielem,1), &
928 postfix = basename_num )
932 qv_org(2,i,j) = work(dummy,i-1+is_org,j-1+js_org)
939 if ( sfc_diagnoses )
then
940 call file_grads_read( file_id_atm, var_id(ielem,1), &
943 postfix = basename_num )
947 qv_org(2,i,j) = work(dummy,i-1+is_org,j-1+js_org)
954 rh(i,j) = qv_org(2,i,j) / 100.0_rp
955 call psat( temp_org(2,i,j), p_sat )
956 qm = epsvap * rh(i,j) * p_sat &
957 / ( pres_org(2,i,j) - rh(i,j) * p_sat )
958 qv_org(2,i,j) = qm / ( 1.0_rp + qm )
965 call file_grads_read( file_id_atm, var_id(ielem,1), &
967 postfix = basename_num )
971 cz_org(2,i,j) = work(dummy,i-1+is_org,j-1+js_org)
977 call file_grads_get_shape( file_id_atm, var_id(ielem,1), &
980 call file_grads_read( file_id_atm, var_id(ielem,1), &
981 work(:shape(1),:,:), &
983 postfix = basename_num )
988 rn222_org(
k+2,i,j) = work(
k,i-1+is_org,j-1+js_org)
994 enddo loop_inputatmosgrads
1003 if( abs( pres_org(
k,i,j) - undef ) < eps )
then
1004 lm_layer(i,j) =
k + 1
1013 if ( var_id(ia_dens,1) < 0 )
then
1018 do k = lm_layer(i,j), ka_org
1019 rtot = rdry * ( 1.0_rp + epstvap * qv_org(
k,i,j) )
1020 dens_org(
k,i,j) = pres_org(
k,i,j) / ( rtot * temp_org(
k,i,j) )
1026 if ( sfc_diagnoses )
then
1028 if ( var_id(ia_topo,1) > 0 )
then
1029 if ( .not. under_sfc )
then
1033 do k = lm_layer(i,j), ka_org
1034 if ( cz_org(
k,i,j) > cz_org(2,i,j) )
then
1042 if ( var_id(ia_t2,1) > 0 .and. var_id(ia_ps,1) > 0 )
then
1047 rtot = rdry * ( 1.0_rp + epstvap * qv_org(2,i,j) )
1048 dens_org(2,i,j) = pres_org(2,i,j) / ( rtot * temp_org(2,i,j) )
1051 else if ( var_id(ia_ps,1) > 0 )
then
1057 dz = cz_org(
k,i,j) - cz_org(2,i,j)
1058 dens_org(2,i,j) = - ( pres_org(
k,i,j) - pres_org(2,i,j) ) * 2.0_rp / ( grav * dz ) &
1060 rtot = rdry * ( 1.0_rp + epstvap * qv_org(2,i,j) )
1061 temp_org(2,i,j) = pres_org(2,i,j) / ( rtot * dens_org(2,i,j) )
1064 else if ( var_id(ia_t2,1) > 0 )
then
1070 dz = cz_org(
k,i,j) - cz_org(2,i,j)
1071 rtot = rdry * ( 1.0_rp + epstvap * qv_org(2,i,j) )
1072 dens_org(2,i,j) = ( pres_org(
k,i,j) + grav * dens_org(
k,i,j) * dz * 0.5_rp ) &
1073 / ( rtot * temp_org(2,i,j) - grav * dz * 0.5_rp )
1074 pres_org(2,i,j) = dens_org(2,i,j) * rtot * temp_org(2,i,j)
1083 dz = cz_org(
k,i,j) - cz_org(2,i,j)
1084 temp_org(2,i,j) = temp_org(
k,i,j) + laps * dz
1085 rtot = rdry * ( 1.0_rp + epstvap * qv_org(2,i,j) )
1086 dens_org(2,i,j) = ( pres_org(
k,i,j) + grav * dens_org(
k,i,j) * dz * 0.5_rp ) &
1087 / ( rtot * temp_org(2,i,j) - grav * dz * 0.5_rp )
1088 pres_org(2,i,j) = dens_org(2,i,j) * rtot * temp_org(2,i,j)
1099 cz_org(2,i,j) = cz_org(
k,i,j)
1100 velz_org(2,i,j) = velz_org(
k,i,j)
1101 velx_org(2,i,j) = velx_org(
k,i,j)
1102 vely_org(2,i,j) = vely_org(
k,i,j)
1103 pres_org(2,i,j) = pres_org(
k,i,j)
1104 temp_org(2,i,j) = temp_org(
k,i,j)
1105 dens_org(2,i,j) = dens_org(
k,i,j)
1106 qv_org(2,i,j) = qv_org(
k,i,j)
1107 qhyd_org(2,i,j,:) = qhyd_org(
k,i,j,:)
1108 rn222_org(2,i,j) = rn222_org(
k,i,j)
1126 if ( var_id(ia_q2,1) < 0 .and. var_id(ia_rh2,1) < 0 )
then
1131 qv_org(2,i,j) = qv_org(
k,i,j)
1139 qv_org(1,i,j) = qv_org(
k,i,j)
1140 qhyd_org(1,i,j,:) = qhyd_org(
k,i,j,:)
1141 qhyd_org(2,i,j,:) = qhyd_org(
k,i,j,:)
1142 rn222_org(1,i,j) = rn222_org(
k,i,j)
1143 rn222_org(2,i,j) = rn222_org(
k,i,j)
1151 temp_org(1,i,j) = temp_org(2,i,j) + laps * cz_org(2,i,j)
1154 if ( var_id(ia_slp,1) > 0 )
then
1158 dens_org(1,i,j) = pres_org(1,i,j) / ( rdry * temp_org(1,i,j) )
1165 dens_org(1,i,j) = ( pres_org(2,i,j) + grav * dens_org(2,i,j) * cz_org(2,i,j) * 0.5_rp ) &
1166 / ( rdry * temp_org(1,i,j) - grav * cz_org(2,i,j) * 0.5_rp )
1167 pres_org(1,i,j) = dens_org(1,i,j) * rdry * temp_org(1,i,j)
1176 velz_org(1:2,i,j) = undef
1177 velx_org(1:2,i,j) = undef
1178 vely_org(1:2,i,j) = undef
1179 dens_org(1:2,i,j) = undef
1180 temp_org(1:2,i,j) = undef
1181 qv_org(1:2,i,j) = undef
1182 qhyd_org(1:2,i,j,:) = undef
1183 rn222_org(1:2,i,j) = undef
1184 pres_org(1 ,i,j) = undef
1185 cz_org(1 ,i,j) = undef
1191 if( pressure_coordinates .and. var_id(ia_ps,1) > 0 )
then
1195 if ( under_sfc )
then
1197 if ( pres_org(1,i,j) < pres_org(
k,i,j) )
then
1198 pres_org(1,i,j) = undef
1199 cz_org(1,i,j) = undef
1201 if ( pres_org(2,i,j) < pres_org(
k,i,j) )
then
1202 pres_org(2,i,j) = pres_org(1,i,j)
1203 cz_org(2,i,j) = cz_org(1,i,j)
1208 if( pres_org(
k,i,j) > pres_org(2,i,j) )
then
1209 if ( sfc_diagnoses )
then
1210 velz_org(
k,i,j) = velz_org(2,i,j)
1211 velx_org(
k,i,j) = velx_org(2,i,j)
1212 vely_org(
k,i,j) = vely_org(2,i,j)
1213 pres_org(
k,i,j) = pres_org(2,i,j)
1214 dens_org(
k,i,j) = dens_org(2,i,j)
1215 temp_org(
k,i,j) = temp_org(2,i,j)
1216 qv_org(
k,i,j) = qv_org(2,i,j)
1217 qhyd_org(
k,i,j,:) = qhyd_org(2,i,j,:)
1218 cz_org(
k,i,j) = cz_org(2,i,j)
1219 rn222_org(
k,i,j) = rn222_org(2,i,j)
1221 velz_org(
k,i,j) = undef
1222 velx_org(
k,i,j) = undef
1223 vely_org(
k,i,j) = undef
1224 pres_org(
k,i,j) = undef
1225 dens_org(
k,i,j) = undef
1226 temp_org(
k,i,j) = undef
1227 qv_org(
k,i,j) = undef
1228 qhyd_org(
k,i,j,:) = undef
1229 cz_org(
k,i,j) = undef
1230 rn222_org(
k,i,j) = undef
1236 else if ( var_id(ia_topo,1) > 0 )
then
1240 if ( under_sfc )
then
1242 if ( cz_org(1,i,j) < cz_org(
k,i,j) )
then
1243 pres_org(1,i,j) = undef
1244 cz_org(1,i,j) = undef
1246 if ( cz_org(1,i,j) < cz_org(
k,i,j) )
then
1247 pres_org(2,i,j) = pres_org(1,i,j)
1248 cz_org(2,i,j) = cz_org(1,i,j)
1254 if( cz_org(
k,i,j) < cz_org(2,i,j) )
then
1255 if ( sfc_diagnoses )
then
1256 velz_org(
k,i,j) = velz_org(2,i,j)
1257 velx_org(
k,i,j) = velx_org(2,i,j)
1258 vely_org(
k,i,j) = vely_org(2,i,j)
1259 pres_org(
k,i,j) = pres_org(2,i,j)
1260 dens_org(
k,i,j) = dens_org(2,i,j)
1261 temp_org(
k,i,j) = temp_org(2,i,j)
1262 qv_org(
k,i,j) = qv_org(2,i,j)
1263 qhyd_org(
k,i,j,:) = qhyd_org(2,i,j,:)
1264 cz_org(
k,i,j) = cz_org(2,i,j)
1265 rn222_org(
k,i,j) = 0.0_rp
1267 velz_org(
k,i,j) = undef
1268 velx_org(
k,i,j) = undef
1269 vely_org(
k,i,j) = undef
1270 pres_org(
k,i,j) = undef
1271 dens_org(
k,i,j) = undef
1272 temp_org(
k,i,j) = undef
1273 qv_org(
k,i,j) = undef
1274 qhyd_org(
k,i,j,:) = undef
1275 cz_org(
k,i,j) = undef
1276 rn222_org(
k,i,j) = undef
1292 use_file_landwater, &
1296 file_grads_get_shape, &
1299 integer,
intent(out) :: ldims(3)
1300 logical,
intent(out) :: use_waterratio
1301 logical,
intent(in) :: use_file_landwater
1302 character(len=*),
intent(in) :: basename
1304 character(len=H_SHORT) :: item
1308 log_info(
"ParentLandSetupGrADS",*)
'Real Case/Land Input File Type: GrADS format'
1311 use_waterratio = .false.
1313 if ( basename ==
"" )
then
1314 log_error(
"ParentLandSetupGrADS",*)
'"BASEMAAME" is not specified in "PARAM_MKINIT_ATMOS_GRID_CARTESC_REAL_ATOMS"!', trim(basename)
1321 call file_grads_get_shape( file_id_lnd,
"STEMP", &
1326 do ielem = 1, num_item_list_land
1327 item = item_list_land(ielem)
1333 do ielem = 1, num_item_list_land
1334 item = item_list_land(ielem)
1338 if ( var_id(ielem,2) < 0 )
then
1339 log_warn(
"ParentLandSetupGrADS",*) trim(item),
' is not found & not used.'
1342 case(
'topo',
'topo_sfc')
1343 if ( var_id(il_topo_sfc,2) < 0 )
then
1344 if ( var_id(il_topo,2) < 0 )
then
1345 log_warn(
"ParentLandSetupGrADS",*)
'"topo" and "topo_sfc" are not found & not used.'
1348 var_id(il_topo,2) = -1
1351 case(
'lon',
'lat',
'lon_sfc',
'lat_sfc')
1352 if ( var_id(il_lon_sfc,2) < 0 )
then
1353 if ( var_id(il_lon,2) < 0 )
then
1354 log_error(
"ParentLandSetupGrADS",*)
'either lon or lon_sfc is required'
1358 var_id(il_lon,2) = -1
1360 if ( var_id(il_lat_sfc,2) < 0 )
then
1361 if ( var_id(il_lat,2) < 0 )
then
1362 log_error(
"ParentLandSetupGrADS",*)
'either lat or lat_sfc is required'
1366 var_id(il_lat,2) = -1
1369 case(
'SMOISVC',
'SMOISDS')
1370 if ( use_file_landwater )
then
1371 if ( var_id(il_smoisvc,2) < 0 .and. var_id(il_smoisds,2) < 0 )
then
1372 log_error(
"ParentLandSetupGrADS",*)
'Not found in grads namelist! : ',trim(item_list_land(ielem))
1375 if ( var_id(il_smoisds,2) > 0 )
then
1376 use_waterratio = .true.
1377 var_id(il_smoisvc,2) = -1
1380 var_id(il_smoisvc,2) = -1
1381 var_id(il_smoisds,2) = -1
1385 if ( var_id(ielem,2) < 0 )
then
1386 log_error(
"ParentLandSetupGrADS",*)
'Not found in grads namelist! : ',trim(item_list_land(ielem))
1408 use_file_landwater, &
1419 file_grads_get_shape, &
1423 real(
rp),
intent(out) :: tg_org (:,:,:)
1424 real(
rp),
intent(out) :: strg_org (:,:,:)
1425 real(
rp),
intent(out) :: smds_org (:,:,:)
1426 real(
rp),
intent(out) :: lst_org (:,:)
1427 real(
rp),
intent(out) :: llon_org (:,:)
1428 real(
rp),
intent(out) :: llat_org (:,:)
1429 real(
rp),
intent(out) :: lz_org (:)
1430 real(
rp),
intent(out) :: topo_org (:,:)
1431 real(
rp),
intent(out) :: lmask_org(:,:)
1432 character(len=*),
intent(in) :: basename_num
1433 integer,
intent(in) :: ldims(3)
1434 logical,
intent(in) :: use_file_landwater
1435 integer,
intent(in) :: nt
1437 real(
rp) :: lon1d(ldims(2)), lat1d(ldims(3))
1440 character(len=H_SHORT) :: item
1449 lmask_org(i,j) = undef
1450 topo_org(i,j) = undef
1454 loop_inputlandgrads :
do ielem = 1, num_item_list_land
1456 item = item_list_land(ielem)
1458 if ( var_id(ielem,2) < 0 ) cycle
1464 call file_grads_read( file_id_lnd, var_id(ielem,2), &
1466 postfix = basename_num )
1468 case(
"lon",
"lon_sfc")
1470 if ( item ==
"lon" )
then
1472 call file_grads_get_shape( file_id_lnd, var_id(ielem,2), &
1474 if ( ldims(2).ne.shape(1) .and. shape(1).ne.-1 )
then
1475 log_error(
"ParentLandInputGrADS",*)
'dimension of "lon" is different! ', ldims(2), shape(1)
1479 call file_grads_get_shape( file_id_lnd, var_id(ielem,2), &
1481 if ( ldims(2).ne.shape(1) .or. ldims(3).ne.shape(2) )
then
1482 log_error(
"ParentLandInputGrADS",*)
'dimension of "lon" is different! ', ldims(2), shape(1), ldims(3), shape(2)
1489 call file_grads_read( file_id_lnd, var_id(ielem,2), &
1494 llon_org(i,j) = lon1d(i) * d2r
1498 call file_grads_read( file_id_lnd, var_id(ielem,2), &
1500 postfix = basename_num )
1504 llon_org(i,j) = llon_org(i,j) * d2r
1509 case(
"lat",
"lat_sfc")
1511 if ( item ==
"lat" )
then
1513 call file_grads_get_shape( file_id_lnd, var_id(ielem,2), &
1515 if ( ldims(3).ne.shape(1) .and. shape(1).ne.-1 )
then
1516 log_error(
"ParentLandInputGrADS",*)
'dimension of "lat" is different! ', ldims(3), shape(1)
1520 call file_grads_get_shape( file_id_lnd, var_id(ielem,2), &
1522 if ( ldims(2).ne.shape(1) .or. ldims(3).ne.shape(2) )
then
1523 log_error(
"ParentLandInputGrADS",*)
'dimension of "lat" is different! ', ldims(2), shape(1), ldims(3), shape(2)
1530 call file_grads_read( file_id_lnd, var_id(ielem,2), &
1535 llat_org(i,j) = lat1d(j) * d2r
1539 call file_grads_read( file_id_lnd, var_id(ielem,2), &
1541 postfix = basename_num )
1545 llat_org(i,j) = llat_org(i,j) * d2r
1552 call file_grads_get_shape( file_id_lnd, var_id(ielem,2), &
1554 if( ldims(1) .ne. shape(1) )
then
1555 log_error(
"ParentLandInputGrADS",*)
'"nz" must be equal to nz of "STEMP" for llev. :', shape(1), ldims(1)
1558 call file_grads_read( file_id_lnd, var_id(ielem,2), &
1563 call file_grads_get_shape( file_id_lnd, var_id(ielem,2), &
1565 if ( ldims(1) .ne. shape(1) )
then
1566 log_error(
"ParentAtmosInputGrADS",*)
'"nz" must be equal to nz of "STEMP" for ',trim(item),
'. :', shape(1), ldims(1)
1570 call file_grads_read( file_id_lnd, var_id(ielem,2), &
1573 postfix = basename_num )
1577 call file_grads_get_shape( file_id_lnd, var_id(ielem,2), &
1579 if ( ldims(1) .ne. shape(1) )
then
1580 log_error(
"ParentAtmosInputGrADS",*)
'"nz" must be equal to nz of "STEMP" for ',trim(item),
'. :', shape(1), ldims(1)
1584 call file_grads_read( file_id_lnd, var_id(ielem,2), &
1587 postfix = basename_num )
1591 call file_grads_get_shape( file_id_lnd, var_id(ielem,2), &
1593 if ( ldims(1) .ne. shape(1) )
then
1594 log_error(
"ParentAtmosInputGrADS",*)
'"nz" must be equal to nz of "STEMP" for ',trim(item),
'. :', shape(1), ldims(1)
1598 call file_grads_read( file_id_lnd, var_id(ielem,2), &
1601 postfix = basename_num )
1605 call file_grads_read( file_id_lnd, var_id(ielem,2), &
1608 postfix = basename_num )
1610 case(
'topo',
'topo_sfc')
1612 if ( item ==
"topo" )
then
1613 call file_grads_get_shape( file_id_lnd, var_id(ielem,2), &
1615 if ( ldims(2).ne.shape(1) .or. ldims(3).ne.shape(2) )
then
1616 log_warn(
"ParentLandInputGrADS",*)
'namelist of "topo_sfc" is not found in grads namelist!'
1617 log_warn_cont(*)
'dimension of "topo" is different! ', ldims(2), shape(1), ldims(3), shape(2)
1622 call file_grads_read( file_id_lnd, var_id(ielem,2), &
1624 postfix = basename_num )
1627 enddo loop_inputlandgrads
1641 file_grads_get_shape
1644 integer,
intent(out) :: odims(2)
1645 integer,
intent(out) :: timelen
1646 character(len=*),
intent(in) :: basename
1648 character(len=H_SHORT) :: item
1653 log_info(
"ParentOceanSetupGrADS",*)
'Real Case/Ocean Input File Type: GrADS format'
1666 log_error(
"ParentOceanSetupGrADS",*)
'SST and SKINT are found in grads namelist!'
1670 call file_grads_get_shape( file_id_ocn, vid, &
1678 do ielem = 1, num_item_list_ocean
1679 item = item_list_ocean(ielem)
1685 do ielem = 1, num_item_list_ocean
1686 item = item_list_ocean(ielem)
1689 case(
'lsmask',
'lsmask_sst')
1690 if ( var_id(io_lsmask_sst,3) < 3 )
then
1691 if ( var_id(io_lsmask,3) < 3 )
then
1692 log_warn(
"ParentOceanSetupGrADS",*) trim(item),
' is not found & not used.'
1695 var_id(io_lsmask,3) = -1
1697 case(
'lon',
'lat',
'lon_sfc',
'lat_sfc',
'lon_sst',
'lat_sst')
1698 if ( var_id(io_lon_sst,3) < 0 )
then
1699 if ( var_id(io_lon_sfc,3) < 0 )
then
1700 if ( var_id(io_lon,3) < 0 )
then
1701 log_error(
"ParentOceanSetupGrADS",*)
'either lon_sst, lon_sfc, or lon is necessary!'
1705 var_id(io_lon,3) = -1
1708 var_id(io_lon_sfc,3) = -1
1709 var_id(io_lon, 3) = -1
1711 if ( var_id(io_lat_sst,3) < 0 )
then
1712 if ( var_id(io_lat_sfc,3) < 0 )
then
1713 if ( var_id(io_lat,3) < 0 )
then
1714 log_error(
"ParentOceanSetupGrADS",*)
'either lat_sst, lat_sfc, or lat is necessary!'
1718 var_id(io_lat,3) = -1
1721 var_id(io_lat_sfc,3) = -1
1722 var_id(io_lat, 3) = -1
1725 if ( var_id(io_sst,3) < 0 )
then
1726 if ( var_id(io_skint,3) < 0 )
then
1727 log_error(
"ParentOceanSetupGrADS",*)
'SST and SKINT are found in grads namelist!'
1730 log_warn(
"ParentOceanSetupGrADS",*)
'SST is found in grads namelist. SKINT is used in place of SST.'
1733 var_id(io_skint,3) = -1
1736 if ( var_id(ielem,3) < 0 )
then
1737 log_error(
"ParentOceanSetupGrADS",*)
'Not found in grads namelist! : ', &
1738 trim(item_list_ocean(ielem))
1772 file_grads_get_shape, &
1776 real(
rp),
intent(out) :: tw_org (:,:)
1777 real(
rp),
intent(out) :: sst_org (:,:)
1778 real(
rp),
intent(out) :: omask_org(:,:)
1779 real(
rp),
intent(out) :: olon_org (:,:)
1780 real(
rp),
intent(out) :: olat_org (:,:)
1781 character(len=*),
intent(in) :: basename_num
1782 integer,
intent(in) :: odims(2)
1783 integer,
intent(in) :: nt
1785 character(len=H_SHORT) :: item
1788 real(
rp) :: lon1d(odims(1)), lat1d(odims(2))
1797 omask_org(i,j) = undef
1801 loop_inputoceangrads :
do ielem = 1, num_item_list_ocean
1803 if ( var_id(ielem,3) < 0 ) cycle
1805 item = item_list_ocean(ielem)
1809 case(
"lsmask",
"lsmask_sst")
1811 if ( item ==
"lsmask" )
then
1812 call file_grads_get_shape( file_id_ocn, var_id(ielem,3), &
1814 if ( odims(1) .ne. shape(1) .or. odims(2) .ne. shape(2) )
then
1815 log_warn(
"ParentOceanInputGrADS",*)
'dimension of lsmask is different. not use'
1820 call file_grads_read( file_id_ocn, var_id(ielem,3), &
1822 postfix = basename_num )
1824 case(
"lon",
"lon_sfc",
"lon_sst")
1826 if ( item .ne.
"lon_sst" )
then
1828 call file_grads_get_shape( file_id_ocn, var_id(ielem,3), &
1830 if ( odims(1).ne.shape(1) .and. shape(1).ne.-1 )
then
1831 log_error(
"ParentOceanInputGrADS",*)
'dimension of "',trim(item),
'" is different! ', odims(1), shape(1)
1835 call file_grads_get_shape( file_id_ocn, var_id(ielem,3), &
1837 if ( odims(1).ne.shape(1) .or. odims(2).ne.shape(2) )
then
1838 log_error(
"ParentOceanInputGrADS",*)
'dimension of "',trim(item),
'" is different', odims(1), shape(1), odims(2), shape(2)
1845 call file_grads_read( file_id_ocn, var_id(ielem,3), &
1850 olon_org(i,j) = lon1d(i) * d2r
1854 call file_grads_read( file_id_ocn, var_id(ielem,3), &
1856 postfix = basename_num )
1860 olon_org(i,j) = olon_org(i,j) * d2r
1865 case(
"lat",
"lat_sfc",
"lat_sst")
1867 if ( item .ne.
"lat_sst" )
then
1869 call file_grads_get_shape( file_id_ocn, var_id(ielem,3), &
1871 if ( odims(2).ne.shape(1) .and. shape(1).ne.-1 )
then
1872 log_error(
"ParentOceanInputGrADS",*)
'dimension of "',trim(item),
'" is different! ', odims(2), shape(1)
1876 call file_grads_get_shape( file_id_ocn, var_id(ielem,3), &
1878 if ( odims(1).ne.shape(1) .or. odims(2).ne.shape(2) )
then
1879 log_error(
"ParentOceanInputGrADS",*)
'dimension of "',trim(item),
'" is different', odims(1), shape(1), odims(2), shape(2)
1886 call file_grads_read( file_id_ocn, var_id(ielem,3), &
1891 olat_org(i,j) = lat1d(j) * d2r
1895 call file_grads_read( file_id_ocn, var_id(ielem,3), &
1897 postfix = basename_num )
1901 olat_org(i,j) = olat_org(i,j) * d2r
1908 if ( item ==
"SKINT" )
then
1909 call file_grads_get_shape( file_id_ocn, var_id(ielem,3), &
1911 if ( odims(1).ne.shape(1) .or. odims(2).ne.shape(2) )
then
1912 log_error(
"ParentLandOceanGrADS",*)
'dimension of "',trim(item),
'" is different', odims(1), shape(1), odims(2), shape(2)
1917 call file_grads_read( file_id_ocn, var_id(ielem,3), &
1919 postfix = basename_num )
1922 enddo loop_inputoceangrads