LCOV - code coverage report
Current view: | top level - chemistry/mozart - mo_tgcm_ubc.F90 (source / functions) |  |  | Hit | Total | Coverage
Test: | coverage.info |  | Lines: | 0 | 31 | 0.0 %
Date: | 2025-01-13 21:54:50 |  | Functions: | 0 | 3 | 0.0 %

              Line data    Source code
           1             : !---------------------------------------------------------------
           2             : !       ... tgcm upper bndy values
           3             : !---------------------------------------------------------------
           4             :
           5             :       module mo_tgcm_ubc
           6             :
           7             :         use ppgrid,           only : pver
           8             :         use shr_kind_mod,     only : r8 => shr_kind_r8
           9             :         use constituents,     only : pcnst, cnst_fixed_ubc
          10             :
          11             :         use cam_abortutils,   only: endrun
          12             :         use cam_logfile,      only: iulog
          13             :
          14             :         use tracer_data,      only : trfld,trfile,MAXTRCRS
          15             :         use cam_history,      only : addfld, horiz_only
          16             :
          17             :         implicit none
          18             :
          19             :         private
          20             :         public  :: tgcm_ubc_inti, set_tgcm_ubc, tgcm_timestep_init
          21             :
          22             :         save
          23             :
          24             :         type(trfld), pointer :: fields(:)
          25             :         type(trfile)         :: file
          26             :
          27             :         integer :: ub_nspecies
          28             :         character(len=16) :: ubc_name(MAXTRCRS)
          29             :         integer :: map(MAXTRCRS)
          30             :
          31             :         logical :: ubc_from_tgcm(pcnst)  = .false.
          32             :
          33             :       contains
          34             :
          35           0 :       subroutine tgcm_ubc_inti( tgcm_ubc_file, tgcm_ubc_data_type, tgcm_ubc_cycle_yr, tgcm_ubc_fixed_ymd, tgcm_ubc_fixed_tod)
          36             :         !------------------------------------------------------------------
          37             :         !       ... initialize upper boundary values
          38             :         !------------------------------------------------------------------
          39             :         use tracer_data, only : trcdata_init
          40             :
          41             :         use constituents,    only : cnst_get_ind
          42             :
          43             :         !------------------------------------------------------------------
          44             :         !       ... dummy args
          45             :         !------------------------------------------------------------------
          46             :         character(len=*),   intent(in)     :: tgcm_ubc_file
          47             :         integer,            intent(in)     :: tgcm_ubc_cycle_yr
          48             :         integer,            intent(in)     :: tgcm_ubc_fixed_ymd
          49             :         integer,            intent(in)     :: tgcm_ubc_fixed_tod
          50             :         character(len=32),  intent(in)     :: tgcm_ubc_data_type
          51             :
          52             :
          53             :         ! local vars
          54             :         integer :: vid, i,ii, ierr
          55             :
          56             :         character(len=256), parameter :: filelist = ' '
          57             :         character(len=256), parameter :: datapath = ' '
          58             :         logical,            parameter :: rmv_file = .false.
          59             :         integer,            parameter :: nubc = 1
          60             :         character(len=4),   parameter :: species(nubc) = (/'H2  '/)
          61             :         character(len=4)              :: specifier(nubc) = ' '
          62             :
          63             :         character(len=*), parameter :: prefix = 'tgcm_ubc_inti: '
          64             :
          65             :         ii = 0
          66             :
          67           0 :         do i = 1,nubc
          68           0 :            call cnst_get_ind( species(i), vid, abort=.false. )
          69           0 :            if( vid > 0 ) then
          70           0 :               if( cnst_fixed_ubc(vid) ) then
          71           0 :                  ii = ii+1
          72           0 :                  specifier(ii) = species(i) ! set specifier to the species that actually
          73             :                                             ! are registered to have a specified upper bounary
          74             :                                             ! so that the species mapping is correct
          75           0 :                  ubc_from_tgcm(vid) = .true.
          76           0 :                  map(ii) = vid              ! elements in map array correspond to elements in specifier
          77           0 :                  ubc_name(ii) = trim(species(i))//'_tgcm'
          78             :                  call addfld( ubc_name(ii), horiz_only, 'I', 'kg/kg', 'upper boundary mmr' )
          79             :               end if
          80             :            end if
          81             :         enddo
          82             :
          83           0 :         ub_nspecies = count( ubc_from_tgcm )
          84             :
          85           0 :         if (ub_nspecies > 0) then
          86           0 :            file%top_bndry = .true.
          87           0 :            allocate(file%in_pbuf(size(specifier)), stat=ierr)
          88           0 :            if (ierr /= 0) call endrun(prefix//'allocate error : file%in_pbuf')
          89           0 :            file%in_pbuf(:) = .false.
          90             :            call trcdata_init( specifier, tgcm_ubc_file, filelist, datapath, fields, file, &
          91           0 :                               rmv_file, tgcm_ubc_cycle_yr, tgcm_ubc_fixed_ymd, tgcm_ubc_fixed_tod, tgcm_ubc_data_type)
          92             :         endif
          93             :
          94           0 :       end subroutine tgcm_ubc_inti
          95             :
          96           0 :       subroutine tgcm_timestep_init(pbuf2d, state )
          97             :
          98           0 :         use tracer_data,  only : advance_trcdata
          99             :         use physics_types,only : physics_state
         100             :         use ppgrid,       only : begchunk, endchunk
         101             :         use physics_buffer, only : physics_buffer_desc
         102             :
         103             :         !--------------------------------------------------------------------
         104             :         !       ... Advance ub values
         105             :         !--------------------------------------------------------------------
         106             :
         107             :         ! args
         108             :         type(physics_state), intent(in):: state(begchunk:endchunk)
         109             :         type(physics_buffer_desc), pointer :: pbuf2d(:,:)
         110             :
         111           0 :         if (ub_nspecies > 0) then
         112           0 :            call advance_trcdata( fields, file, state, pbuf2d )
         113             :         endif
         114             :
         115           0 :       end subroutine tgcm_timestep_init
         116             :
         117           0 :       subroutine set_tgcm_ubc( lchunk, ncol, mmr )
         118             :         !--------------------------------------------------------------------
         119             :         !       ... Set the upper boundary values h2o, h2, and h
         120             :         !--------------------------------------------------------------------
         121             :
         122           0 :         use ppgrid,      only : pcols
         123             :         use cam_history, only : outfld
         124             :
         125             :         !--------------------------------------------------------------------
         126             :         !       ... dummy args
         127             :         !--------------------------------------------------------------------
         128             :         integer,  intent(in)    :: lchunk            ! chunk id
         129             :         integer,  intent(in)    :: ncol              ! columns in chunk
         130             :         real(r8), intent(inout) :: mmr(pcols,pcnst)
         131             :
         132             :         !--------------------------------------------------------------------
         133             :         !       ... local variables
         134             :         !--------------------------------------------------------------------
         135             :         integer  :: m,n
         136             :
         137           0 :         if (ub_nspecies > 0) then
         138           0 :            do m = 1,ub_nspecies
         139           0 :               n = map(m)
         140           0 :               mmr(:ncol,n) = fields(m)%data(:ncol,1,lchunk)
         141           0 :               call outfld( ubc_name(m), mmr(:ncol,n), ncol, lchunk )
         142             :            enddo
         143             :         endif
         144             :
         145           0 :       end subroutine set_tgcm_ubc
         146             :
         147             :       end module mo_tgcm_ubc

Generated by: LCOV version 1.14