Line data Source code
1 : module rayleigh_friction_cam
2 :
3 : !---------------------------------------------------------------------------------
4 : ! This contains the residual code required to read namelists for the
5 : ! Rayliegh Friction scheme. All of the functional code (the init and run subroutines)
6 : ! has been moved to ncar_ccpp code.
7 : !
8 : !---------------------------------------------------------------------------------
9 :
10 : use shr_kind_mod, only: r8 => shr_kind_r8
11 : use ppgrid, only: pver
12 : use spmd_utils, only: masterproc
13 : use phys_control, only: use_simple_phys
14 : use cam_logfile, only: iulog
15 : use cam_abortutils, only: endrun
16 :
17 : implicit none
18 : private
19 : save
20 :
21 : ! Public interfaces
22 : public :: rayleigh_friction_readnl ! read namelist
23 : ! Rayleigh friction namelist parameters for use in physpkg
24 : integer, public :: rf_nl_k0 = 2 ! vertical level at which rayleigh friction term is centered
25 : real(r8), public :: rf_nl_krange = 0._r8 ! range of rayleigh friction profile
26 : ! if 0, range is set to satisfy x=2 (see below)
27 : real(r8), public :: rf_nl_tau0 = 0._r8 ! approximate value of decay time at model top (days)
28 : ! if 0., no rayleigh friction is applied
29 :
30 : !===============================================================================
31 : contains
32 : !===============================================================================
33 :
34 1024 : subroutine rayleigh_friction_readnl(nlfile)
35 :
36 : use namelist_utils, only: find_group_name
37 : use units, only: getunit, freeunit
38 : use spmd_utils, only: mpicom, mstrid=>masterprocid, mpi_integer, mpi_real8
39 :
40 : character(len=*), intent(in) :: nlfile ! filepath for file containing namelist input
41 :
42 : ! Local variables
43 : integer :: unitn, ierr, rayk0
44 : real (r8) :: raykrange, raytau0
45 : character(len=*), parameter :: sub = 'rayleigh_friction_readnl'
46 :
47 : namelist /rayleigh_friction_nl/ rayk0, raykrange, raytau0
48 : !-----------------------------------------------------------------------------
49 :
50 0 : if (use_simple_phys) return
51 :
52 : ! Initialize with default values
53 1024 : rayk0 = rf_nl_k0
54 1024 : raykrange = rf_nl_krange
55 1024 : raytau0 = rf_nl_tau0
56 :
57 1024 : if (masterproc) then
58 2 : unitn = getunit()
59 2 : open( unitn, file=trim(nlfile), status='old' )
60 2 : call find_group_name(unitn, 'rayleigh_friction_nl', status=ierr)
61 2 : if (ierr == 0) then
62 0 : read(unitn, rayleigh_friction_nl, iostat=ierr)
63 0 : if (ierr /= 0) then
64 0 : call endrun(sub//': FATAL: reading namelist')
65 : end if
66 : end if
67 2 : close(unitn)
68 2 : call freeunit(unitn)
69 : end if
70 :
71 1024 : call mpi_bcast(rayk0, 1, mpi_integer, mstrid, mpicom, ierr)
72 1024 : if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: rayk0")
73 1024 : call mpi_bcast(raykrange, 1, mpi_real8, mstrid, mpicom, ierr)
74 1024 : if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: raykrange")
75 1024 : call mpi_bcast(raytau0, 1, mpi_real8, mstrid, mpicom, ierr)
76 1024 : if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: raytau0")
77 :
78 : ! Set module variables
79 1024 : rf_nl_tau0 = raytau0
80 1024 : rf_nl_krange = raykrange
81 1024 : rf_nl_k0 = rayk0
82 :
83 1024 : if (masterproc) then
84 2 : if (raytau0 > 0._r8) then
85 0 : write (iulog,*) 'Rayleigh friction options: '
86 0 : write (iulog,*) ' rayk0 = ', rf_nl_k0
87 0 : write (iulog,*) ' raykrange = ', rf_nl_krange
88 0 : write (iulog,*) ' raytau0 = ', rf_nl_tau0
89 : else
90 2 : write (iulog,*) 'Rayleigh friction not enabled.'
91 : end if
92 : end if
93 :
94 1024 : end subroutine rayleigh_friction_readnl
95 :
96 : !=========================================================================================
97 :
98 : end module rayleigh_friction_cam
|