cpld_gridgen  1.13.0
All Data Structures Files Functions Variables Pages
inputnml.F90
Go to the documentation of this file.
1 
7 
8 module inputnml
9 
10  use grdvars, only : nx,ny,ni,nj,npx
11  use grdvars, only : editmask, debug, do_postwgts
12  use charstrings, only : dirsrc, dirout, fv3dir, res, topofile, editsfile
13 
14  implicit none
15 
16 contains
17 
23 
24  subroutine read_inputnml(fname)
25 
26  character(len=*), intent(in) :: fname
27 
28  ! local variables
29  integer :: iounit, rc
30  character(len=200) :: tmpstr
31 
32  namelist /grid_nml/ ni, nj, dirsrc, dirout, fv3dir, topofile, editsfile, &
33  res, editmask, debug, do_postwgts
34 
35  ! Check whether file exists.
36  inquire (file=trim(fname), iostat=rc)
37  if (rc /= 0) then
38  write (0, '(3a)') 'Error: input file "', trim(fname), '" does not exist.'
39  stop 1
40  end if
41 
42  ! Open and read Namelist file.
43  open (action='read', file=trim(fname), iostat=rc, newunit=iounit)
44  read (nml=grid_nml, iostat=rc, unit=iounit)
45  if (rc /= 0) then
46  backspace(iounit)
47  read(iounit,'(a)')tmpstr
48  write (6, '(a)') 'Error: invalid Namelist format '//trim(tmpstr)
49  stop 1
50  end if
51  close(iounit)
52 
53  ! set supergrid dimensions
54  nx = ni*2
55  ny = nj*2
56 
57  end subroutine read_inputnml
58 end module inputnml