FV3DYCORE  Version 2.0.0
fv_arrays.F90
Go to the documentation of this file.
1 !***********************************************************************
2 !* GNU Lesser General Public License
3 !*
4 !* This file is part of the FV3 dynamical core.
5 !*
6 !* The FV3 dynamical core is free software: you can redistribute it
7 !* and/or modify it under the terms of the
8 !* GNU Lesser General Public License as published by the
9 !* Free Software Foundation, either version 3 of the License, or
10 !* (at your option) any later version.
11 !*
12 !* The FV3 dynamical core is distributed in the hope that it will be
13 !* useful, but WITHOUT ANYWARRANTY; without even the implied warranty
14 !* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 !* See the GNU General Public License for more details.
16 !*
17 !* You should have received a copy of the GNU Lesser General Public
18 !* License along with the FV3 dynamical core.
19 !* If not, see <http://www.gnu.org/licenses/>.
20 !***********************************************************************
23 
25 #include <fms_platform.h>
26  use mpp_domains_mod, only: domain2d
27  use fms_io_mod, only: restart_file_type
28  use time_manager_mod, only: time_type
29  use horiz_interp_type_mod, only: horiz_interp_type
30  use mpp_mod, only: mpp_broadcast
31  use platform_mod, only: r8_kind
32  public
33 
34  integer, public, parameter :: r_grid = r8_kind
35 
36  !Several 'auxiliary' structures are introduced here. These are for
37  ! the internal use by certain modules, and although fv_atmos_type
38  ! contains one of each of these structures all memory management
39  ! is performed by the module in question.
40 
41 
42  integer, parameter:: max_step = 1000
43 !--- MAY NEED TO TEST THIS
44 #ifdef OVERLOAD_R4
45  real, parameter:: real_big = 1.e8 ! big enough to cause blowup if used
46 #else
47  real, parameter:: real_big = 1.e30 ! big enough to cause blowup if used
48 #endif
50 
51 
52  integer ::id_ps, id_slp, id_ua, id_va, id_pt, id_omga, id_vort, &
53  id_tm, id_pv, id_zsurf, id_oro, id_sgh, id_divg, id_w, &
54  id_ke, id_te, id_zs, id_ze, id_mq, id_vorts, id_us, id_vs, &
55  id_tq, id_rh, id_c15, id_c25, id_c35, id_c45, &
56  id_f15, id_f25, id_f35, id_f45, id_ctp, &
57  id_ppt, id_ts, id_tb, id_ctt, id_pmask, id_pmaskv2, &
58  id_delp, id_delz, id_zratio, id_ws, id_iw, id_lw, &
59  id_pfhy, id_pfnh, &
60  id_qn, id_qn200, id_qn500, id_qn850, id_qp, id_mdt, &
61  id_qdt, id_aam, id_amdt, &
62  id_acly, id_acl, id_acl2, &
63  id_dbz, id_maxdbz, id_basedbz, id_dbz4km, id_dbztop, id_dbz_m10c, &
64  id_ctz, id_w1km, id_wmaxup, id_wmaxdn, id_cape, id_cin, id_diss
65 
66 ! Selected p-level fields from 3D variables:
67  integer :: id_vort200, id_vort500, id_w500, id_w700
68  integer :: id_vort850, id_w850, id_x850, id_srh25, &
69  id_uh03, id_uh25, id_theta_e, &
70  id_w200, id_s200, id_sl12, id_sl13, id_w5km, id_rain5km, id_w2500m
71  integer :: id_srh1, id_srh3, id_ustm, id_vstm
72 ! NGGPS 31-level diag
73  integer, allocatable :: id_u(:), id_v(:), id_t(:), id_h(:), id_q(:), id_omg(:)
74 
75  integer:: id_u_plev, id_v_plev, id_t_plev, id_h_plev, id_q_plev, id_omg_plev
76 ! IPCC diag
77  integer :: id_rh10, id_rh50, id_rh100, id_rh200, id_rh250, id_rh300, &
78  id_rh500, id_rh700, id_rh850, id_rh925, id_rh1000
79  integer :: id_dp10, id_dp50, id_dp100, id_dp200, id_dp250, id_dp300, &
80  id_dp500, id_dp700, id_dp850, id_dp925, id_dp1000
81 
82  integer :: id_rh1000_cmip, id_rh925_cmip, id_rh850_cmip, id_rh700_cmip, id_rh500_cmip, &
83  id_rh300_cmip, id_rh250_cmip, id_rh100_cmip, id_rh50_cmip, id_rh10_cmip
84 
85  integer :: id_hght3d, id_any_hght
86  integer :: id_u100m, id_v100m, id_w100m
87 
88  ! For initial conditions:
89  integer ic_ps, ic_ua, ic_va, ic_ppt
90  integer ic_sphum
91  integer, allocatable :: id_tracer(:)
92 ! ESM requested diagnostics - dry mass/volume mixing ratios
93  integer, allocatable :: id_tracer_dmmr(:)
94  integer, allocatable :: id_tracer_dvmr(:)
95  real, allocatable :: w_mr(:)
96 
97  real, allocatable :: phalf(:)
98  real, allocatable :: zsurf(:,:)
99  real, allocatable :: zxg(:,:)
100  real, allocatable :: pt1(:)
101 
102  integer :: id_prer, id_prei, id_pres, id_preg
103  integer :: id_qv_dt_gfdlmp, id_t_dt_gfdlmp, id_ql_dt_gfdlmp, id_qi_dt_gfdlmp
104  integer :: id_u_dt_gfdlmp, id_v_dt_gfdlmp
105  integer :: id_t_dt_phys, id_qv_dt_phys, id_ql_dt_phys, id_qi_dt_phys, id_u_dt_phys, id_v_dt_phys
106  integer :: id_intqv, id_intql, id_intqi, id_intqr, id_intqs, id_intqg
107 
108  integer :: id_uw, id_vw, id_hw, id_qvw, id_qlw, id_qiw, id_o3w
109 
110  logical :: initialized = .false.
111  real sphum, liq_wat, ice_wat ! GFDL physics
112  real rainwat, snowwat, graupel
113 
114  real :: efx(max_step), efx_sum, efx_nest(max_step), efx_sum_nest, mtq(max_step), mtq_sum
115  integer :: steps
116 
117  end type fv_diag_type
118 
119 
124  real(kind=R_GRID), allocatable, dimension(:,:,:) :: grid_64, agrid_64
125  real(kind=R_GRID), allocatable, dimension(:,:) :: area_64, area_c_64
126  real(kind=R_GRID), allocatable, dimension(:,:) :: sina_64, cosa_64
127  real(kind=R_GRID), allocatable, dimension(:,:) :: dx_64, dy_64
128  real(kind=R_GRID), allocatable, dimension(:,:) :: dxc_64, dyc_64
129  real(kind=R_GRID), allocatable, dimension(:,:) :: dxa_64, dya_64
130 
131  real, allocatable, dimension(:,:,:) :: grid, agrid
132  real, allocatable, dimension(:,:) :: area, area_c
133  real, allocatable, dimension(:,:) :: rarea, rarea_c
134 
135  real, allocatable, dimension(:,:) :: sina, cosa
136  real, allocatable, dimension(:,:,:) :: e1,e2
137  real, allocatable, dimension(:,:) :: dx, dy
138  real, allocatable, dimension(:,:) :: dxc, dyc
139  real, allocatable, dimension(:,:) :: dxa, dya
140  real, allocatable, dimension(:,:) :: rdx, rdy
141  real, allocatable, dimension(:,:) :: rdxc, rdyc
142  real, allocatable, dimension(:,:) :: rdxa, rdya
143 
144  ! Scalars:
145  real(kind=R_GRID), allocatable :: edge_s(:)
146  real(kind=R_GRID), allocatable :: edge_n(:)
147  real(kind=R_GRID), allocatable :: edge_w(:)
148  real(kind=R_GRID), allocatable :: edge_e(:)
149  ! Vector:
150  real(kind=R_GRID), allocatable :: edge_vect_s(:)
151  real(kind=R_GRID), allocatable :: edge_vect_n(:)
152  real(kind=R_GRID), allocatable :: edge_vect_w(:)
153  real(kind=R_GRID), allocatable :: edge_vect_e(:)
154  ! scalar:
155  real(kind=R_GRID), allocatable :: ex_s(:)
156  real(kind=R_GRID), allocatable :: ex_n(:)
157  real(kind=R_GRID), allocatable :: ex_w(:)
158  real(kind=R_GRID), allocatable :: ex_e(:)
159 
160  real, allocatable :: l2c_u(:,:), l2c_v(:,:)
161  ! divergence Damping:
162  real, allocatable :: divg_u(:,:), divg_v(:,:) !
163  ! del6 diffusion:
164  real, allocatable :: del6_u(:,:), del6_v(:,:) !
165  ! Cubed_2_latlon:
166  real, allocatable :: a11(:,:)
167  real, allocatable :: a12(:,:)
168  real, allocatable :: a21(:,:)
169  real, allocatable :: a22(:,:)
170  ! latlon_2_cubed:
171  real, allocatable :: z11(:,:)
172  real, allocatable :: z12(:,:)
173  real, allocatable :: z21(:,:)
174  real, allocatable :: z22(:,:)
175 
176 ! real, allocatable :: w00(:,:)
177 
178  real, allocatable :: cosa_u(:,:)
179  real, allocatable :: cosa_v(:,:)
180  real, allocatable :: cosa_s(:,:)
181  real, allocatable :: sina_u(:,:)
182  real, allocatable :: sina_v(:,:)
183  real, allocatable :: rsin_u(:,:)
184  real, allocatable :: rsin_v(:,:)
185  real, allocatable :: rsina(:,:)
186  real, allocatable :: rsin2(:,:)
187  real(kind=R_GRID), allocatable :: ee1(:,:,:)
188  real(kind=R_GRID), allocatable :: ee2(:,:,:)
189  real(kind=R_GRID), allocatable :: ec1(:,:,:)
190  real(kind=R_GRID), allocatable :: ec2(:,:,:)
191  real(kind=R_GRID), allocatable :: ew(:,:,:,:)
192  real(kind=R_GRID), allocatable :: es(:,:,:,:)
193 
194 
195  !- 3D Super grid to contain all geometrical factors --
196  ! the 3rd dimension is 9
197  real, allocatable :: sin_sg(:,:,:)
198  real, allocatable :: cos_sg(:,:,:)
199  !--------------------------------------------------
200 
201  ! Unit Normal vectors at cell edges:
202  real(kind=R_GRID), allocatable :: en1(:,:,:)
203  real(kind=R_GRID), allocatable :: en2(:,:,:)
204 
205  ! Extended Cubed cross-edge winds
206  real, allocatable :: eww(:,:)
207  real, allocatable :: ess(:,:)
208 
209  ! Unit vectors for lat-lon grid
210  real(kind=R_GRID), allocatable :: vlon(:,:,:), vlat(:,:,:)
211  real, allocatable :: fc(:,:), f0(:,:)
212 
213  integer, dimension(:,:,:), allocatable :: iinta, jinta, iintb, jintb
214 
215  !Scalar data
216 
217  integer :: npx_g, npy_g, ntiles_g ! global domain
218 
219  real(kind=R_GRID) :: global_area
220  logical :: g_sum_initialized = .false.
221  logical:: sw_corner, se_corner, ne_corner, nw_corner
222 
223  real(kind=R_GRID) :: da_min, da_max, da_min_c, da_max_c
224 
225  real :: acapn, acaps
226  real :: globalarea
227 
228  logical :: latlon = .false.
229  logical :: cubed_sphere = .false.
230  logical :: have_south_pole = .false.
231  logical :: have_north_pole = .false.
232  logical :: stretched_grid = .false.
233 
234  logical :: square_domain = .false.
235 
236  integer, pointer :: grid_type
241 
242  logical, pointer :: nested
243  logical, pointer :: regional
244  logical :: bounded_domain
245 
246  end type fv_grid_type
247 
249 
250  !! FOR EACH VARIABLE IN FV_FLAGS:
251  !! 1. Must be defined here:
252  !! 2. Must be broadcast in fv_atmos_data
253  !! 3. If a namelist entry, a pointer must
254  !! be defined and associated in fv_control
255  !! 4. Must NOT appear in fv_current_grid_mod.
256  !! (this module will soon be removed)
257  !! 5. Must be referenced through Atm%flagstruct,
258  !! not Atm%, unless a convenience
259  !! pointer is defined
260 
261 !-----------------------------------------------------------------------
262 ! Grid descriptor file setup
263 !-----------------------------------------------------------------------
264  character(len=80) :: grid_name = 'Gnomonic'
265  character(len=120):: grid_file = 'Inline'
266  integer :: grid_type = 0
273 ! -> moved to grid_tools
274 
275 ! Momentum (or KE) options:
276  integer :: hord_mt = 9
292 
293  integer :: kord_mt = 8
297 
298  integer :: kord_wz = 8
301 
303  integer :: hord_vt = 9
305 
306 
307 ! Heat & air mass (delp) transport options:
308  integer :: hord_tm = 9
310 
311  integer :: hord_dp = 9
314 
315  integer :: kord_tm = -8
320  integer :: hord_tr = 12
326 
327  integer :: kord_tr = 8
330 
331  real :: scale_z = 0.
332  real :: w_max = 75.
333  real :: z_min = 0.05
334  real :: lim_fac = 1.0
335 
336  integer :: nord = 1
341 
342  integer :: nord_tr = 0
344 
345  real :: dddmp = 0.0
348 
349  real :: d2_bg = 0.0
352 
353  real :: d4_bg = 0.16
358 
359  real :: vtdm4 = 0.0
365 
366  real :: trdm2 = 0.0
367  real :: d2_bg_k1 = 4.
375 
376  real :: d2_bg_k2 = 2.
379 
380  real :: d2_divg_max_k1 = 0.15
381  real :: d2_divg_max_k2 = 0.08
382  real :: damp_k_k1 = 0.2
383  real :: damp_k_k2 = 0.12
384 
386  integer :: n_zs_filter = 0
393 
394  integer :: nord_zs_filter = 4
401 
402  logical :: full_zs_filter = .false.
411 
412  logical :: rf_fast = .false.
418 
419  logical :: consv_am = .false.
420 
421 
422  logical :: do_sat_adj= .false. !
423  logical :: do_f3d = .false. !
424  logical :: no_dycore = .false.
428 
429  logical :: convert_ke = .false.
434 
435  logical :: do_vort_damp = .false.
446 
447  logical :: use_old_omega = .true.
448 ! PG off centering:
449  real :: beta = 0.0
461 
462 #ifdef SW_DYNAMICS
463  integer :: n_sponge = 0
466 
467  real :: d_ext = 0.
472 
473  integer :: nwat = 0
488 
489  logical :: warm_start = .false.
492 
493  logical :: inline_q = .true.
497 
498  logical :: adiabatic = .true.
501 #else
502  integer :: n_sponge = 1
504 
505  real :: d_ext = 0.02
509 
510  integer :: nwat = 3
525 
526  logical :: warm_start = .true.
529 
530  logical :: inline_q = .false.
534  logical :: adiabatic = .false.
535 #endif
536 !-----------------------------------------------------------
537 ! Grid shifting, rotation, and cube transformations:
538 !-----------------------------------------------------------
539  real :: shift_fac = 18.
547 
548 ! Defaults for Schmidt transformation:
549  logical :: do_schmidt = .false.
552  logical :: do_cube_transform = .false.
553  real(kind=R_GRID) :: stretch_fac = 1.
561 
562  real(kind=R_GRID) :: target_lat = -90.
568 
569  real(kind=R_GRID) :: target_lon = 0.
571 
572  !-----------------------------------------------------------------------------------------------
573  ! Example #1a: US regional climate simulation, center located over Oklahoma city: (262.4, 35.4)
574  ! stretching factor: 2.5
575  ! Example #1b: US Hurricane model, center over Miami: (279.7, 25.8)
576  ! stretching factor: 3-5
577  ! Example #2a: South-East Asia Regional Climate H*** (SERACH), Central Taiwan: (121.0, 23.5)
578  ! Example #2b: Typhoon Model: (124.0, 22.0)
579  ! stretching factor: 5-10
580  !-----------------------------------------------------------------------------------------------
581 
582  logical :: reset_eta = .false.
583  real :: p_fac = 0.05
592 
593  real :: a_imp = 0.75
603 
604  integer :: n_split = 0
608 
609  real :: fac_n_spl = 1.0
610  real :: fhouri = 0.0
612 
613  integer :: m_split = 0
614  integer :: k_split = 1
616 
617  logical :: use_logp = .false.
622 
623 ! For doubly periodic domain with sim_phys
624 ! 5km 150 20 (7.5 s) 2
625 !
626 ! Estimates for Gnomonic grids:
627  !===================================================
628  ! dx (km) dt (sc) n_split m_split
629  !===================================================
630  ! C1000: ~10 150 16 3
631  ! C2000: ~5 90 18 (5 s) 2
632  !===================================================
633 ! The nonhydrostatic algorithm is described in Lin 2006, QJ, (submitted)
634 ! C2000 should easily scale to at least 6 * 100 * 100 = 60,000 CPUs
635 ! For a 1024 system: try 6 x 13 * 13 = 1014 CPUs
636 
637  integer :: q_split = 0
641 
642  integer :: print_freq = 0
646 
647  logical :: write_3d_diags = .true.
652 !------------------------------------------
653 ! Model Domain parameters
654 !------------------------------------------
655  integer :: npx
658 
659  integer :: npy
662 
663  integer :: npz
666 #ifdef USE_GFSL63
667  character(24) :: npz_type = 'gfs'
668 #else
669  character(24) :: npz_type = ''
670 #endif
671 
672  integer :: npz_rst = 0
676 
677  integer :: ncnst = 0
682 
683  integer :: pnats = 0
687 
688  integer :: dnats = 0
691  integer :: dnrts = -1
692 
693  integer :: ntiles = 1
697 
698  integer :: ndims = 2 ! Lat-Lon Dims for Grid in Radians
699  integer :: nf_omega = 1
701 
702  integer :: fv_sg_adj = -1
709 
710  real :: sg_cutoff = -1
711 
712  integer :: na_init = 0
717 
718 
719  logical :: nudge_dz = .false.
724 
725  real :: p_ref = 1.e5
731 
732  real :: dry_mass = 98290.
736 
737  integer :: nt_prog = 0
738  integer :: nt_phys = 0
739  real :: tau_h2o = 0.
746 
747 
748  real :: delt_max = 1.
754 
755  real :: d_con = 0.
759 
760  real :: ke_bg = 0.
762 
763  real :: consv_te = 0.
773 
774  real :: tau = 0.
782 
783  real :: rf_cutoff = 30.e2
784 
785  logical :: filter_phys = .false.
786  logical :: dwind_2d = .false.
793 
794  logical :: breed_vortex_inline = .false.
797 
798  logical :: range_warn = .false.
803 
804  logical :: fill = .false.
807  logical :: fill_dp = .false.
813 
814 
815  logical :: fill_wz = .false.
816  logical :: fill_gfs = .true. ! default behavior
817  logical :: check_negative = .false.
818  logical :: non_ortho = .true.
819  logical :: moist_phys = .true.
820  logical :: do_held_suarez = .false.
823  logical :: do_reed_physics = .false.
824  logical :: reed_cond_only = .false.
825  logical :: reproduce_sum = .true.
831 
832  logical :: adjust_dry_mass = .false.
839 
840  logical :: fv_debug = .false.
842  logical :: srf_init = .false.
843  logical :: mountain = .true.
850  logical :: old_divg_damp = .false.
860 
861  logical :: remap_t = .true.
868 
869  logical :: z_tracer = .false.
873 
874  logical :: fv_land = .false.
882 !--------------------------------------------------------------------------------------
883 ! The following options are useful for NWP experiments using datasets on the lat-lon grid
884 !--------------------------------------------------------------------------------------
885  logical :: nudge = .false.
888 
889  logical :: nudge_ic = .false.
892 
893  logical :: ncep_ic = .false.
897 
898  logical :: nggps_ic = .false.
901 
902  logical :: ecmwf_ic = .false.
904 
905  logical :: gfs_phil = .false.
906 
907  logical :: agrid_vel_rst = .false.
911 
912  logical :: use_new_ncep = .false. ! use the NCEP ICs created after 2014/10/22, if want to read CWAT
913  logical :: use_ncep_phy = .false. ! if .T., separate CWAT by weights of liq_wat and liq_ice in FV_IC
914  logical :: fv_diag_ic = .false. ! reconstruct IC from fv_diagnostics on lat-lon grid
915 
916  logical :: external_ic = .false.
923 
924  logical :: external_eta = .false.
928 
929  logical :: read_increment = .false.
930 ! following are namelist parameters for Stochastic Energy Baskscatter dissipation estimate
931  logical :: do_skeb = .false.
932  integer :: skeb_npass = 11
933 ! Default restart files from the "Memphis" latlon FV core:
934  character(len=128) :: res_latlon_dynamics = 'INPUT/fv_rst.res.nc'
936  character(len=128) :: res_latlon_tracers = 'INPUT/atmos_tracers.res.nc'
941 ! The user also needs to copy the "cold start" cubed sphere restart files (fv_core.res.tile1-6)
942 ! to the INPUT dir during runtime
943 !------------------------------------------------
944 ! Parameters related to non-hydrostatic dynamics:
945 !------------------------------------------------
946  logical :: hydrostatic = .true.
948 
949  logical :: phys_hydrostatic = .true.
954 
955  logical :: use_hydro_pressure = .false.
958 
959  logical :: do_uni_zfull = .false.
965 
966  logical :: hybrid_z = .false.
969 
970  logical :: make_nh = .false.
973 
974  logical :: make_hybrid_z = .false.
977 
978  logical :: nudge_qv = .false.
985 
986  real :: add_noise = -1.
989 
990  logical :: butterfly_effect = .false.
993 
994  integer :: a2b_ord = 4
998 
999  integer :: c2l_ord = 4
1004 
1005  integer :: nrows_blend = 0
1006 
1007  real(kind=R_GRID) :: dx_const = 1000.
1010 
1011  real(kind=R_GRID) :: dy_const = 1000.
1014 
1015  real(kind=R_GRID) :: deglat = 15.
1018 
1019  !The following deglat_*, deglon_* options are not used.
1020  real(kind=R_GRID) :: deglon_start = -30., deglon_stop = 30., &
1021  deglat_start = -30., deglat_stop = 30.
1022 
1023  logical :: regional = .false.
1024 
1025  integer :: bc_update_interval = 3
1026 
1027  logical :: regional_bcs_from_gsi = .false.
1028 
1029  logical :: write_restart_with_bcs = .false.
1030 
1032  integer, pointer :: grid_number
1033 
1034  !f1p
1035  logical :: adj_mass_vmr = .false. !TER: This is to reproduce answers for verona patch. This default can be changed
1036  ! to .true. in the next city release if desired
1037 
1038  !integer, pointer :: test_case
1039  !real, pointer :: alpha
1040 
1041  end type fv_flags_type
1042 
1044 
1045  !!! CLEANUP: could we have pointers to np[xyz], nest_domain, and the index/weight arrays?
1046 
1047  real, allocatable, dimension(:,:,:) :: west_t1, east_t1, south_t1, north_t1
1048  real, allocatable, dimension(:,:,:) :: west_t0, east_t0, south_t0, north_t0
1049 
1050  integer :: istag, jstag
1051 
1052  logical :: allocated = .false.
1053  logical :: initialized = .false.
1054 
1055  end type fv_nest_bc_type_3d
1056 
1058 
1059  real, allocatable, dimension(:,:,:,:) :: west_t1, east_t1, south_t1, north_t1
1060  real, allocatable, dimension(:,:,:,:) :: west_t0, east_t0, south_t0, north_t0
1061 
1062  integer :: istag, jstag
1063 
1064  logical :: allocated = .false.
1065  logical :: initialized = .false.
1066 
1067  end type fv_nest_bc_type_4d
1068 
1070  !Interpolation arrays for grid nesting
1071  logical :: on_level ! indicate if current processor on this level.
1072  logical :: do_remap_bc
1073  integer, allocatable, dimension(:,:,:) :: ind_h, ind_u, ind_v, ind_b ! I don't think these are necessary since BC interpolation is done locally
1074  real, allocatable, dimension(:,:,:) :: wt_h, wt_u, wt_v, wt_b
1075  end type nest_level_type
1076 
1078 
1079 !nested grid flags:
1080 
1081  integer :: refinement = 3
1087 
1088 
1089  integer :: parent_tile = 1
1095 
1096  logical :: nested = .false.
1097 
1098  integer :: nestbctype = 1
1099  integer :: nsponge = 0
1100  integer :: nestupdate = 7
1102 
1103  logical :: twowaynest = .false.
1106  integer :: ioffset, joffset
1107  integer :: nlevel = 0 ! levels down from top-most domain
1108 
1109  integer :: nest_timestep = 0
1110  integer :: tracer_nest_timestep = 0
1111  real :: s_weight = 1.e-6
1112  logical :: first_step = .true.
1113  integer :: refinement_of_global = 1
1114  integer :: npx_global
1115  integer :: upoff = 1
1116  integer :: isu = -999, ieu = -1000, jsu = -999, jeu = -1000
1117  real :: update_blend = 1. ! option for controlling how much "blending" is done during two-way update
1118  logical, allocatable :: do_remap_bc(:)
1119 
1120  !nest_domain now a global structure defined in fv_mp_mod
1121  !type(nest_domain_type) :: nest_domain !Structure holding link from this grid to its parent
1122  !type(nest_domain_type), allocatable :: nest_domain_all(:)
1123  integer :: num_nest_level ! number of nest levels.
1124  type(nest_level_type), allocatable :: nest(:) ! store data for each level.
1125 
1126  !Interpolation arrays for grid nesting
1127  integer, allocatable, dimension(:,:,:) :: ind_h, ind_u, ind_v, ind_b
1128  real, allocatable, dimension(:,:,:) :: wt_h, wt_u, wt_v, wt_b
1129 
1130  !These arrays are not allocated by allocate_fv_atmos_type; but instead
1131  !allocated for all grids, regardless of whether the grid is
1132  !on a PE of a concurrent run.
1133  logical, allocatable, dimension(:) :: child_grids
1134 
1135  logical :: parent_proc, child_proc
1136  logical :: parent_of_twoway = .false.
1137 
1138  !These are for time-extrapolated BCs
1139  type(fv_nest_bc_type_3d) :: delp_bc, u_bc, v_bc, uc_bc, vc_bc, divg_bc
1140  type(fv_nest_bc_type_3d), allocatable, dimension(:) :: q_bc
1141 #ifndef SW_DYNAMICS
1142  type(fv_nest_bc_type_3d) :: pt_bc, w_bc, delz_bc
1143 #ifdef USE_COND
1144  type(fv_nest_bc_type_3d) :: q_con_bc
1145 #ifdef MOIST_CAPPA
1146  type(fv_nest_bc_type_3d) :: cappa_bc
1147 #endif
1148 #endif
1149 #endif
1150 
1151  !points to same parent grid as does Atm%parent_grid
1152  type(fv_atmos_type), pointer :: parent_grid => null()
1153 
1154 
1155  !These are for tracer flux BCs
1156  logical :: do_flux_bcs, do_2way_flux_bcs
1157  type(restart_file_type) :: bcfile_ne, bcfile_sw
1158 
1159  end type fv_nest_type
1160 
1162 
1163  real, _allocatable :: phys_t_dt(:,:,:)
1164  real, _allocatable :: phys_qv_dt(:,:,:)
1165  real, _allocatable :: phys_ql_dt(:,:,:)
1166  real, _allocatable :: phys_qi_dt(:,:,:)
1167  real, _allocatable :: phys_u_dt(:,:,:)
1168  real, _allocatable :: phys_v_dt(:,:,:)
1169 
1170  end type phys_diag_type
1171 
1177  module procedure allocate_fv_nest_bc_type_3d
1178  module procedure allocate_fv_nest_bc_type_3d_atm
1179  end interface
1180 
1184  module procedure deallocate_fv_nest_bc_type_3d
1185  end interface
1186 
1188 
1189  integer :: is, ie, js, je
1190  integer :: isd, ied, jsd, jed
1191  integer :: isc, iec, jsc, jec
1192 
1193  integer :: ng = 3 !default
1194 
1195  end type fv_grid_bounds_type
1196 
1198 
1199  integer :: is_north ,ie_north ,js_north ,je_north &
1200  ,is_south ,ie_south ,js_south ,je_south &
1201  ,is_east ,ie_east ,js_east ,je_east &
1202  ,is_west ,ie_west ,js_west ,je_west
1203 
1204  integer :: is_north_uvs ,ie_north_uvs ,js_north_uvs ,je_north_uvs &
1205  ,is_south_uvs ,ie_south_uvs ,js_south_uvs ,je_south_uvs &
1206  ,is_east_uvs ,ie_east_uvs ,js_east_uvs ,je_east_uvs &
1207  ,is_west_uvs ,ie_west_uvs ,js_west_uvs ,je_west_uvs
1208 
1209  integer :: is_north_uvw ,ie_north_uvw ,js_north_uvw ,je_north_uvw &
1210  ,is_south_uvw ,ie_south_uvw ,js_south_uvw ,je_south_uvw &
1211  ,is_east_uvw ,ie_east_uvw ,js_east_uvw ,je_east_uvw &
1212  ,is_west_uvw ,ie_west_uvw ,js_west_uvw ,je_west_uvw
1213 
1215 
1217 
1218  logical :: allocated = .false.
1219  logical :: dummy = .false. ! same as grids_on_this_pe(n)
1220  integer :: grid_number = 1
1221  character(len=32) :: nml_filename = "input.nml"
1222 
1223  !Timestep-related variables.
1224 
1225  type(time_type) :: time_init, time, run_length, time_end, time_step_atmos
1226 
1227 #ifdef GFS_PHYS
1228  !--- DUMMY for backwards-compatibility. Will be removed
1229  real, dimension(2048) :: fdiag = 0.
1230 #endif
1231 
1232  logical :: grid_active = .true. !Always active for now
1233 
1234  !This is kept here instead of in neststruct% simply for convenience
1235  type(fv_atmos_type), pointer :: parent_grid => null()
1236 
1237 !-----------------------------------------------------------------------
1238 ! Five prognostic state variables for the f-v dynamics
1239 !-----------------------------------------------------------------------
1240 ! dyn_state:
1241 ! D-grid prognostatic variables: u, v, and delp (and other scalars)
1242 !
1243 ! o--------u(i,j+1)----------o
1244 ! | | |
1245 ! | | |
1246 ! v(i,j)------scalar(i,j)----v(i+1,j)
1247 ! | | |
1248 ! | | |
1249 ! o--------u(i,j)------------o
1250 !
1251 ! The C grid component is "diagnostic" in that it is predicted every time step
1252 ! from the D grid variables.
1253  real, _allocatable :: u(:,:,:) _null
1254  real, _allocatable :: v(:,:,:) _null
1255  real, _allocatable :: pt(:,:,:) _null
1256  real, _allocatable :: delp(:,:,:) _null
1257  real, _allocatable :: q(:,:,:,:) _null
1258  real, _allocatable :: qdiag(:,:,:,:) _null
1259 
1260 !----------------------
1261 ! non-hydrostatic state:
1262 !----------------------------------------------------------------------
1263  real, _allocatable :: w(:,:,:) _null
1264  real, _allocatable :: delz(:,:,:) _null
1265  real, _allocatable :: ze0(:,:,:) _null
1266  real, _allocatable :: q_con(:,:,:) _null
1267 
1268 !-----------------------------------------------------------------------
1269 ! Auxilliary pressure arrays:
1270 ! The 5 vars below can be re-computed from delp and ptop.
1271 !-----------------------------------------------------------------------
1272 ! dyn_aux:
1273  real, _allocatable :: ps (:,:) _null
1274  real, _allocatable :: pe (:,:,: ) _null
1275  real, _allocatable :: pk (:,:,:) _null
1276  real, _allocatable :: peln(:,:,:) _null
1277  real, _allocatable :: pkz (:,:,:) _null
1278 
1279 ! For phys coupling:
1280  real, _allocatable :: u_srf(:,:) _null
1281  real, _allocatable :: v_srf(:,:) _null
1282  real, _allocatable :: sgh(:,:) _null
1283  real, _allocatable :: oro(:,:) _null
1284  real, _allocatable :: ts(:,:) _null
1285 ! For stochastic kinetic energy backscatter (SKEB)
1286  real, _allocatable :: diss_est(:,:,:) _null
1287 
1288 !-----------------------------------------------------------------------
1289 ! Others:
1290 !-----------------------------------------------------------------------
1291  real, _allocatable :: phis(:,:) _null
1292  real, _allocatable :: omga(:,:,:) _null
1293  real, _allocatable :: ua(:,:,:) _null
1294  real, _allocatable :: va(:,:,:) _null
1295  real, _allocatable :: uc(:,:,:) _null
1296  real, _allocatable :: vc(:,:,:) _null
1297 
1298  real, _allocatable :: ak(:) _null
1299  real, _allocatable :: bk(:) _null
1300 
1301  integer :: ks
1302 
1303 ! Accumulated Mass flux arrays
1304  real, _allocatable :: mfx(:,:,:) _null
1305  real, _allocatable :: mfy(:,:,:) _null
1306 ! Accumulated Courant number arrays
1307  real, _allocatable :: cx(:,:,:) _null
1308  real, _allocatable :: cy(:,:,:) _null
1309 
1310  type(fv_flags_type) :: flagstruct
1311 
1312  !! Convenience pointers
1313  integer, pointer :: npx, npy, npz, ncnst, ng
1314 
1315  integer, allocatable, dimension(:) :: pelist
1316 
1318 
1319  type(fv_regional_bc_bounds_type) :: regional_bc_bounds
1320 
1321  type(domain2d) :: domain
1322 #if defined(SPMD)
1323 
1324  type(domain2d) :: domain_for_coupler
1325 
1326  integer :: num_contact, npes_per_tile, global_tile, tile_of_mosaic, npes_this_grid
1327  integer :: layout(2), io_layout(2) = (/ 1,1 /)
1336 
1337 #endif
1338  !These do not actually belong to the grid, but to the process
1339  !integer :: masterproc
1340  !integer :: gid
1341 
1342 !!!!!!!!!!!!!!!!
1343 ! From fv_grid_tools
1344 !!!!!!!!!!!!!!!!
1345 
1346 
1347  real :: ptop
1348 
1349  type(fv_grid_type) :: gridstruct
1350 
1351 
1352 !!!!!!!!!!!!!!!!
1353 !fv_diagnostics!
1354 !!!!!!!!!!!!!!!!
1355 
1356  type(fv_diag_type) :: idiag
1357 
1358 !!!!!!!!!!!!!!
1359 ! From fv_io !
1360 !!!!!!!!!!!!!!
1361  type(restart_file_type) :: fv_restart, sst_restart, fv_tile_restart, &
1362  rsf_restart, mg_restart, lnd_restart, tra_restart
1363 
1364  type(fv_nest_type) :: neststruct
1365 
1366  !Hold on to coarse-grid global grid, so we don't have to waste processor time getting it again when starting to do grid nesting
1367  real(kind=R_GRID), allocatable, dimension(:,:,:,:) :: grid_global
1368 
1369  integer :: atmos_axes(4)
1370 
1371  type(phys_diag_type) :: phys_diag
1372 
1373  end type fv_atmos_type
1374 
1375 contains
1376 
1380  subroutine allocate_fv_atmos_type(Atm, isd_in, ied_in, jsd_in, jed_in, is_in, ie_in, js_in, je_in, &
1381  npx_in, npy_in, npz_in, ndims_in, ncnst_in, nq_in, dummy, alloc_2d, ngrids_in)
1383  !WARNING: Before calling this routine, be sure to have set up the
1384  ! proper domain parameters from the namelists (as is done in
1385  ! fv_control.F90)
1386 
1387  implicit none
1388  type(fv_atmos_type), intent(INOUT), target :: Atm
1389  integer, intent(IN) :: isd_in, ied_in, jsd_in, jed_in, is_in, ie_in, js_in, je_in
1390  integer, intent(IN) :: npx_in, npy_in, npz_in, ndims_in, ncnst_in, nq_in
1391  logical, intent(IN) :: dummy, alloc_2d
1392  integer, intent(IN) :: ngrids_in
1393  integer:: isd, ied, jsd, jed, is, ie, js, je
1394  integer:: npx, npy, npz, ndims, ncnst, nq, ng
1395 
1396  !For 2D utility arrays
1397  integer:: isd_2d, ied_2d, jsd_2d, jed_2d, is_2d, ie_2d, js_2d, je_2d
1398  integer:: npx_2d, npy_2d, npz_2d, ndims_2d, ncnst_2d, nq_2d, ng_2d
1399 
1400  integer :: i,j,k, ns, n
1401 
1402  if (atm%allocated) return
1403 
1404  if (dummy) then
1405  isd = 0
1406  ied= -1
1407  jsd= 0
1408  jed= -1
1409  is= 0
1410  ie= -1
1411  js= 0
1412  je= -1
1413  npx= 1
1414  npy= 1
1415  npz= 1
1416  ndims= 1
1417  ncnst= 1
1418  nq= 1
1419  else
1420  isd = isd_in
1421  ied= ied_in
1422  jsd= jsd_in
1423  jed= jed_in
1424  is= is_in
1425  ie= ie_in
1426  js= js_in
1427  je= je_in
1428  npx= npx_in
1429  npy= npy_in
1430  npz= npz_in
1431  ndims= ndims_in
1432  ncnst= ncnst_in
1433  nq= nq_in
1434  endif
1435 
1436  if ((.not. dummy) .or. alloc_2d) then
1437  isd_2d = isd_in
1438  ied_2d= ied_in
1439  jsd_2d= jsd_in
1440  jed_2d= jed_in
1441  is_2d= is_in
1442  ie_2d= ie_in
1443  js_2d= js_in
1444  je_2d= je_in
1445  npx_2d= npx_in
1446  npy_2d= npy_in
1447  npz_2d= npz_in
1448  ndims_2d= ndims_in
1449  ncnst_2d= ncnst_in
1450  nq_2d= nq_in
1451  else
1452  isd_2d = 0
1453  ied_2d= -1
1454  jsd_2d= 0
1455  jed_2d= -1
1456  is_2d= 0
1457  ie_2d= -1
1458  js_2d= 0
1459  je_2d= -1
1460  npx_2d= 1
1461  npy_2d= 1
1462  npz_2d= npz_in !for ak, bk, which are 1D arrays and thus OK to allocate
1463  ndims_2d= 1
1464  ncnst_2d= 1
1465  nq_2d= 1
1466  endif
1467 
1468 !This should be set up in fv_mp_mod
1469 !!$ Atm%bd%isd = isd_in
1470 !!$ Atm%bd%ied = ied_in
1471 !!$ Atm%bd%jsd = jsd_in
1472 !!$ Atm%bd%jed = jed_in
1473 !!$
1474 !!$ Atm%bd%is = is_in
1475 !!$ Atm%bd%ie = ie_in
1476 !!$ Atm%bd%js = js_in
1477 !!$ Atm%bd%je = je_in
1478 !!$
1479 !!$ Atm%bd%isc = Atm%bd%is
1480 !!$ Atm%bd%iec = Atm%bd%ie
1481 !!$ Atm%bd%jsc = Atm%bd%js
1482 !!$ Atm%bd%jec = Atm%bd%je
1483 
1484  !Convenience pointers
1485  atm%npx => atm%flagstruct%npx
1486  atm%npy => atm%flagstruct%npy
1487  atm%npz => atm%flagstruct%npz
1488  atm%ncnst => atm%flagstruct%ncnst
1489 
1490  atm%ng => atm%bd%ng
1491 
1492 !!$ Atm%npx = npx_in
1493 !!$ Atm%npy = npy_in
1494 !!$ Atm%npz = npz_in
1495  atm%flagstruct%ndims = ndims_in
1496 
1497  allocate ( atm%u(isd:ied ,jsd:jed+1,npz) )
1498  allocate ( atm%v(isd:ied+1,jsd:jed ,npz) )
1499 
1500  allocate ( atm%pt(isd:ied ,jsd:jed ,npz) )
1501  allocate ( atm%delp(isd:ied ,jsd:jed ,npz) )
1502  allocate ( atm%q(isd:ied ,jsd:jed ,npz, nq) )
1503  allocate (atm%qdiag(isd:ied ,jsd:jed ,npz, nq+1:ncnst) )
1504 
1505  ! Allocate Auxilliary pressure arrays
1506  allocate ( atm%ps(isd:ied ,jsd:jed) )
1507  allocate ( atm%pe(is-1:ie+1, npz+1,js-1:je+1) )
1508  allocate ( atm%pk(is:ie ,js:je , npz+1) )
1509  allocate ( atm%peln(is:ie,npz+1,js:je) )
1510  allocate ( atm%pkz(is:ie,js:je,npz) )
1511 
1512  allocate ( atm%u_srf(is:ie,js:je) )
1513  allocate ( atm%v_srf(is:ie,js:je) )
1514 
1515  if ( atm%flagstruct%fv_land ) then
1516  allocate ( atm%sgh(is:ie,js:je) )
1517  allocate ( atm%oro(is:ie,js:je) )
1518  else
1519  allocate ( atm%oro(1,1) )
1520  endif
1521 
1522  ! Allocate others
1523  allocate ( atm%diss_est(isd:ied ,jsd:jed ,npz) )
1524  allocate ( atm%ts(is:ie,js:je) )
1525  allocate ( atm%phis(isd:ied ,jsd:jed ) )
1526  allocate ( atm%omga(isd:ied ,jsd:jed ,npz) ); atm%omga=0.
1527  allocate ( atm%ua(isd:ied ,jsd:jed ,npz) )
1528  allocate ( atm%va(isd:ied ,jsd:jed ,npz) )
1529  allocate ( atm%uc(isd:ied+1,jsd:jed ,npz) )
1530  allocate ( atm%vc(isd:ied ,jsd:jed+1,npz) )
1531  ! For tracer transport:
1532  allocate ( atm%mfx(is:ie+1, js:je, npz) )
1533  allocate ( atm%mfy(is:ie , js:je+1,npz) )
1534  allocate ( atm%cx(is:ie+1, jsd:jed, npz) )
1535  allocate ( atm%cy(isd:ied ,js:je+1, npz) )
1536 
1537  allocate ( atm%ak(npz_2d+1) )
1538  allocate ( atm%bk(npz_2d+1) )
1539 
1540  !--------------------------
1541  ! Non-hydrostatic dynamics:
1542  !--------------------------
1543  if ( atm%flagstruct%hydrostatic ) then
1544  !Note length-one initialization if hydrostatic = .true.
1545  allocate ( atm%w(isd:isd, jsd:jsd ,1) )
1546  allocate ( atm%delz(is:is, js:js ,1) )
1547  allocate ( atm%ze0(is:is, js:js ,1) )
1548  else
1549  allocate ( atm%w(isd:ied, jsd:jed ,npz ) )
1550  allocate ( atm%delz(is:ie, js:je ,npz) )
1551  if( atm%flagstruct%hybrid_z ) then
1552  allocate ( atm%ze0(is:ie, js:je ,npz+1) )
1553  else
1554  allocate ( atm%ze0(is:is, js:js ,1) )
1555  endif
1556  ! allocate ( mono(isd:ied, jsd:jed, npz))
1557  endif
1558 
1559 #ifdef USE_COND
1560  allocate ( atm%q_con(isd:ied,jsd:jed,1:npz) )
1561 #else
1562  allocate ( atm%q_con(isd:isd,jsd:jsd,1) )
1563 #endif
1564 
1565 ! Notes by SJL
1566 ! Place the memory in the optimal shared mem space
1567 ! This will help the scaling with OpenMP
1568 !$OMP parallel do default(none) shared(is,ie,js,je,isd,ied,jsd,jed,npz,Atm,nq,ncnst)
1569  do k=1, npz
1570  do j=jsd, jed
1571  do i=isd, ied
1572  atm%ua(i,j,k) = real_big
1573  atm%va(i,j,k) = real_big
1574  atm%pt(i,j,k) = real_big
1575  atm%delp(i,j,k) = real_big
1576  enddo
1577  enddo
1578  do j=jsd, jed+1
1579  do i=isd, ied
1580  atm%u(i,j,k) = 0.
1581  atm%vc(i,j,k) = real_big
1582  enddo
1583  enddo
1584  do j=jsd, jed
1585  do i=isd, ied+1
1586  atm%v(i,j,k) = 0.
1587  atm%uc(i,j,k) = real_big
1588  enddo
1589  enddo
1590  if ( .not. atm%flagstruct%hydrostatic ) then
1591  do j=jsd, jed
1592  do i=isd, ied
1593  atm%w(i,j,k) = real_big
1594  enddo
1595  enddo
1596  do j=js, je
1597  do i=is, ie
1598  atm%delz(i,j,k) = real_big
1599  enddo
1600  enddo
1601  endif
1602  do n=1,nq
1603  do j=jsd, jed
1604  do i=isd, ied
1605  atm%q(i,j,k,n) = real_big
1606  enddo
1607  enddo
1608  enddo
1609  do n=nq+1,ncnst
1610  do j=jsd, jed
1611  do i=isd, ied
1612  atm%qdiag(i,j,k,n) = real_big
1613  enddo
1614  enddo
1615  enddo
1616  enddo
1617  do j=js, je
1618  do i=is, ie
1619  atm%ts(i,j) = 300.
1620  atm%phis(i,j) = real_big
1621  enddo
1622  enddo
1623 
1624  allocate ( atm%gridstruct% area(isd_2d:ied_2d ,jsd_2d:jed_2d ) ) ! Cell Centered
1625  allocate ( atm%gridstruct% area_64(isd_2d:ied_2d ,jsd_2d:jed_2d ) ) ! Cell Centered
1626  allocate ( atm%gridstruct%rarea(isd_2d:ied_2d ,jsd_2d:jed_2d ) ) ! Cell Centered
1627 
1628  allocate ( atm%gridstruct% area_c(isd_2d:ied_2d+1,jsd_2d:jed_2d+1) ) ! Cell Corners
1629  allocate ( atm%gridstruct% area_c_64(isd_2d:ied_2d+1,jsd_2d:jed_2d+1) )! Cell Corners
1630  allocate ( atm%gridstruct%rarea_c(isd_2d:ied_2d+1,jsd_2d:jed_2d+1) ) ! Cell Corners
1631 
1632  allocate ( atm%gridstruct% dx(isd_2d:ied_2d ,jsd_2d:jed_2d+1) )
1633  allocate ( atm%gridstruct% dx_64(isd_2d:ied_2d ,jsd_2d:jed_2d+1) )
1634  allocate ( atm%gridstruct%rdx(isd_2d:ied_2d ,jsd_2d:jed_2d+1) )
1635  allocate ( atm%gridstruct% dy(isd_2d:ied_2d+1,jsd_2d:jed_2d ) )
1636  allocate ( atm%gridstruct% dy_64(isd_2d:ied_2d+1,jsd_2d:jed_2d ) )
1637  allocate ( atm%gridstruct%rdy(isd_2d:ied_2d+1,jsd_2d:jed_2d ) )
1638 
1639  allocate ( atm%gridstruct% dxc(isd_2d:ied_2d+1,jsd_2d:jed_2d ) )
1640  allocate ( atm%gridstruct% dxc_64(isd_2d:ied_2d+1,jsd_2d:jed_2d ) )
1641  allocate ( atm%gridstruct%rdxc(isd_2d:ied_2d+1,jsd_2d:jed_2d ) )
1642  allocate ( atm%gridstruct% dyc(isd_2d:ied_2d ,jsd_2d:jed_2d+1) )
1643  allocate ( atm%gridstruct% dyc_64(isd_2d:ied_2d ,jsd_2d:jed_2d+1) )
1644  allocate ( atm%gridstruct%rdyc(isd_2d:ied_2d ,jsd_2d:jed_2d+1) )
1645 
1646  allocate ( atm%gridstruct% dxa(isd_2d:ied_2d ,jsd_2d:jed_2d ) )
1647  allocate ( atm%gridstruct% dxa_64(isd_2d:ied_2d ,jsd_2d:jed_2d ) )
1648  allocate ( atm%gridstruct%rdxa(isd_2d:ied_2d ,jsd_2d:jed_2d ) )
1649  allocate ( atm%gridstruct% dya(isd_2d:ied_2d ,jsd_2d:jed_2d ) )
1650  allocate ( atm%gridstruct% dya_64(isd_2d:ied_2d ,jsd_2d:jed_2d ) )
1651  allocate ( atm%gridstruct%rdya(isd_2d:ied_2d ,jsd_2d:jed_2d ) )
1652 
1653  allocate ( atm%gridstruct%grid (isd_2d:ied_2d+1,jsd_2d:jed_2d+1,1:ndims_2d) )
1654  allocate ( atm%gridstruct%grid_64 (isd_2d:ied_2d+1,jsd_2d:jed_2d+1,1:ndims_2d) )
1655  allocate ( atm%gridstruct%agrid(isd_2d:ied_2d ,jsd_2d:jed_2d ,1:ndims_2d) )
1656  allocate ( atm%gridstruct%agrid_64(isd_2d:ied_2d ,jsd_2d:jed_2d ,1:ndims_2d) )
1657  allocate ( atm%gridstruct% sina(isd_2d:ied_2d+1,jsd_2d:jed_2d+1) ) ! SIN(angle of intersection)
1658  allocate ( atm%gridstruct% sina_64(isd_2d:ied_2d+1,jsd_2d:jed_2d+1) ) ! SIN(angle of intersection)
1659  allocate ( atm%gridstruct%rsina(is_2d:ie_2d+1,js_2d:je_2d+1) ) ! Why is the size different?
1660  allocate ( atm%gridstruct% cosa(isd_2d:ied_2d+1,jsd_2d:jed_2d+1) ) ! COS(angle of intersection)
1661  allocate ( atm%gridstruct% cosa_64(isd_2d:ied_2d+1,jsd_2d:jed_2d+1) ) ! COS(angle of intersection)
1662 
1663  allocate ( atm%gridstruct% e1(3,isd_2d:ied_2d+1,jsd_2d:jed_2d+1) )
1664  allocate ( atm%gridstruct% e2(3,isd_2d:ied_2d+1,jsd_2d:jed_2d+1) )
1665 
1666  allocate (atm%gridstruct%iinta(4, isd_2d:ied_2d ,jsd_2d:jed_2d), &
1667  atm%gridstruct%jinta(4, isd_2d:ied_2d ,jsd_2d:jed_2d), &
1668  atm%gridstruct%iintb(4, is_2d:ie_2d+1 ,js_2d:je_2d+1), &
1669  atm%gridstruct%jintb(4, is_2d:ie_2d+1 ,js_2d:je_2d+1) )
1670 
1671  allocate ( atm%gridstruct%edge_s(npx_2d) )
1672  allocate ( atm%gridstruct%edge_n(npx_2d) )
1673  allocate ( atm%gridstruct%edge_w(npy_2d) )
1674  allocate ( atm%gridstruct%edge_e(npy_2d) )
1675 
1676  allocate ( atm%gridstruct%edge_vect_s(isd_2d:ied_2d) )
1677  allocate ( atm%gridstruct%edge_vect_n(isd_2d:ied_2d) )
1678  allocate ( atm%gridstruct%edge_vect_w(jsd_2d:jed_2d) )
1679  allocate ( atm%gridstruct%edge_vect_e(jsd_2d:jed_2d) )
1680 
1681  allocate ( atm%gridstruct%ex_s(npx_2d) )
1682  allocate ( atm%gridstruct%ex_n(npx_2d) )
1683  allocate ( atm%gridstruct%ex_w(npy_2d) )
1684  allocate ( atm%gridstruct%ex_e(npy_2d) )
1685 
1686 
1687  allocate ( atm%gridstruct%l2c_u(is_2d:ie_2d, js_2d:je_2d+1) )
1688  allocate ( atm%gridstruct%l2c_v(is_2d:ie_2d+1,js_2d:je_2d) )
1689 
1690  ! For diveregnce damping:
1691  allocate ( atm%gridstruct%divg_u(isd_2d:ied_2d, jsd_2d:jed_2d+1) )
1692  allocate ( atm%gridstruct%divg_v(isd_2d:ied_2d+1,jsd_2d:jed_2d) )
1693  ! For del6 diffusion:
1694  allocate ( atm%gridstruct%del6_u(isd_2d:ied_2d, jsd_2d:jed_2d+1) )
1695  allocate ( atm%gridstruct%del6_v(isd_2d:ied_2d+1,jsd_2d:jed_2d) )
1696 
1697  allocate ( atm%gridstruct%z11(is_2d-1:ie_2d+1,js_2d-1:je_2d+1) )
1698  allocate ( atm%gridstruct%z12(is_2d-1:ie_2d+1,js_2d-1:je_2d+1) )
1699  allocate ( atm%gridstruct%z21(is_2d-1:ie_2d+1,js_2d-1:je_2d+1) )
1700  allocate ( atm%gridstruct%z22(is_2d-1:ie_2d+1,js_2d-1:je_2d+1) )
1701 
1702 ! if (.not.Atm%flagstruct%hydrostatic) &
1703 ! allocate ( Atm%gridstruct%w00(is_2d-1:ie_2d+1,js_2d-1:je_2d+1) )
1704 
1705  allocate ( atm%gridstruct%a11(is_2d-1:ie_2d+1,js_2d-1:je_2d+1) )
1706  allocate ( atm%gridstruct%a12(is_2d-1:ie_2d+1,js_2d-1:je_2d+1) )
1707  allocate ( atm%gridstruct%a21(is_2d-1:ie_2d+1,js_2d-1:je_2d+1) )
1708  allocate ( atm%gridstruct%a22(is_2d-1:ie_2d+1,js_2d-1:je_2d+1) )
1709  allocate ( atm%gridstruct%vlon(is_2d-2:ie_2d+2,js_2d-2:je_2d+2,3) )
1710  allocate ( atm%gridstruct%vlat(is_2d-2:ie_2d+2,js_2d-2:je_2d+2,3) )
1711  ! Coriolis parameters:
1712  allocate ( atm%gridstruct%f0(isd_2d:ied_2d ,jsd_2d:jed_2d ) )
1713  allocate ( atm%gridstruct%fC(isd_2d:ied_2d+1,jsd_2d:jed_2d+1) )
1714 
1715  ! Corner unit vectors:
1716  allocate( atm%gridstruct%ee1(3,isd_2d:ied_2d+1,jsd_2d:jed_2d+1) )
1717  allocate( atm%gridstruct%ee2(3,isd_2d:ied_2d+1,jsd_2d:jed_2d+1) )
1718 
1719  ! Center unit vectors:
1720  allocate( atm%gridstruct%ec1(3,isd_2d:ied_2d,jsd_2d:jed_2d) )
1721  allocate( atm%gridstruct%ec2(3,isd_2d:ied_2d,jsd_2d:jed_2d) )
1722 
1723  ! Edge unit vectors:
1724  allocate( atm%gridstruct%ew(3,isd_2d:ied_2d+1,jsd_2d:jed_2d, 2) )
1725  allocate( atm%gridstruct%es(3,isd_2d:ied_2d ,jsd_2d:jed_2d+1,2) )
1726 
1727  ! Edge unit "Normal" vectors: (for omega computation)
1728  allocate( atm%gridstruct%en1(3,is_2d:ie_2d, js_2d:je_2d+1) ) ! E-W edges
1729  allocate( atm%gridstruct%en2(3,is_2d:ie_2d+1,js_2d:je_2d ) ) ! N-S egdes
1730 
1731  allocate ( atm%gridstruct%cosa_u(isd_2d:ied_2d+1,jsd_2d:jed_2d) )
1732  allocate ( atm%gridstruct%sina_u(isd_2d:ied_2d+1,jsd_2d:jed_2d) )
1733  allocate ( atm%gridstruct%rsin_u(isd_2d:ied_2d+1,jsd_2d:jed_2d) )
1734 
1735  allocate ( atm%gridstruct%cosa_v(isd_2d:ied_2d,jsd_2d:jed_2d+1) )
1736  allocate ( atm%gridstruct%sina_v(isd_2d:ied_2d,jsd_2d:jed_2d+1) )
1737  allocate ( atm%gridstruct%rsin_v(isd_2d:ied_2d,jsd_2d:jed_2d+1) )
1738 
1739  allocate ( atm%gridstruct%cosa_s(isd_2d:ied_2d,jsd_2d:jed_2d) ) ! cell center
1740 
1741  allocate ( atm%gridstruct%rsin2(isd_2d:ied_2d,jsd_2d:jed_2d) ) ! cell center
1742 
1743 
1744  ! Super (composite) grid:
1745 
1746  ! 9---4---8
1747  ! | |
1748  ! 1 5 3
1749  ! | |
1750  ! 6---2---7
1751 
1752  allocate ( atm%gridstruct%cos_sg(isd_2d:ied_2d,jsd_2d:jed_2d,9) )
1753  allocate ( atm%gridstruct%sin_sg(isd_2d:ied_2d,jsd_2d:jed_2d,9) )
1754 
1755  allocate( atm%gridstruct%eww(3,4) )
1756  allocate( atm%gridstruct%ess(3,4) )
1757 
1758  if (atm%neststruct%nested) then
1759 
1760 
1761  allocate(atm%neststruct%ind_h(isd:ied,jsd:jed,4))
1762  allocate(atm%neststruct%ind_u(isd:ied,jsd:jed+1,4))
1763  allocate(atm%neststruct%ind_v(isd:ied+1,jsd:jed,4))
1764 
1765  allocate(atm%neststruct%wt_h(isd:ied, jsd:jed, 4))
1766  allocate(atm%neststruct%wt_u(isd:ied, jsd:jed+1,4))
1767  allocate(atm%neststruct%wt_v(isd:ied+1, jsd:jed, 4))
1768  allocate(atm%neststruct%ind_b(isd:ied+1,jsd:jed+1,4))
1769  allocate(atm%neststruct%wt_b(isd:ied+1, jsd:jed+1,4))
1770 
1771  ns = atm%neststruct%nsponge
1772 
1773  call allocate_fv_nest_bc_type(atm%neststruct%delp_BC,atm,ns,0,0,dummy)
1774  call allocate_fv_nest_bc_type(atm%neststruct%u_BC,atm,ns,0,1,dummy)
1775  call allocate_fv_nest_bc_type(atm%neststruct%v_BC,atm,ns,1,0,dummy)
1776  call allocate_fv_nest_bc_type(atm%neststruct%uc_BC,atm,ns,1,0,dummy)
1777  call allocate_fv_nest_bc_type(atm%neststruct%vc_BC,atm,ns,0,1,dummy)
1778  call allocate_fv_nest_bc_type(atm%neststruct%divg_BC,atm,ns,1,1,dummy)
1779 
1780  if (ncnst > 0) then
1781  allocate(atm%neststruct%q_BC(ncnst))
1782  do n=1,ncnst
1783  call allocate_fv_nest_bc_type(atm%neststruct%q_BC(n),atm,ns,0,0,dummy)
1784  enddo
1785  endif
1786 
1787 #ifndef SW_DYNAMICS
1788 
1789  call allocate_fv_nest_bc_type(atm%neststruct%pt_BC,atm,ns,0,0,dummy)
1790 #ifdef USE_COND
1791  call allocate_fv_nest_bc_type(atm%neststruct%q_con_BC,atm,ns,0,0,dummy)
1792 #ifdef MOIST_CAPPA
1793  call allocate_fv_nest_bc_type(atm%neststruct%cappa_BC,atm,ns,0,0,dummy)
1794 #endif
1795 #endif
1796  if (.not.atm%flagstruct%hydrostatic) then
1797  call allocate_fv_nest_bc_type(atm%neststruct%w_BC,atm,ns,0,0,dummy)
1798  call allocate_fv_nest_bc_type(atm%neststruct%delz_BC,atm,ns,0,0,dummy)
1799  endif
1800 
1801 #endif
1802 
1803  end if
1804 
1805  !--- Do the memory allocation only for nested model
1806  if( ngrids_in > 1 ) then
1807  if (atm%flagstruct%grid_type < 4) then
1808  if (atm%neststruct%nested) then
1809  allocate(atm%grid_global(1-atm%ng:npx_2d +atm%ng,1-atm%ng:npy_2d +atm%ng,2,1))
1810  else
1811  allocate(atm%grid_global(1-atm%ng:npx_2d +atm%ng,1-atm%ng:npy_2d +atm%ng,2,1:6))
1812  endif
1813  end if
1814  endif
1815 
1816 
1817  !!Convenience pointers
1818  atm%gridstruct%nested => atm%neststruct%nested
1819  atm%gridstruct%grid_type => atm%flagstruct%grid_type
1820  atm%flagstruct%grid_number => atm%grid_number
1821  atm%gridstruct%regional => atm%flagstruct%regional
1822  atm%gridstruct%bounded_domain = atm%flagstruct%regional .or. atm%neststruct%nested
1823  if (atm%neststruct%nested) atm%neststruct%parent_grid => atm%parent_grid
1824 
1825  atm%allocated = .true.
1826  if (dummy) atm%dummy = .true.
1827 
1828  end subroutine allocate_fv_atmos_type
1829 
1831  subroutine deallocate_fv_atmos_type(Atm)
1833  implicit none
1834  type(fv_atmos_type), intent(INOUT) :: Atm
1835 
1836  integer :: n
1837 
1838  if (.not.atm%allocated) return
1839 
1840  deallocate ( atm%u )
1841  deallocate ( atm%v )
1842  deallocate ( atm%pt )
1843  deallocate ( atm%delp )
1844  deallocate ( atm%q )
1845  deallocate ( atm%qdiag )
1846  deallocate ( atm%ps )
1847  deallocate ( atm%pe )
1848  deallocate ( atm%pk )
1849  deallocate ( atm%peln )
1850  deallocate ( atm%pkz )
1851  deallocate ( atm%phis )
1852  deallocate ( atm%omga )
1853  deallocate ( atm%ua )
1854  deallocate ( atm%va )
1855  deallocate ( atm%uc )
1856  deallocate ( atm%vc )
1857  deallocate ( atm%mfx )
1858  deallocate ( atm%mfy )
1859  deallocate ( atm%cx )
1860  deallocate ( atm%cy )
1861  deallocate ( atm%ak )
1862  deallocate ( atm%bk )
1863 
1864  deallocate ( atm%u_srf )
1865  deallocate ( atm%v_srf )
1866  if( atm%flagstruct%fv_land ) deallocate ( atm%sgh )
1867  deallocate ( atm%oro )
1868 
1869  deallocate ( atm%w )
1870  deallocate ( atm%delz )
1871  deallocate ( atm%ze0 )
1872  deallocate ( atm%q_con )
1873 
1874  deallocate ( atm%gridstruct% area ) ! Cell Centered
1875  deallocate ( atm%gridstruct%rarea ) ! Cell Centered
1876 
1877  deallocate ( atm%gridstruct% area_c ) ! Cell Corners
1878  deallocate ( atm%gridstruct%rarea_c ) ! Cell Corners
1879 
1880  deallocate ( atm%gridstruct% dx )
1881  deallocate ( atm%gridstruct%rdx )
1882  deallocate ( atm%gridstruct% dy )
1883  deallocate ( atm%gridstruct%rdy )
1884 
1885  deallocate ( atm%gridstruct% dxc )
1886  deallocate ( atm%gridstruct%rdxc )
1887  deallocate ( atm%gridstruct% dyc )
1888  deallocate ( atm%gridstruct%rdyc )
1889 
1890  deallocate ( atm%gridstruct% dxa )
1891  deallocate ( atm%gridstruct%rdxa )
1892  deallocate ( atm%gridstruct% dya )
1893  deallocate ( atm%gridstruct%rdya )
1894 
1895  deallocate ( atm%gridstruct%grid )
1896  deallocate ( atm%gridstruct%agrid )
1897  deallocate ( atm%gridstruct%sina ) ! SIN(angle of intersection)
1898  deallocate ( atm%gridstruct%cosa ) ! COS(angle of intersection)
1899 
1900  deallocate ( atm%gridstruct% e1 )
1901  deallocate ( atm%gridstruct% e2 )
1902 
1903 
1904 
1905 
1906  deallocate (atm%gridstruct%iinta, &
1907  atm%gridstruct%jinta, &
1908  atm%gridstruct%iintb, &
1909  atm%gridstruct%jintb )
1910 
1911  deallocate ( atm%gridstruct%edge_s )
1912  deallocate ( atm%gridstruct%edge_n )
1913  deallocate ( atm%gridstruct%edge_w )
1914  deallocate ( atm%gridstruct%edge_e )
1915 
1916  deallocate ( atm%gridstruct%edge_vect_s )
1917  deallocate ( atm%gridstruct%edge_vect_n )
1918  deallocate ( atm%gridstruct%edge_vect_w )
1919  deallocate ( atm%gridstruct%edge_vect_e )
1920 
1921  deallocate ( atm%gridstruct%ex_s )
1922  deallocate ( atm%gridstruct%ex_n )
1923  deallocate ( atm%gridstruct%ex_w )
1924  deallocate ( atm%gridstruct%ex_e )
1925 
1926 
1927  deallocate ( atm%gridstruct%l2c_u )
1928  deallocate ( atm%gridstruct%l2c_v )
1929  ! For diveregnce damping:
1930  deallocate ( atm%gridstruct%divg_u )
1931  deallocate ( atm%gridstruct%divg_v )
1932  ! For del6 diffusion:
1933 
1934  deallocate ( atm%gridstruct%z11 )
1935  deallocate ( atm%gridstruct%z12 )
1936  deallocate ( atm%gridstruct%z21 )
1937  deallocate ( atm%gridstruct%z22 )
1938 
1939  deallocate ( atm%gridstruct%a11 )
1940  deallocate ( atm%gridstruct%a12 )
1941  deallocate ( atm%gridstruct%a21 )
1942  deallocate ( atm%gridstruct%a22 )
1943  deallocate ( atm%gridstruct%vlon )
1944  deallocate ( atm%gridstruct%vlat )
1945  ! Coriolis parameters:
1946  deallocate ( atm%gridstruct%f0 )
1947  deallocate ( atm%gridstruct%fC )
1948 
1949  ! Corner unit vectors:
1950  deallocate( atm%gridstruct%ee1 )
1951  deallocate( atm%gridstruct%ee2 )
1952 
1953  ! Center unit vectors:
1954  deallocate( atm%gridstruct%ec1 )
1955  deallocate( atm%gridstruct%ec2 )
1956 
1957  ! Edge unit vectors:
1958  deallocate( atm%gridstruct%ew )
1959  deallocate( atm%gridstruct%es )
1960 
1961  ! Edge unit "Normal" vectors: (for omega computation)
1962  deallocate( atm%gridstruct%en1 ) ! E-W edges
1963  deallocate( atm%gridstruct%en2 ) ! N-S egdes
1964 
1965  deallocate ( atm%gridstruct%cosa_u )
1966  deallocate ( atm%gridstruct%sina_u )
1967  deallocate ( atm%gridstruct%rsin_u )
1968 
1969  deallocate ( atm%gridstruct%cosa_v )
1970  deallocate ( atm%gridstruct%sina_v )
1971  deallocate ( atm%gridstruct%rsin_v )
1972 
1973  deallocate ( atm%gridstruct%cosa_s ) ! cell center
1974 
1975  deallocate ( atm%gridstruct%rsin2 ) ! cell center
1976 
1977 
1978  ! Super (composite) grid:
1979 
1980  ! 9---4---8
1981  ! | |
1982  ! 1 5 3
1983  ! | |
1984  ! 6---2---7
1985 
1986  deallocate ( atm%gridstruct%cos_sg )
1987  deallocate ( atm%gridstruct%sin_sg )
1988 
1989  deallocate( atm%gridstruct%eww )
1990  deallocate( atm%gridstruct%ess )
1991 
1992  if (atm%neststruct%nested) then
1993  deallocate(atm%neststruct%ind_h)
1994  deallocate(atm%neststruct%ind_u)
1995  deallocate(atm%neststruct%ind_v)
1996 
1997  deallocate(atm%neststruct%wt_h)
1998  deallocate(atm%neststruct%wt_u)
1999  deallocate(atm%neststruct%wt_v)
2000 
2001  deallocate(atm%neststruct%ind_b)
2002  deallocate(atm%neststruct%wt_b)
2003 
2004  call deallocate_fv_nest_bc_type(atm%neststruct%delp_BC)
2005  call deallocate_fv_nest_bc_type(atm%neststruct%u_BC)
2006  call deallocate_fv_nest_bc_type(atm%neststruct%v_BC)
2007  call deallocate_fv_nest_bc_type(atm%neststruct%uc_BC)
2008  call deallocate_fv_nest_bc_type(atm%neststruct%vc_BC)
2009  call deallocate_fv_nest_bc_type(atm%neststruct%divg_BC)
2010 
2011  if (allocated(atm%neststruct%q_BC)) then
2012  do n=1,size(atm%neststruct%q_BC)
2013  call deallocate_fv_nest_bc_type(atm%neststruct%q_BC(n))
2014  enddo
2015  endif
2016 
2017 #ifndef SW_DYNAMICS
2018  call deallocate_fv_nest_bc_type(atm%neststruct%pt_BC)
2019 #ifdef USE_COND
2020  call deallocate_fv_nest_bc_type(atm%neststruct%q_con_BC)
2021 #ifdef MOIST_CAPPA
2022  call deallocate_fv_nest_bc_type(atm%neststruct%cappa_BC)
2023 #endif
2024 #endif
2025  if (.not.atm%flagstruct%hydrostatic) then
2026  call deallocate_fv_nest_bc_type(atm%neststruct%w_BC)
2027  call deallocate_fv_nest_bc_type(atm%neststruct%delz_BC)
2028  endif
2029 #endif
2030 
2031  end if
2032 
2033  if (atm%flagstruct%grid_type < 4) then
2034  if(allocated(atm%grid_global)) deallocate(atm%grid_global)
2035  end if
2036 
2037  atm%allocated = .false.
2038 
2039  end subroutine deallocate_fv_atmos_type
2040 
2041 
2042 subroutine allocate_fv_nest_bc_type_3d_atm(BC,Atm,ns,istag,jstag,dummy)
2044  type(fv_nest_bc_type_3d), intent(INOUT) :: BC
2045  type(fv_atmos_type), intent(IN) :: Atm
2046  integer, intent(IN) :: ns, istag, jstag
2047  logical, intent(IN) :: dummy
2048 
2049  integer :: is, ie, js, je, isd, ied, jsd, jed, npx, npy, npz, ng
2050 
2051  if (bc%allocated) return
2052 
2053  is = atm%bd%is
2054  ie = atm%bd%ie
2055  js = atm%bd%js
2056  je = atm%bd%je
2057 
2058  isd = atm%bd%isd
2059  ied = atm%bd%ied
2060  jsd = atm%bd%jsd
2061  jed = atm%bd%jed
2062 
2063  npx = atm%npx
2064  npy = atm%npy
2065  npz = atm%npz
2066 
2067  ng = atm%ng
2068 
2069  call allocate_fv_nest_bc_type_3d(bc,is,ie,js,je,isd,ied,jsd,jed,npx,npy,npz,ng,ns,istag,jstag,dummy)
2070 
2071 
2072 end subroutine allocate_fv_nest_bc_type_3d_atm
2073 
2074 subroutine allocate_fv_nest_bc_type_3d(BC,is,ie,js,je,isd,ied,jsd,jed,npx,npy,npz,ng,ns,istag,jstag,dummy)
2076  type(fv_nest_bc_type_3d), intent(INOUT) :: BC
2077  integer, intent(IN) :: ns, istag, jstag
2078  logical, intent(IN) :: dummy
2079 
2080  integer, intent(IN) :: is, ie, js, je, isd, ied, jsd, jed, npx, npy, npz, ng
2081 
2082  if (bc%allocated) return
2083 
2084 
2085  if (ie == npx-1 .and. .not. dummy) then
2086  allocate(bc%east_t1(ie+1-ns+istag:ied+istag,jsd:jed+jstag,npz))
2087  allocate(bc%east_t0(ie+1-ns+istag:ied+istag,jsd:jed+jstag,npz))
2088  do k=1,npz
2089  do j=jsd,jed+jstag
2090  do i=ie+1-ns+istag,ied+istag
2091  bc%east_t1(i,j,k) = 0.
2092  bc%east_t0(i,j,k) = 0.
2093  enddo
2094  enddo
2095  enddo
2096  else
2097  allocate(bc%east_t1(1,1,npz))
2098  allocate(bc%east_t0(1,1,npz))
2099  end if
2100 
2101  if (js == 1 .and. .not. dummy) then
2102  allocate(bc%south_t1(isd:ied+istag,jsd:js-1+ns,npz))
2103  allocate(bc%south_t0(isd:ied+istag,jsd:js-1+ns,npz))
2104  do k=1,npz
2105  do j=jsd,js-1+ns
2106  do i=isd,ied+istag
2107  bc%south_t1(i,j,k) = 0.
2108  bc%south_t0(i,j,k) = 0.
2109  enddo
2110  enddo
2111  enddo
2112  else
2113  allocate(bc%south_t1(1,1,npz))
2114  allocate(bc%south_t0(1,1,npz))
2115  end if
2116 
2117  if (is == 1 .and. .not. dummy) then
2118  allocate(bc%west_t1(isd:is-1+ns,jsd:jed+jstag,npz))
2119  allocate(bc%west_t0(isd:is-1+ns,jsd:jed+jstag,npz))
2120  do k=1,npz
2121  do j=jsd,jed+jstag
2122  do i=isd,is-1+ns
2123  bc%west_t1(i,j,k) = 0.
2124  bc%west_t0(i,j,k) = 0.
2125  enddo
2126  enddo
2127  enddo
2128  else
2129  allocate(bc%west_t1(1,1,npz))
2130  allocate(bc%west_t0(1,1,npz))
2131  end if
2132 
2133  if (je == npy-1 .and. .not. dummy) then
2134  allocate(bc%north_t1(isd:ied+istag,je+1-ns+jstag:jed+jstag,npz))
2135  allocate(bc%north_t0(isd:ied+istag,je+1-ns+jstag:jed+jstag,npz))
2136  do k=1,npz
2137  do j=je+1-ns+jstag,jed+jstag
2138  do i=isd,ied+istag
2139  bc%north_t1(i,j,k) = 0.
2140  bc%north_t0(i,j,k) = 0.
2141  enddo
2142  enddo
2143  enddo
2144  else
2145  allocate(bc%north_t1(1,1,npz))
2146  allocate(bc%north_t0(1,1,npz))
2147  end if
2148 
2149  bc%allocated = .true.
2150 
2151 end subroutine allocate_fv_nest_bc_type_3d
2152 
2153 subroutine deallocate_fv_nest_bc_type_3d(BC)
2155  type(fv_nest_bc_type_3d) :: BC
2156 
2157  if (.not. bc%allocated) return
2158 
2159  deallocate(bc%north_t1)
2160  deallocate(bc%south_t1)
2161  deallocate(bc%west_t1)
2162  deallocate(bc%east_t1)
2163 
2164  if (allocated(bc%north_t0)) then
2165  deallocate(bc%north_t0)
2166  deallocate(bc%south_t0)
2167  deallocate(bc%west_t0)
2168  deallocate(bc%east_t0)
2169  endif
2170 
2171  bc%allocated = .false.
2172 
2173 end subroutine deallocate_fv_nest_bc_type_3d
2174 
2175 
2176 end module fv_arrays_mod
subroutine allocate_fv_atmos_type(Atm, isd_in, ied_in, jsd_in, jed_in, is_in, ie_in, js_in, je_in, npx_in, npy_in, npz_in, ndims_in, ncnst_in, nq_in, dummy, alloc_2d, ngrids_in)
The subroutine &#39;allocate_fv_atmos_type&#39; allocates the fv_atmos_type.
Definition: fv_arrays.F90:1382
subroutine allocate_fv_nest_bc_type_3d_atm(BC, Atm, ns, istag, jstag, dummy)
Definition: fv_arrays.F90:2043
The type &#39;fv_grid_type&#39; is made up of grid-dependent information from fv_grid_tools and fv_grid_utils...
Definition: fv_arrays.F90:123
integer, parameter max_step
Definition: fv_arrays.F90:42
integer, parameter, public r_grid
Definition: fv_arrays.F90:34
&#39;allocate_fv_nest_BC_type&#39; is an interface to subroutines that allocate the &#39;fv_nest_BC_type&#39; structu...
Definition: fv_arrays.F90:1176
&#39;deallocate_fv_nest_BC_type&#39; is an interface to a subroutine that deallocates the &#39;fv_nest_BC_type&#39; s...
Definition: fv_arrays.F90:1183
subroutine allocate_fv_nest_bc_type_3d(BC, is, ie, js, je, isd, ied, jsd, jed, npx, npy, npz, ng, ns, istag, jstag, dummy)
Definition: fv_arrays.F90:2075
The module &#39;fv_arrays&#39; contains the &#39;fv_atmos_type&#39; and associated datatypes.
Definition: fv_arrays.F90:24
real, parameter real_big
Definition: fv_arrays.F90:47
subroutine deallocate_fv_nest_bc_type_3d(BC)
Definition: fv_arrays.F90:2154
subroutine deallocate_fv_atmos_type(Atm)
The subroutine &#39;deallocate_fv_atmos_type&#39; deallocates the fv_atmos_type.
Definition: fv_arrays.F90:1832