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~5~~CallsGraph proc~process_command_line~5 regrid_support%process_command_line interface~mapl_am_i_root MAPL_Am_I_Root proc~process_command_line~5->interface~mapl_am_i_root interface~mapl_assert MAPL_Assert proc~process_command_line~5->interface~mapl_assert mpi_finalize mpi_finalize proc~process_command_line~5->mpi_finalize proc~create_grid~3 regrid_support%create_grid proc~process_command_line~5->proc~create_grid~3 proc~mapl_return MAPL_Return proc~process_command_line~5->proc~mapl_return proc~mapl_verify MAPL_Verify proc~process_command_line~5->proc~mapl_verify proc~regrid_method_string_to_int regrid_method_string_to_int proc~process_command_line~5->proc~regrid_method_string_to_int proc~split_string split_string proc~process_command_line~5->proc~split_string proc~create_grid~3->proc~mapl_return proc~create_grid~3->proc~mapl_verify at at proc~create_grid~3->at none~create~9 FileMetadataUtils%create proc~create_grid~3->none~create~9 none~get_dimension~2 FileMetadataUtils%get_dimension proc~create_grid~3->none~get_dimension~2 none~get_level_name FileMetadataUtils%get_level_name proc~create_grid~3->none~get_level_name none~make_grid~3 GridManager%make_grid proc~create_grid~3->none~make_grid~3 proc~create_cf~2 create_cf proc~create_grid~3->proc~create_cf~2 proc~unpackgridname~2 UnpackGridName proc~create_grid~3->proc~unpackgridname~2 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~2->proc~mapl_return none~get_dimension~2->proc~mapl_verify none~get_dimension FileMetadata%get_dimension none~get_dimension~2->none~get_dimension none~get_level_name->proc~mapl_return none~first~177 StringVariableMapIterator%first none~get_level_name->none~first~177 none~ftn_begin~25 StringVariableMap%ftn_begin none~get_level_name->none~ftn_begin~25 none~ftn_end~25 StringVariableMap%ftn_end none~get_level_name->none~ftn_end~25 none~get_coordinate_variable~2 FileMetadataUtils%get_coordinate_variable none~get_level_name->none~get_coordinate_variable~2 none~get_variable_attribute FileMetadataUtils%get_variable_attribute none~get_level_name->none~get_variable_attribute none~get_variables~2 FileMetadataUtils%get_variables none~get_level_name->none~get_variables~2 none~is_attribute_present Variable%is_attribute_present none~get_level_name->none~is_attribute_present none~next~82 StringVariableMapIterator%next none~get_level_name->none~next~82 none~make_grid_from_distgrid GridManager%make_grid_from_distGrid none~make_grid~3->none~make_grid_from_distgrid proc~create_cf~2->interface~mapl_assert proc~create_cf~2->proc~mapl_verify interface~mapl_configsetattribute MAPL_ConfigSetAttribute proc~create_cf~2->interface~mapl_configsetattribute proc~mapl_configcreate MAPL_ConfigCreate proc~create_cf~2->proc~mapl_configcreate

Called by

proc~~process_command_line~5~~CalledByGraph proc~process_command_line~5 regrid_support%process_command_line proc~main~2 main proc~main~2->proc~process_command_line~5 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