LCOV - code coverage report
Current view: | top level - dynamics/se/dycore - namelist_mod.F90 (source / functions) |  |  | Hit | Total | Coverage
Test: | coverage.info |  | Lines: | 34 | 62 | 54.8 %
Date: | 2024-12-17 22:39:59 |  | Functions: | 2 | 2 | 100.0 %

              Line data    Source code
           1             : module namelist_mod
           2             :   !-----------------
           3             :   use cam_logfile,    only: iulog
           4             :   !-----------------
           5             :   use params_mod,     only: recursive, sfcurve
           6             :   !-----------------
           7             :   use shr_string_mod, only: shr_string_toUpper
           8             :   use shr_kind_mod,   only: r8=>shr_kind_r8
           9             :   !-----------------
          10             :   use control_mod,    only:   &
          11             :        partmethod,            & ! Mesh partitioning method (METIS)
          12             :        multilevel,            &
          13             :        numnodes,              &
          14             :        tasknum,               & ! used dg model in AIX machine
          15             :        remapfreq,             & ! number of steps per remapping call
          16             :        statefreq,             & ! number of steps per printstate call
          17             :        runtype,               &
          18             :        cubed_sphere_map,      &
          19             :        limiter_option,        &
          20             :        nu_top,                &
          21             :        hypervis_scaling,      & ! use tensor HV instead of scalar coefficient
          22             :        hypervis_power,        &
          23             :        columnpackage
          24             :
          25             :   !-----------------
          26             :   use thread_mod, only : omp_get_max_threads, max_num_threads, horz_num_threads, vert_num_threads, tracer_num_threads
          27             :   !-----------------
          28             :   use dimensions_mod, only : ne, np, npdg, nnodes, nmpi_per_node, npart, qsize, qsize_d, set_mesh_dimensions
          29             :   !-----------------
          30             :   !-----------------
          31             :   use cam_abortutils, only: endrun
          32             :   use parallel_mod,   only: parallel_t, partitionfornodes, useframes
          33             :   !-----------------
          34             :
          35             :
          36             :   use interpolate_mod, only : set_interp_parameter, get_interp_parameter
          37             :
          38             : !=============================================================================!
          39             :   implicit none
          40             :   private
          41             : !
          42             : ! This module should contain no global data and should only be 'use'd to
          43             : !    call one of the public interfaces below
          44             : !
          45             :   public :: homme_set_defaults
          46             :   public :: homme_postprocess_namelist
          47             :
          48             :  contains
          49             :
          50             :   ! ============================================
          51             :   ! homme_set_defaults:
          52             :   !
          53             :   !  Set default values for namelist variables
          54             :   !
          55             :   ! ============================================
          56        1536 :   subroutine homme_set_defaults()
          57        1536 :     npart               = 1
          58        1536 :     useframes           = 0
          59        1536 :     multilevel          = 1
          60        1536 :     numnodes            = -1
          61        1536 :     runtype             = 0
          62        1536 :     statefreq           = 1
          63        1536 :     remapfreq           = 240
          64        1536 :     tasknum             =-1
          65        1536 :     columnpackage       = "none"
          66        1536 :     nu_top              = 0
          67        1536 :     ne                  = 0
          68             :
          69        1536 :   end subroutine homme_set_defaults
          70             :
          71        1536 :   subroutine homme_postprocess_namelist(mesh_file, par)
          72             :     use mesh_mod,        only: MeshOpen
          73             :     use dimensions_mod,  only: use_cslam
          74             :     ! Dummy arguments
          75             :     character(len=*),  intent(in) :: mesh_file
          76             :     type (parallel_t), intent(in) :: par
          77             :
          78             :     ! Local variable
          79             :     real(kind=r8) :: dt_max
          80             :     character(len=*), parameter :: subname = 'HOMME_POSTPROCESS_NAMELIST: '
          81             :
          82        1536 :     if(par%masterproc) then
          83           2 :       write(iulog, *) subname, 'omp_get_max_threads() = ', max_num_threads
          84             :     end if
          85             :
          86        1536 :     if((vert_num_threads > 1) .and. (limiter_option .ne. 8)) then
          87           0 :        if(par%masterproc) then
          88           0 :          write(iulog, *) subname, 'WARNING: vertical threading on supported for limiter_option != 8 '
          89             :        end if
          90           0 :        vert_num_threads = 1
          91             :     endif
          92             :
          93        1536 :     if (ne /= 0) then
          94        1536 :       if (mesh_file /= "none" .and. mesh_file /= "/dev/null") then
          95           0 :         if (par%masterproc) then
          96           0 :           write(iulog, *) subname, "mesh_file:", trim(mesh_file),        &
          97           0 :                " and ne:",ne," are both sepcified in the input file."
          98           0 :           write(iulog,*) "            Specify one or the other, but not both."
          99             :         end if
         100           0 :         call endrun(subname//"Do not specify ne if using a mesh file input.")
         101             :       end if
         102             :     end if
         103        1536 :     if (par%masterproc) then
         104           2 :       write(iulog,*) subname, "Mesh File:", trim(mesh_file)
         105             :     end if
         106        1536 :     if (ne == 0) then
         107           0 :       if (par%masterproc) then
         108           0 :         write (iulog,*) subname, "Opening Mesh File:", trim(mesh_file)
         109             :       end if
         110           0 :       call set_mesh_dimensions()
         111           0 :       call MeshOpen(mesh_file, par)
         112             :     end if
         113             :
         114             :     ! set map
         115        1536 :     if (cubed_sphere_map < 0) then
         116        1536 :       if (ne == 0) then
         117           0 :         cubed_sphere_map = 2  ! element_local for var-res grids
         118             :       else
         119        1536 :         cubed_sphere_map = 0  ! default is equi-angle gnomonic
         120             :       end if
         121             :     end if
         122             :
         123        1536 :     if ((cubed_sphere_map /= 0) .AND. use_cslam) then
         124           0 :       if (par%masterproc) then
         125           0 :         write(iulog, *) subname, 'fvm transport and require equi-angle gnomonic cube sphere mapping.'
         126           0 :         write(iulog, *) '         Set cubed_sphere_map = 0 or comment it out all together.                          '
         127             :       end if
         128           0 :       call endrun(subname//"ERROR: fvm transport and cubed_sphere_map>0")
         129             :     end if
         130        1536 :     if (par%masterproc) then
         131           2 :       write (iulog,*) subname, "Reference element projection: cubed_sphere_map=",cubed_sphere_map
         132             :     end if
         133             :
         134             :     !logic around different hyperviscosity options
         135        1536 :     if (hypervis_power /= 0) then
         136           0 :       if (hypervis_scaling /= 0) then
         137           0 :         if (par%masterproc) then
         138           0 :           write(iulog, *) subname, 'Both hypervis_power and hypervis_scaling are nonzero.'
         139           0 :           write(iulog, *) '        (1) Set hypervis_power=1, hypervis_scaling=0 for HV based on an element area.'
         140           0 :           write(iulog, *) '        (2) Set hypervis_power=0 and hypervis_scaling=1 for HV based on a tensor.'
         141           0 :           write(iulog, *) '        (3) Set hypervis_power=0 and hypervis_scaling=0 for constant HV.'
         142             :         end if
         143           0 :         call endrun(subname//"ERROR: hypervis_power>0 and hypervis_scaling>0")
         144             :       end if
         145             :     end if
         146             :
         147        1536 :     if (multilevel <= 0) then
         148           0 :       nmpi_per_node = 1
         149             :     end if
         150             :
         151        1536 :     nnodes = npart / nmpi_per_node
         152             :
         153        1536 :     if((numnodes > 0) .and. (multilevel == 1)) then
         154           0 :       nnodes = numnodes
         155           0 :       nmpi_per_node = npart/nnodes
         156             :     end if
         157             :
         158             :     ! ====================================================================
         159             :     !  Do not perform node level partitioning if you are only on one node
         160             :     ! ====================================================================
         161        1536 :     if((nnodes .eq. 1) .and. PartitionForNodes) then
         162           0 :       PartitionForNodes = .FALSE.
         163             :     end if
         164             :
         165        1536 :   end subroutine homme_postprocess_namelist
         166             : end module namelist_mod

Generated by: LCOV version 1.14