Skip to content

Commit

Permalink
Options handling (update)
Browse files Browse the repository at this point in the history
   * Update print_options
   * Update C interface to account for newly added options
   * Add new entries to ral_nlls.h
  • Loading branch information
Andrew Sajo committed Mar 22, 2019
1 parent 1281a33 commit 2f44c0a
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 110 deletions.
3 changes: 3 additions & 0 deletions libRALFit/include/ral_nlls.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ struct ral_nlls_options_d {
int error; /* Fortran output stream for error messages */
int out; /* Fortran output stream for general messages */
int print_level; /* levels of print output */
bool print_options; /* print all options? */
int print_header; /*=k; print one-liner header every k-th iteration */
int maxit; /* maximum number of iterations */
int model; /* what model to use? */
int type_of_method; /* what method to use? */
Expand Down Expand Up @@ -101,6 +103,7 @@ struct ral_nlls_inform_d {
ral_nllspkgtype_d_ scaled_g;
int external_return;
char external_name[81];
ral_nllspkgtype_d_ step;
};

/* Set default values of options */
Expand Down
9 changes: 8 additions & 1 deletion libRALFit/src/ral_nlls_ciface.f90
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ module ral_nlls_ciface
integer(C_INT) :: error
integer(C_INT) :: out
integer(C_INT) :: print_level
logical(c_bool) :: print_options
integer(C_INT) :: print_header
integer(C_INT) :: maxit
integer(C_INT) :: model
integer(C_INT) :: type_of_method
Expand Down Expand Up @@ -89,7 +91,7 @@ module ral_nlls_ciface
real(wp) :: scaled_g
integer(C_INT) :: external_return
character( kind = c_char), dimension(81) :: external_name

real(wp) :: step
end type nlls_inform

abstract interface
Expand Down Expand Up @@ -146,6 +148,8 @@ subroutine copy_options_in(coptions, foptions, f_arrays)
foptions%error = coptions%error
foptions%out = coptions%out
foptions%print_level = coptions%print_level
foptions%print_options = coptions%print_options
foptions%print_header = coptions%print_header
foptions%maxit = coptions%maxit
foptions%model = coptions%model
foptions%type_of_method = coptions%type_of_method
Expand Down Expand Up @@ -214,6 +218,7 @@ subroutine copy_info_out(finfo,cinfo)
end do
cinfo%bad_alloc(len(finfo%bad_alloc) + 1) = C_NULL_CHAR
cinfo%iter = finfo%iter
cinfo%step = finfo%step
cinfo%inner_iter = finfo%iter
cinfo%f_eval = finfo%f_eval
cinfo%g_eval = finfo%g_eval
Expand Down Expand Up @@ -293,6 +298,8 @@ subroutine ral_nlls_default_options_d(coptions) bind(C)
coptions%error = foptions%error
coptions%out = foptions%out
coptions%print_level = foptions%print_level
coptions%print_options = foptions%print_options
coptions%print_header = foptions%print_header
coptions%maxit = foptions%maxit
coptions%model = foptions%model
coptions%type_of_method = foptions%type_of_method
Expand Down
225 changes: 116 additions & 109 deletions libRALFit/src/ral_nlls_printing.f90
Original file line number Diff line number Diff line change
Expand Up @@ -70,115 +70,122 @@ Subroutine print_options(options)
Character (30) :: adj

Write (rec(1),Fmt=99995)

Write (adj,Fmt=99999) 'error'
Write (rec(2),Fmt=99997) adjustl(adj), options%error
Write (adj,Fmt=99999) 'out'
Write (rec(3),Fmt=99997) adjustl(adj), options%out
Write (adj,Fmt=99999) 'print_level'
Write (rec(4),Fmt=99997) adjustl(adj), options%print_level
Write (adj,Fmt=99999) 'maxit'
Write (rec(5),Fmt=99997) adjustl(adj), options%maxit
Write (adj,Fmt=99999) 'model'
Write (rec(6),Fmt=99997) adjustl(adj), options%model
Write (adj,Fmt=99999) 'type_of_method'
Write (rec(7),Fmt=99997) adjustl(adj), options%type_of_method
Write (adj,Fmt=99999) 'nlls_method'
Write (rec(8),Fmt=99997) adjustl(adj), options%nlls_method
Write (adj,Fmt=99999) 'lls_solver'
Write (rec(9),Fmt=99997) adjustl(adj), options%lls_solver
Write (adj,Fmt=99999) 'stop_g_absolute'
Write (rec(10),Fmt=99998) adjustl(adj), options%stop_g_absolute
Write (adj,Fmt=99999) 'stop_g_relative'
Write (rec(11),Fmt=99998) adjustl(adj), options%stop_g_relative
Write (adj,Fmt=99999) 'stop_f_absolute'
Write (rec(12),Fmt=99998) adjustl(adj), options%stop_f_absolute
Write (adj,Fmt=99999) 'stop_f_relative'
Write (rec(13),Fmt=99998) adjustl(adj), options%stop_f_relative
Write (adj,Fmt=99999) 'stop_s'
Write (rec(14),Fmt=99998) adjustl(adj), options%stop_s
Write (adj,Fmt=99999) 'relative_tr_radius'
Write (rec(15),Fmt=99997) adjustl(adj), options%relative_tr_radius
Write (adj,Fmt=99999) 'initial_radius_scale'
Write (rec(16),Fmt=99998) adjustl(adj), options%initial_radius_scale
Write (adj,Fmt=99999) 'initial_radius'
Write (rec(17),Fmt=99998) adjustl(adj), options%initial_radius
Write (adj,Fmt=99999) 'base_regularization'
Write (rec(18),Fmt=99998) adjustl(adj), options%base_regularization
Write (adj,Fmt=99999) 'regularization_term'
Write (rec(19),Fmt=99998) adjustl(adj), options%regularization_term
Write (adj,Fmt=99999) 'regularization_power'
Write (rec(20),Fmt=99998) adjustl(adj), options%regularization_power
Write (adj,Fmt=99999) 'maximum_radius'
Write (rec(21),Fmt=99998) adjustl(adj), options%maximum_radius
Write (adj,Fmt=99999) 'eta_successful'
Write (rec(22),Fmt=99998) adjustl(adj), options%eta_successful
Write (adj,Fmt=99999) 'eta_success_but_reduce'
Write (rec(23),Fmt=99998) adjustl(adj), options%eta_success_but_reduce
Write (adj,Fmt=99999) 'eta_very_successful'
Write (rec(24),Fmt=99998) adjustl(adj), options%eta_very_successful
Write (adj,Fmt=99999) 'eta_too_successful'
Write (rec(25),Fmt=99998) adjustl(adj), options%eta_too_successful
Write (adj,Fmt=99999) 'radius_increase'
Write (rec(26),Fmt=99998) adjustl(adj), options%radius_increase
Write (adj,Fmt=99999) 'radius_reduce'
Write (rec(27),Fmt=99998) adjustl(adj), options%radius_reduce
Write (adj,Fmt=99999) 'radius_reduce_max'
Write (rec(28),Fmt=99998) adjustl(adj), options%radius_reduce_max
Write (adj,Fmt=99999) 'hybrid_switch'
Write (rec(29),Fmt=99998) adjustl(adj), options%hybrid_switch
Write (adj,Fmt=99999) 'exact_second_derivatives'
Write (rec(30),Fmt=99996) adjustl(adj), options% &
exact_second_derivatives
Write (adj,Fmt=99999) 'subproblem_eig_fact'
Write (rec(31),Fmt=99996) adjustl(adj), options%subproblem_eig_fact
Write (adj,Fmt=99999) 'use_ews_subproblem'
Write (rec(32),Fmt=99996) adjustl(adj), options%use_ews_subproblem
Write (adj,Fmt=99999) 'scale'
Write (rec(33),Fmt=99997) adjustl(adj), options%scale
Write (adj,Fmt=99999) 'scale_max'
Write (rec(34),Fmt=99998) adjustl(adj), options%scale_max
Write (adj,Fmt=99999) 'scale_min'
Write (rec(35),Fmt=99998) adjustl(adj), options%scale_min
Write (adj,Fmt=99999) 'scale_trim_min'
Write (rec(36),Fmt=99996) adjustl(adj), options%scale_trim_min
Write (adj,Fmt=99999) 'scale_trim_max'
Write (rec(37),Fmt=99996) adjustl(adj), options%scale_trim_max
Write (adj,Fmt=99999) 'scale_require_increase'
Write (rec(38),Fmt=99996) adjustl(adj), options%scale_require_increase
Write (adj,Fmt=99999) 'calculate_svd_J'
Write (rec(39),Fmt=99996) adjustl(adj), options%calculate_svd_j
Write (adj,Fmt=99999) 'setup_workspaces'
Write (rec(40),Fmt=99996) adjustl(adj), options%setup_workspaces
Write (adj,Fmt=99999) 'remove_workspaces'
Write (rec(41),Fmt=99996) adjustl(adj), options%remove_workspaces
Write (adj,Fmt=99999) 'more_sorensen_maxits'
Write (rec(42),Fmt=99997) adjustl(adj), options%more_sorensen_maxits
Write (adj,Fmt=99999) 'more_sorensen_shift'
Write (rec(43),Fmt=99998) adjustl(adj), options%more_sorensen_shift
Write (adj,Fmt=99999) 'more_sorensen_tiny'
Write (rec(44),Fmt=99998) adjustl(adj), options%more_sorensen_tiny
Write (adj,Fmt=99999) 'more_sorensen_tol'
Write (rec(45),Fmt=99998) adjustl(adj), options%more_sorensen_tol
Write (adj,Fmt=99999) 'hybrid_tol'
Write (rec(46),Fmt=99998) adjustl(adj), options%hybrid_tol
Write (adj,Fmt=99999) 'hybrid_switch_its'
Write (rec(47),Fmt=99997) adjustl(adj), options%hybrid_switch_its
Write (adj,Fmt=99999) 'reg_order'
Write (rec(48),Fmt=99998) adjustl(adj), options%reg_order
Write (adj,Fmt=99999) 'inner_method'
Write (rec(49),Fmt=99997) adjustl(adj), options%inner_method
Write (adj,Fmt=99999) 'output_progress_vectors'
Write (rec(50),Fmt=99996) adjustl(adj), options% &
output_progress_vectors
Write (adj,Fmt=99999) 'update_lower_order'
Write (rec(51),Fmt=99996) adjustl(adj), options%update_lower_order
Write (adj,Fmt=99999) 'Fortran_Jacobian'
Write (rec(52),Fmt=99996) adjustl(adj), options%fortran_jacobian

Write (rec(53),Fmt=99994)

nrec = 53
! Begin OPTLIST.AWK contents
Write(adj,Fmt=99999) "error"
Write(rec(2),Fmt=99997) Adjustl(adj), options%error
Write(adj,Fmt=99999) "out"
Write(rec(3),Fmt=99997) Adjustl(adj), options%out
Write(adj,Fmt=99999) "print_level"
Write(rec(4),Fmt=99997) Adjustl(adj), options%print_level
Write(adj,Fmt=99999) "print_options"
Write(rec(5),Fmt=99996) Adjustl(adj), options%print_options
Write(adj,Fmt=99999) "print_header"
Write(rec(6),Fmt=99997) Adjustl(adj), options%print_header
Write(adj,Fmt=99999) "maxit"
Write(rec(7),Fmt=99997) Adjustl(adj), options%maxit
Write(adj,Fmt=99999) "model"
Write(rec(8),Fmt=99997) Adjustl(adj), options%model
Write(adj,Fmt=99999) "type_of_method"
Write(rec(9),Fmt=99997) Adjustl(adj), options%type_of_method
Write(adj,Fmt=99999) "nlls_method"
Write(rec(10),Fmt=99997) Adjustl(adj), options%nlls_method
Write(adj,Fmt=99999) "lls_solver"
Write(rec(11),Fmt=99997) Adjustl(adj), options%lls_solver
Write(adj,Fmt=99999) "stop_g_absolute"
Write(rec(12),Fmt=99998) Adjustl(adj), options%stop_g_absolute
Write(adj,Fmt=99999) "stop_g_relative"
Write(rec(13),Fmt=99998) Adjustl(adj), options%stop_g_relative
Write(adj,Fmt=99999) "stop_f_absolute"
Write(rec(14),Fmt=99998) Adjustl(adj), options%stop_f_absolute
Write(adj,Fmt=99999) "stop_f_relative"
Write(rec(15),Fmt=99998) Adjustl(adj), options%stop_f_relative
Write(adj,Fmt=99999) "stop_s"
Write(rec(16),Fmt=99998) Adjustl(adj), options%stop_s
Write(adj,Fmt=99999) "relative_tr_radius"
Write(rec(17),Fmt=99997) Adjustl(adj), options%relative_tr_radius
Write(adj,Fmt=99999) "initial_radius_scale"
Write(rec(18),Fmt=99998) Adjustl(adj), options%initial_radius_scale
Write(adj,Fmt=99999) "initial_radius"
Write(rec(19),Fmt=99998) Adjustl(adj), options%initial_radius
Write(adj,Fmt=99999) "base_regularization"
Write(rec(20),Fmt=99998) Adjustl(adj), options%base_regularization
Write(adj,Fmt=99999) "regularization"
Write(rec(21),Fmt=99997) Adjustl(adj), options%regularization
Write(adj,Fmt=99999) "regularization_term"
Write(rec(22),Fmt=99998) Adjustl(adj), options%regularization_term
Write(adj,Fmt=99999) "regularization_power"
Write(rec(23),Fmt=99998) Adjustl(adj), options%regularization_power
Write(adj,Fmt=99999) "maximum_radius"
Write(rec(24),Fmt=99998) Adjustl(adj), options%maximum_radius
Write(adj,Fmt=99999) "eta_successful"
Write(rec(25),Fmt=99998) Adjustl(adj), options%eta_successful
Write(adj,Fmt=99999) "eta_success_but_reduce"
Write(rec(26),Fmt=99998) Adjustl(adj), options%eta_success_but_reduce
Write(adj,Fmt=99999) "eta_very_successful"
Write(rec(27),Fmt=99998) Adjustl(adj), options%eta_very_successful
Write(adj,Fmt=99999) "eta_too_successful"
Write(rec(28),Fmt=99998) Adjustl(adj), options%eta_too_successful
Write(adj,Fmt=99999) "radius_increase"
Write(rec(29),Fmt=99998) Adjustl(adj), options%radius_increase
Write(adj,Fmt=99999) "radius_reduce"
Write(rec(30),Fmt=99998) Adjustl(adj), options%radius_reduce
Write(adj,Fmt=99999) "radius_reduce_max"
Write(rec(31),Fmt=99998) Adjustl(adj), options%radius_reduce_max
Write(adj,Fmt=99999) "tr_update_strategy"
Write(rec(32),Fmt=99997) Adjustl(adj), options%tr_update_strategy
Write(adj,Fmt=99999) "hybrid_switch"
Write(rec(33),Fmt=99998) Adjustl(adj), options%hybrid_switch
Write(adj,Fmt=99999) "exact_second_derivatives"
Write(rec(34),Fmt=99996) Adjustl(adj), options%exact_second_derivatives
Write(adj,Fmt=99999) "subproblem_eig_fact"
Write(rec(35),Fmt=99996) Adjustl(adj), options%subproblem_eig_fact
Write(adj,Fmt=99999) "use_ews_subproblem"
Write(rec(36),Fmt=99996) Adjustl(adj), options%use_ews_subproblem
Write(adj,Fmt=99999) "force_min_eig_symm"
Write(rec(37),Fmt=99996) Adjustl(adj), options%force_min_eig_symm
Write(adj,Fmt=99999) "scale"
Write(rec(38),Fmt=99997) Adjustl(adj), options%scale
Write(adj,Fmt=99999) "scale_max"
Write(rec(39),Fmt=99998) Adjustl(adj), options%scale_max
Write(adj,Fmt=99999) "scale_min"
Write(rec(40),Fmt=99998) Adjustl(adj), options%scale_min
Write(adj,Fmt=99999) "scale_trim_min"
Write(rec(41),Fmt=99996) Adjustl(adj), options%scale_trim_min
Write(adj,Fmt=99999) "scale_trim_max"
Write(rec(42),Fmt=99996) Adjustl(adj), options%scale_trim_max
Write(adj,Fmt=99999) "scale_require_increase"
Write(rec(43),Fmt=99996) Adjustl(adj), options%scale_require_increase
Write(adj,Fmt=99999) "calculate_svd_j"
Write(rec(44),Fmt=99996) Adjustl(adj), options%calculate_svd_j
Write(adj,Fmt=99999) "setup_workspaces"
Write(rec(45),Fmt=99996) Adjustl(adj), options%setup_workspaces
Write(adj,Fmt=99999) "remove_workspaces"
Write(rec(46),Fmt=99996) Adjustl(adj), options%remove_workspaces
Write(adj,Fmt=99999) "more_sorensen_maxits"
Write(rec(47),Fmt=99997) Adjustl(adj), options%more_sorensen_maxits
Write(adj,Fmt=99999) "more_sorensen_shift"
Write(rec(48),Fmt=99998) Adjustl(adj), options%more_sorensen_shift
Write(adj,Fmt=99999) "more_sorensen_tiny"
Write(rec(49),Fmt=99998) Adjustl(adj), options%more_sorensen_tiny
Write(adj,Fmt=99999) "more_sorensen_tol"
Write(rec(50),Fmt=99998) Adjustl(adj), options%more_sorensen_tol
Write(adj,Fmt=99999) "hybrid_tol"
Write(rec(51),Fmt=99998) Adjustl(adj), options%hybrid_tol
Write(adj,Fmt=99999) "hybrid_switch_its"
Write(rec(52),Fmt=99997) Adjustl(adj), options%hybrid_switch_its
Write(adj,Fmt=99999) "reg_order"
Write(rec(53),Fmt=99998) Adjustl(adj), options%reg_order
Write(adj,Fmt=99999) "inner_method"
Write(rec(54),Fmt=99997) Adjustl(adj), options%inner_method
Write(adj,Fmt=99999) "output_progress_vectors"
Write(rec(55),Fmt=99996) Adjustl(adj), options%output_progress_vectors
Write(adj,Fmt=99999) "update_lower_order"
Write(rec(56),Fmt=99996) Adjustl(adj), options%update_lower_order
Write(adj,Fmt=99999) "fortran_jacobian"
Write(rec(57),Fmt=99996) Adjustl(adj), options%fortran_jacobian
Write (rec(58),Fmt=99994)
nrec = 58
! End OPTLIST.AWK contents

Call printmsg(0,.False.,options,nrec,rec)

Expand Down

0 comments on commit 2f44c0a

Please sign in to comment.