LCOV - code coverage report
Current view: | top level - chemistry/utils - solar_data.F90 (source / functions) |  |  | Hit | Total | Coverage
Test: | coverage.info |  | Lines: | 50 | 53 | 94.3 %
Date: | 2025-01-13 21:54:50 |  | Functions: | 3 | 3 | 100.0 %

              Line data    Source code
           1             : module solar_data
           2             :   use shr_kind_mod,   only: r8 => shr_kind_r8
           3             :   use shr_kind_mod,   only: shr_kind_cl
           4             :   use spmd_utils,     only: masterproc
           5             :   use cam_abortutils, only: endrun
           6             :   use cam_logfile,    only: iulog
           7             :   use phys_control,   only: use_simple_phys
           8             :
           9             :   implicit none
          10             :
          11             :   save
          12             :   private
          13             :   public :: solar_data_readnl
          14             :   public :: solar_data_init
          15             :   public :: solar_data_advance
          16             :
          17             :   character(len=shr_kind_cl) :: solar_irrad_data_file = 'NONE'
          18             :   character(len=shr_kind_cl) :: solar_parms_data_file = 'NONE'
          19             :   character(len=shr_kind_cl) :: solar_euv_data_file   = 'NONE'
          20             :   character(len=shr_kind_cl) :: solar_wind_data_file  = 'NONE'
          21             :
          22             :   character(len=8)   :: solar_data_type = 'SERIAL'      ! "FIXED" or "SERIAL"
          23             :   integer            :: solar_data_ymd = -99999999      ! YYYYMMDD for "FIXED" type
          24             :   integer            :: solar_data_tod = 0              ! seconds of day for "FIXED" type
          25             :   real(r8)           :: solar_const = -9999._r8         ! constant TSI (W/m2)
          26             :   logical            :: solar_htng_spctrl_scl = .false. ! do rad heating spectral scaling
          27             :
          28             :  contains
          29             :
          30             : !-----------------------------------------------------------------------
          31             : !-----------------------------------------------------------------------
          32      372480 :   subroutine solar_data_readnl( nlfile )
          33             :     use namelist_utils,  only: find_group_name
          34             :     use units,           only: getunit, freeunit
          35             :     use spmd_utils,      only: mpicom, masterprocid, mpi_character, mpi_integer, mpi_logical, mpi_real8
          36             :     use solar_parms_data,only: solar_parms_on
          37             :     use solar_wind_data, only: solar_wind_on
          38             :
          39             :     ! arguments
          40             :     character(len=*), intent(in) :: nlfile  ! filepath for file containing namelist input
          41             :
          42             :     ! local vars
          43             :     integer :: unitn, ierr
          44             :
          45             :     namelist /solar_data_opts/ &
          46             :          solar_irrad_data_file, solar_parms_data_file, solar_euv_data_file, solar_wind_data_file, &
          47             :          solar_data_type, solar_data_ymd, solar_data_tod, solar_const, solar_htng_spctrl_scl
          48             :
          49        1536 :     if (use_simple_phys) return
          50             :
          51        1536 :     if (masterproc) then
          52           2 :        unitn = getunit()
          53           2 :        open( unitn, file=trim(nlfile), status='old' )
          54           2 :        call find_group_name(unitn, 'solar_data_opts', status=ierr)
          55           2 :        if (ierr == 0) then
          56           2 :           read(unitn, solar_data_opts, iostat=ierr)
          57           2 :           if (ierr /= 0) then
          58           0 :              call endrun('solar_data_readnl: ERROR reading namelist')
          59             :           end if
          60             :        end if
          61           2 :        close(unitn)
          62           2 :        call freeunit(unitn)
          63             :     end if
          64             :
          65             :     ! broadcast the options to all MPI tasks
          66        1536 :     call mpi_bcast(solar_irrad_data_file, len(solar_irrad_data_file), mpi_character, masterprocid, mpicom, ierr)
          67        1536 :     call mpi_bcast(solar_parms_data_file, len(solar_parms_data_file), mpi_character, masterprocid, mpicom, ierr)
          68        1536 :     call mpi_bcast(solar_euv_data_file,   len(solar_euv_data_file),   mpi_character, masterprocid, mpicom, ierr)
          69        1536 :     call mpi_bcast(solar_wind_data_file,  len(solar_wind_data_file),  mpi_character, masterprocid, mpicom, ierr)
          70             :
          71        1536 :     call mpi_bcast(solar_data_type, len(solar_data_type), mpi_character, masterprocid, mpicom, ierr)
          72        1536 :     call mpi_bcast(solar_data_ymd,  1,                    mpi_integer,   masterprocid, mpicom, ierr)
          73        1536 :     call mpi_bcast(solar_data_tod,  1,                    mpi_integer,   masterprocid, mpicom, ierr)
          74        1536 :     call mpi_bcast(solar_const,     1,                    mpi_real8 ,    masterprocid, mpicom, ierr)
          75        1536 :     call mpi_bcast(solar_htng_spctrl_scl,1,               mpi_logical,   masterprocid, mpicom, ierr)
          76             :
          77        1536 :     if ( (solar_irrad_data_file.ne.'NONE') .and. (solar_const>0._r8) ) then
          78           0 :        call endrun('solar_data_readnl: ERROR cannot specify both solar_irrad_data_file and solar_const')
          79             :     endif
          80             :
          81        1536 :     if ( (solar_data_ymd>0 .or. solar_data_tod>0) .and. trim(solar_data_type)=='SERIAL' ) then
          82           0 :        call endrun('solar_data_readnl: ERROR cannot set solar_data_ymd or solar_data_tod with solar_data_type=SERIAL')
          83             :     endif
          84             :
          85        1536 :     if (masterproc) then
          86           2 :        write(iulog,*) 'solar_data_readnl: solar_const (W/m2) = ', solar_const
          87           2 :        write(iulog,*) 'solar_data_readnl: solar_irrad_data_file = ',trim(solar_irrad_data_file)
          88           2 :        write(iulog,*) 'solar_data_readnl: solar_parms_data_file = ',trim(solar_parms_data_file)
          89           2 :        write(iulog,*) 'solar_data_readnl: solar_euv_data_file = ',trim(solar_euv_data_file)
          90           2 :        write(iulog,*) 'solar_data_readnl: solar_wind_data_file = ',trim(solar_wind_data_file)
          91           2 :        write(iulog,*) 'solar_data_readnl: solar_data_type = ',trim(solar_data_type)
          92           2 :        write(iulog,*) 'solar_data_readnl: solar_data_ymd  = ',solar_data_ymd
          93           2 :        write(iulog,*) 'solar_data_readnl: solar_data_tod  = ',solar_data_tod
          94           2 :        write(iulog,*) 'solar_data_readnl: solar_htng_spctrl_scl  = ',solar_htng_spctrl_scl
          95             :     endif
          96             :
          97        1536 :     solar_parms_on = solar_parms_data_file.ne.'NONE'
          98        1536 :     solar_wind_on = solar_wind_data_file.ne.'NONE'
          99             :
         100        1536 :   end subroutine solar_data_readnl
         101             :
         102             : !-----------------------------------------------------------------------
         103             : !-----------------------------------------------------------------------
         104        1536 :   subroutine solar_data_init()
         105        1536 :     use solar_irrad_data, only: solar_irrad_init
         106             :     use solar_parms_data, only: solar_parms_init
         107             :     use solar_wind_data,  only: solar_wind_init
         108             :     use solar_euv_data,   only: solar_euv_init
         109             :
         110             :     logical :: fixed_solar
         111        1536 :     fixed_solar = trim(solar_data_type) == 'FIXED'
         112             :
         113             :     call solar_irrad_init( solar_irrad_data_file, fixed_solar, solar_data_ymd, solar_data_tod, &
         114        1536 :                            solar_const, solar_htng_spctrl_scl )
         115        1536 :     call solar_parms_init( solar_parms_data_file, fixed_solar, solar_data_ymd, solar_data_tod )
         116        1536 :     call solar_wind_init( solar_wind_data_file, fixed_solar, solar_data_ymd, solar_data_tod )
         117        1536 :     call solar_euv_init( solar_euv_data_file, fixed_solar, solar_data_ymd, solar_data_tod )
         118             :
         119        1536 :    end subroutine solar_data_init
         120             :
         121             : !-----------------------------------------------------------------------
         122             : !-----------------------------------------------------------------------
         123      370944 :    subroutine solar_data_advance()
         124             :
         125        1536 :      use solar_irrad_data, only: solar_irrad_advance
         126             :      use solar_parms_data, only: solar_parms_advance
         127             :      use solar_wind_data,  only: solar_wind_advance
         128             :      use solar_euv_data,   only: solar_euv_advance
         129             :
         130      370944 :      call solar_irrad_advance()
         131      370944 :      call solar_parms_advance()
         132      370944 :      call solar_wind_advance()
         133      370944 :      call solar_euv_advance()
         134             :
         135      370944 :    end subroutine solar_data_advance
         136             :
         137             : end module solar_data

Generated by: LCOV version 1.14