process_command_line Subroutine

public subroutine process_command_line(this, rc)

Type Bound

regrid_support

Arguments

Type IntentOptional Attributes Name
class(regrid_support) :: this
integer, intent(out), optional :: rc

Calls

proc~~process_command_line~3~~CallsGraph proc~process_command_line~3 regrid_support%process_command_line interface~mapl_am_i_root MAPL_Am_I_Root proc~process_command_line~3->interface~mapl_am_i_root interface~mapl_assert MAPL_Assert proc~process_command_line~3->interface~mapl_assert mpi_finalize mpi_finalize proc~process_command_line~3->mpi_finalize proc~create_grid~2 regrid_support%create_grid proc~process_command_line~3->proc~create_grid~2 proc~mapl_return MAPL_Return proc~process_command_line~3->proc~mapl_return proc~mapl_verify MAPL_Verify proc~process_command_line~3->proc~mapl_verify proc~regrid_method_string_to_int regrid_method_string_to_int proc~process_command_line~3->proc~regrid_method_string_to_int proc~split_string split_string proc~process_command_line~3->proc~split_string proc~create_grid~2->proc~mapl_return proc~create_grid~2->proc~mapl_verify at at proc~create_grid~2->at none~get_dimension FileMetadata%get_dimension proc~create_grid~2->none~get_dimension none~make_grid~4 GridManager%make_grid proc~create_grid~2->none~make_grid~4 proc~create FileMetadataUtils%create proc~create_grid~2->proc~create proc~create_cf create_cf proc~create_grid~2->proc~create_cf proc~get_level_name FileMetadataUtils%get_level_name proc~create_grid~2->proc~get_level_name proc~unpackgridname UnpackGridName proc~create_grid~2->proc~unpackgridname proc~mapl_return->at insert insert proc~mapl_return->insert proc~mapl_throw_exception MAPL_throw_exception proc~mapl_return->proc~mapl_throw_exception proc~mapl_verify->proc~mapl_throw_exception ESMF_UtilStringUpperCase ESMF_UtilStringUpperCase proc~regrid_method_string_to_int->ESMF_UtilStringUpperCase push_back push_back proc~split_string->push_back none~get_dimension->proc~mapl_return none~get_dimension->at find find none~get_dimension->find none~make_grid_from_distgrid GridManager%make_grid_from_distGrid none~make_grid~4->none~make_grid_from_distgrid proc~create_cf->interface~mapl_assert proc~create_cf->proc~mapl_verify interface~mapl_configsetattribute MAPL_ConfigSetAttribute proc~create_cf->interface~mapl_configsetattribute proc~mapl_configcreate MAPL_ConfigCreate proc~create_cf->proc~mapl_configcreate proc~get_level_name->proc~mapl_return none~begin~52 StringVariableMap%begin proc~get_level_name->none~begin~52 none~get_coordinate_variable FileMetadata%get_coordinate_variable proc~get_level_name->none~get_coordinate_variable none~get_variables FileMetadata%get_variables proc~get_level_name->none~get_variables none~is_attribute_present Variable%is_attribute_present proc~get_level_name->none~is_attribute_present none~key~117 StringVariableMapIterator%key proc~get_level_name->none~key~117 none~next~48 StringVariableMapIterator%next proc~get_level_name->none~next~48 proc~get_variable_attribute FileMetadataUtils%get_variable_attribute proc~get_level_name->proc~get_variable_attribute

Called by

proc~~process_command_line~3~~CalledByGraph proc~process_command_line~3 regrid_support%process_command_line proc~main~2 main proc~main~2->proc~process_command_line~3 program~regrid_util Regrid_Util program~regrid_util->proc~main~2

Source Code

    subroutine process_command_line(this,rc)
    class(regrid_support) :: this
    integer, optional, intent(out) :: rc

    character(len=ESMF_MAXSTR) :: RegridMth
    integer :: nargs, i, status
    character(len=ESMF_MAXPATHLEN) :: str,astr
    character(len=ESMF_MAXPATHLEN) :: tp_filein,tp_fileout
    character(len=ESMF_MAXPATHLEN*100) :: cfileNames,coutputFiles
    character(len=ESMF_MAXSTR) :: gridname

    this%nx=1
    this%ny=6
    this%onlyvars=.false.
    this%alltimes=.true.
    regridMth='bilinear'
    this%cs_stretch_param=uninit
    this%lon_range=uninit
    this%lat_range=uninit
    this%shave=64
    this%deflate=0
    this%quantize_algorithm=0
    this%quantize_level=0
    this%zstandard_level=0
    this%use_weights = .false.
    nargs = command_argument_count()
    do i=1,nargs
      call get_command_argument(i,str)
      select case(trim(str))
      case ('-o')
         call get_command_argument(i+1,coutputfiles)
      case('-i')
         call get_command_argument(i+1,cfilenames)
      case('-ogrid')
         call get_command_argument(i+1,Gridname)
      case('-nx')
         call get_command_argument(i+1,astr)
         read(astr,*)this%nx
      case('-ny')
         call get_command_argument(i+1,astr)
         read(astr,*)this%ny
      case('-vars')
         call get_command_argument(i+1,this%vars)
         this%onlyVars = .true.
      case('-t')
         call get_command_argument(i+1,astr)
         read(astr,*)this%itime(1)
         call get_command_argument(i+2,astr)
         read(astr,*)this%itime(2)
         this%alltimes=.false.
      case('-stretch_factor')
         call get_command_argument(i+1,astr)
         read(astr,*)this%cs_stretch_param(1)
         call get_command_argument(i+2,astr)
         read(astr,*)this%cs_stretch_param(2)
         call get_command_argument(i+3,astr)
         read(astr,*)this%cs_stretch_param(3)
      case('-lon_range')
         call get_command_argument(i+1,astr)
         read(astr,*)this%lon_range(1)
         call get_command_argument(i+2,astr)
         read(astr,*)this%lon_range(2)
      case('-lat_range')
         call get_command_argument(i+1,astr)
         read(astr,*)this%lat_range(1)
         call get_command_argument(i+2,astr)
         read(astr,*)this%lat_range(2)
      case('-method')
         call get_command_argument(i+1,RegridMth)
      case('-tp_in')
         call get_command_argument(i+1,tp_filein)
         this%tripolar_file_in = tp_filein
      case('-tp_out')
         call get_command_argument(i+1,tp_fileout)
         this%tripolar_file_out = tp_fileout
      case('-shave')
         call get_command_argument(i+1,astr)
         read(astr,*)this%shave
      case('-deflate')
         call get_command_argument(i+1,astr)
         read(astr,*)this%deflate
      case('-quantize_algorithm')
         call get_command_argument(i+1,astr)
         read(astr,*)this%quantize_algorithm
      case('-quantize_level')
         call get_command_argument(i+1,astr)
         read(astr,*)this%quantize_level
      case('-zstandard_level')
         call get_command_argument(i+1,astr)
         read(astr,*)this%zstandard_level
      case('-file_weights')
         this%use_weights = .true.
      case('--help')
         if (mapl_am_I_root()) then

         end if
         call MPI_Finalize(status)
         return
      end select
    enddo

    if (.not.allocated(this%tripolar_file_out)) then
       this%tripolar_file_out = "empty"
    end if
    this%regridMethod = regrid_method_string_to_int(regridMth)
    _ASSERT(this%regridMethod/=UNSPECIFIED_REGRID_METHOD,"improper regrid method chosen")

    this%filenames = split_string(cfilenames,',')
    this%outputfiles = split_string(coutputfiles,',')
    _ASSERT(this%filenames%size() > 0, 'no input files')
    _ASSERT(this%outputfiles%size() >0, 'no ouput files specified')
    _ASSERT(this%filenames%size() == this%outputfiles%size(), 'different number of input and output files')
    if (.not.this%alltimes) then
       _ASSERT(this%filenames%size() == 1,'if selecting time from file, can only regrid a single file')
    end if

    call this%create_grid(gridname,_RC)
    _RETURN(_SUCCESS)

    end subroutine process_command_line