My command line it very long, what can I do to make it sorter?

33 views
Skip to first unread message

Lukasz Kaczmraczyk

unread,
Jun 1, 2017, 4:06:30 AM6/1/17
to mofem...@googlegroups.com
If you run code with a complex set of preconditions, or you have many model parameters, command line could be very long. 

Lukasz Kaczmraczyk

unread,
Jun 2, 2017, 1:06:34 AM6/2/17
to mofem...@googlegroups.com
One way to solve that problem is to make script, e.g. bash script http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html

Another way is to write .petscrc  which contains fixes set command line options which you not often changing, see details http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Sys/PetscInitialize.html

For example:
mpirun -np 4 ./elasticity \
  
-my_file dam_4parts.h5m -my_is_partitioned \
  
-ksp_type gmres -ksp_max_it 1000  -ksp_atol 1e-13 -ksp_rtol 0  -ksp_monitor_lg_residualnorm  -ksp_final_residual -ksp_monitor -ksp_converged_reason
  
-my_order 1  -my_block_config block_config.in   \
  
-mofem_mg_verbose 1 -mofem_mg_coarse_order 1 -mofem_mg_levels 4  \
  
-pc_type mg \
  
-mg_coarse_ksp_type preonly -mg_coarse_pc_type lu -mg_coarse_pc_factor_mat_solver_package mumps \
  
-pc_mg_smoothup 20 -pc_mg_smoothdown 20  -pc_mg_type multiplicative

You can see in above to types of command line options, once which are a problem specific like mesh file name or solver tolerance, and other type related to solver setup, which unlike you like to change for typical analysis.

You put into .petscrc:
-ksp_monitor_lg_residualnorm  
-ksp_final_residual 
-ksp_monitor 
-ksp_converged_reason
-mofem_mg_verbose 1 
-mofem_mg_coarse_order 1 -mofem_mg_levels 4  
-pc_type mg 
-mg_coarse_ksp_type preonly -mg_coarse_pc_type lu 
-mg_coarse_pc_factor_mat_solver_package mumps 
 
-pc_mg_smoothup 20 -pc_mg_smoothdown 20  -pc_mg_type multiplicative


And you command line will look like this:
mpirun -np 4 ./elasticity \
  
-my_file dam_4parts.h5m -my_is_partitioned \
  
-ksp_type gmres -ksp_max_it 1000  -ksp_atol 1e-13 -ksp_rtol 0 
  
-my_order 1  -my_block_config block_config.in  

Note that in command line you have only options which you will change very often, where solver setup is hidden in .petscrc file. Note if you put option in command line it will overwrite option from .petscrc. Use -skip_petscrc in the code specific file to skip the .petscrc files.
Reply all
Reply to author
Forward
0 new messages