Skip to content

Commit

Permalink
Add namelist and streams filename parameters to mpas_init (#10)
Browse files Browse the repository at this point in the history
This alters the signature of the mpas_init subroutine in mpas_subdriver.F, adding two optional parameters that allow the caller to pass in filenames for the namelist and streams file. This allows the caller to specify different files to be used, other than namelist.atmosphere and streams.atmosphere in the working directory. This functionality is critical for several use-cases in MPAS-JEDI, including the ConvertState application, which interpolates data between two MPAS meshes of different resolutions.
  • Loading branch information
svahl991 authored Jan 29, 2021
1 parent 31ca214 commit d33a772
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/driver/mpas_subdriver.F
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ module mpas_subdriver
contains


subroutine mpas_init(corelist, domain_ptr, mpi_comm)
subroutine mpas_init(corelist, domain_ptr, mpi_comm, namelistFileParam, streamsFileParam)

use mpas_stream_manager, only : MPAS_stream_mgr_init, MPAS_build_stream_filename, MPAS_stream_mgr_validate_streams
use iso_c_binding, only : c_char, c_loc, c_ptr, c_int
Expand All @@ -53,7 +53,9 @@ subroutine mpas_init(corelist, domain_ptr, mpi_comm)
type (core_type), intent(inout), pointer :: corelist
type (domain_type), intent(inout), pointer :: domain_ptr
integer, intent(in), optional :: mpi_comm

character(len=*), intent(in), optional :: namelistFileParam
character(len=*), intent(in), optional :: streamsFileParam

integer :: iArg, nArgs
logical :: readNamelistArg, readStreamsArg
character(len=StrKIND) :: argument, namelistFile, streamsFile
Expand Down Expand Up @@ -109,6 +111,15 @@ end subroutine xml_stream_get_attributes
readNamelistArg = .false.
readStreamsArg = .false.

if (present(namelistFileParam) .and. len_trim(namelistFileParam) > 0 ) then
readNamelistArg = .true.
namelistFile = trim(namelistFileParam)
endif
if (present(streamsFileParam) .and. len_trim(streamsFileParam) > 0 ) then
readStreamsArg = .true.
streamsFile = trim(streamsFileParam)
endif

nArgs = command_argument_count()
iArg = 1
do while (iArg < nArgs)
Expand Down

0 comments on commit d33a772

Please sign in to comment.