regrid_sfc  1.13.0
readin_setup.F90
Go to the documentation of this file.
1 
4 
13  subroutine readin_setup(unt,namel,grid_setup)
14 
15  use grids_io, only : grid_setup_type
16  use utilities, only : error_handler
17 
18  implicit none
19 
20  ! INPUTS
21  integer, intent(in) :: unt
22  character(*), intent(in) :: namel
23  ! OUTPUTS
24  type(grid_setup_type), intent(out) :: grid_setup
25 
26  character(len=7) :: gridtype
27  character(len=100) :: fname, fname_mask, fname_coord
28  character(len=100) :: dir, dir_mask, dir_coord
29  character(len=4) :: default_str="NULL"
30  integer :: ires, jres
31  integer :: ierr
32  logical :: add_time_dim
33  integer :: fhrs(10) ! forecast hours of increment files
34 
35  namelist /input/ fname, dir, &
36  gridtype, &
37  fname_mask, dir_mask, &
38  fname_coord, dir_coord, &
39  ires, jres, &
40  fhrs
41 
42  namelist /output/ fname, dir, &
43  gridtype, &
44  fname_mask, dir_mask, &
45  fname_coord, dir_coord,&
46  ires, jres, &
47  add_time_dim
48 
49  ! set defaults
50  fname = default_str
51  dir = default_str
52  fname_mask = default_str
53  dir_mask = default_str
54  fname_coord = default_str
55  dir_coord = default_str
56  ires = 0
57  jres = 0
58  add_time_dim = .false.
59  fhrs = -1
60 
61  select case (namel)
62  case ("input")
63  read(unt, nml=input, iostat=ierr)
64  if (ierr /= 0) call error_handler("READING input NAMELIST.", ierr)
65  case ("output")
66  read(unt, nml=output, iostat=ierr)
67  if (ierr /= 0) call error_handler("READING output NAMELIST.", ierr)
68  case default
69  call error_handler("unknown namel in readin_setup", 1)
70  end select
71 
72  grid_setup%descriptor = gridtype
73 
74  grid_setup%dir = dir
75  grid_setup%fname = fname
76  grid_setup%mask_from_input = .false.
77 
78  ! set-up mask details, based on file type
79  select case (gridtype)
80  case ("fv3_rst") ! for history file and restarts, use veg type
81  grid_setup%dir_mask = dir_mask ! get from a fix file
82  grid_setup%fname_mask = fname_mask
83  grid_setup%mask_variable(1) = "vegetation_type" ! if getting from fix file
84  case ("gau_inc") ! gsi-output incr files only, use calculated mask
85  if (trim(fname_mask) == default_str) then ! if not specified, use input file
86  grid_setup%dir_mask = dir
87  grid_setup%fname_mask = fname
88  grid_setup%mask_from_input = .true.
89  else
90  grid_setup%dir_mask = dir_mask
91  grid_setup%fname_mask = fname_mask
92  endif
93  grid_setup%mask_variable(1) = "soilsnow_mask "
94  case default
95  call error_handler("unknown gridtype in readin_setup", 1)
96  end select
97 
98  grid_setup%dir_coord = dir_coord
99  grid_setup%fname_coord = fname_coord
100  grid_setup%ires = ires
101  grid_setup%jres = jres
102 
103  end subroutine readin_setup
subroutine readin_setup(unt, namel, grid_setup)
Subroutine to read in namelists, and convert values into setupgrid.