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