![]()  | 
  
    libSUFR
    
   a LIBrary of Some Useful Fortran Routines 
   | 
 
System-related procedures. More...
Functions/Subroutines | |
| subroutine | quit_program (message) | 
| Print a message to StdOut and stop the execution of the current program.   | |
| subroutine | quit_program_warning (message, status) | 
| Print a warning to StdOut and stop the execution of the current program.   | |
| subroutine | quit_program_error (message, status) | 
| Print an error message to StdErr and stop the execution of the current program.   | |
| subroutine | execute_command_line_verbose (command, wait, status, quit_on_error) | 
| Execute a shell command and print a message upon error. Optionally stop the execution of the current program in that case.   | |
| subroutine | execute_command_line_quit_on_error (command, wait, status) | 
| Execute a shell command. Upon error, print a message and stop the execution of the current program.   | |
| character function, dimension(1024 *10) | execute_command_line_and_return_str (command, wait, status) | 
| Execute a shell command and return the result as a string.   | |
| integer function | execute_command_line_and_return_int (command, wait, status) | 
| Execute a shell command and return the result as an integer.   | |
| subroutine | syntax_print (syntax, descr) | 
| Print a syntax message to StdErr.   | |
| subroutine | syntax_quit (syntax, status, descr) | 
| Print a syntax message to StdErr and stop the execution of the current program.   | |
| subroutine | file_open_error (filename, filetype, iostat, iomsg) | 
| Print a message to StdErr upon file open error.   | |
| subroutine | file_open_error_quit (filename, filetype, iostat, iomsg) | 
| Print a message to StdErr on file open error, and stop the execution of the current program.   | |
| subroutine | file_read_error (filename, line, procedure, iostat, iomsg) | 
| Print a message to StdErr on file read error.   | |
| subroutine | file_read_error_quit (filename, line, status, procedure, iostat, iomsg) | 
| Print a message to StdErr on file read error, and stop the execution of the current program.   | |
| subroutine | file_write_error (filename, line) | 
| Print a message to StdErr on file write error.   | |
| subroutine | file_write_error_quit (filename, line, status) | 
| Print a message to StdErr on file write error, and stop the execution of the current program.   | |
| subroutine | file_end_error (filename) | 
| Print a message to StdErr on reaching the end of a file while reading.   | |
| subroutine | file_end_quit (filename, status) | 
| Print a message to StdErr on reaching the end of a file while reading, and stop the code.   | |
| subroutine | file_read_end_error (filename, line, readstatus, stopcode, exitstatus, message) | 
| Print a message to StdErr on read error or reaching the end of a file while reading, and optionally stop the code.   | |
| subroutine | warn (message, unit) | 
| Print a warning to StdOut or StErr.   | |
| subroutine | error (message, unit) | 
| Print an error to StdOut or StErr.   | |
| subroutine | system_time (year, month, day, hour, minute, second, tz) | 
| Get date and time from the system clock.   | |
| real(double) function | timestamp () | 
| Return the time stamp in seconds since 1970-01-01 00:00:00 UTC.   | |
| subroutine | printprogressbar (frac, timestamp0) | 
| Print a text progress bar to the screen, optionally with estimated time left.   | |
| pure character function, dimension(8) | tms (t) | 
| Print time as mm:ss.s string, input in hours.   | |
| subroutine | print_runtimes (calltype, sp, dec) | 
| Print run times: wall time and CPU time.   | |
| subroutine | print_cputime (sp, dec, unit) | 
| Print CPU time since the first execution of the program.   | |
| subroutine | find_free_io_unit (unit) | 
| Find the first unused I/O unit larger than 100.   | |
| subroutine | file_skip_header (unit, nlines) | 
| Skip the next (e.g. first) lines of a file.   | |
| pure subroutine | swapint (int1, int2) | 
| Swap two integer variables.   | |
| pure subroutine | swapreal (rl1, rl2) | 
| Swap two single-precision real variables.   | |
| pure subroutine | swapdbl (dbl1, dbl2) | 
| Swap two double-precision real variables.   | |
| subroutine | swapstr (str1, str2) | 
| Swap two strings.   | |
System-related procedures.
| subroutine sufr_system::error | ( | character, dimension(*), intent(in) | message, | 
| integer, intent(in), optional | unit ) | 
Print an error to StdOut or StErr.
| message | Warning message | 
| unit | Output unit: 0-StdErr, 1-StdOut - (optional; default = 0) | 
Definition at line 670 of file system.f90.
References sufr_constants::program_name.
Referenced by execute_command_line_verbose(), sufr_statistics::mean_weight(), sufr_statistics::prob_range(), sufr_text::replace_string_in_textfile(), sufr_statistics::stdev(), and sufr_statistics::stdev_weight().
| integer function sufr_system::execute_command_line_and_return_int | ( | character, dimension(*), intent(in) | command, | 
| logical, intent(in), optional | wait, | ||
| integer, intent(in), optional | status ) | 
Execute a shell command and return the result as an integer.
| command | Command line to execute | 
| wait | Execute command synchronously (in the foreground) if true, asynchronously (in the background) if false (optional; default=true) | 
| status | Exit code: 0-ok, 1-not ok. The latter makes the stop command appear on screen (optional; default=1) | 
| Integer | containing the result. If more data were returned by the command, only the first is parsed. | 
Definition at line 254 of file system.f90.
References execute_command_line_and_return_int(), execute_command_line_and_return_str(), and quit_program_error().
Referenced by execute_command_line_and_return_int().

| character function, dimension(1024*10) sufr_system::execute_command_line_and_return_str | ( | character, dimension(*), intent(in) | command, | 
| logical, intent(in), optional | wait, | ||
| integer, intent(in), optional | status ) | 
Execute a shell command and return the result as a string.
| command | Command line to execute | 
| wait | Execute command synchronously (in the foreground) if true, asynchronously (in the background) if false (optional; default=true) | 
| status | Exit code: 0-ok, 1-not ok. The latter makes the stop command appear on screen (optional; default=1) | 
| String | containing the result. Multiple lines are separated by newline code. The size is 10kb, and an error occurs when one attempts to stuff more into it. | 
Definition at line 182 of file system.f90.
References sufr_kinds::double, execute_command_line_and_return_str(), execute_command_line_verbose(), file_open_error_quit(), file_read_error_quit(), find_free_io_unit(), sufr_random_numbers::get_ran_seed(), sufr_constants::homedir, sufr_constants::newline, and sufr_random_numbers::ran_unif().
Referenced by execute_command_line_and_return_int(), and execute_command_line_and_return_str().

| subroutine sufr_system::execute_command_line_quit_on_error | ( | character, dimension(*), intent(in) | command, | 
| logical, intent(in), optional | wait, | ||
| integer, intent(in), optional | status ) | 
Execute a shell command. Upon error, print a message and stop the execution of the current program.
| command | Command line to execute | 
| wait | Execute command synchronously (in the foreground) if true, asynchronously (in the background) if false (optional; default=true) | 
| status | Exit code: 0-ok, 1-not ok. The latter makes the stop command appear on screen (optional; default=1) | 
Definition at line 153 of file system.f90.
References execute_command_line_verbose().

| subroutine sufr_system::execute_command_line_verbose | ( | character, dimension(*), intent(in) | command, | 
| logical, intent(in), optional | wait, | ||
| integer, intent(in), optional | status, | ||
| logical, intent(in), optional | quit_on_error ) | 
Execute a shell command and print a message upon error. Optionally stop the execution of the current program in that case.
| command | Command line to execute | 
| wait | Execute command synchronously (in the foreground) if true, asynchronously (in the background) if false (optional; default=true) | 
| status | Exit code: 0-ok, 1-not ok. The latter makes the stop command appear on screen (optional; default=1) | 
| quit_on_error | Quit the program upon error (optional; defaults to false) | 
Definition at line 104 of file system.f90.
References error(), and quit_program_error().
Referenced by execute_command_line_and_return_str(), and execute_command_line_quit_on_error().

| subroutine sufr_system::file_end_error | ( | character, dimension(*), intent(in) | filename | ) | 
Print a message to StdErr on reaching the end of a file while reading.
| filename | Filename | 
Definition at line 552 of file system.f90.
References sufr_constants::program_name.
Referenced by file_read_end_error().
| subroutine sufr_system::file_end_quit | ( | character, dimension(*), intent(in) | filename, | 
| integer, intent(in) | status ) | 
Print a message to StdErr on reaching the end of a file while reading, and stop the code.
| filename | Filename | 
| status | Exit code: 0-ok, 1-not ok. The latter makes the stop command appear on screen | 
Definition at line 570 of file system.f90.
References sufr_constants::program_name.
Referenced by file_read_end_error().
| subroutine sufr_system::file_open_error | ( | character, dimension(*), intent(in) | filename, | 
| integer, intent(in) | filetype, | ||
| integer, intent(in), optional | iostat, | ||
| character, dimension(*), intent(in), optional | iomsg ) | 
Print a message to StdErr upon file open error.
| filename | Filename | 
| filetype | File type: 0: (0)utput, 1: (1)nput | 
| ioStat | IO status (optional) | 
| ioMsg | IO status message (optional; default = none) | 
Definition at line 345 of file system.f90.
References sufr_constants::program_name.
Referenced by file_open_error_quit().
| subroutine sufr_system::file_open_error_quit | ( | character, dimension(*), intent(in) | filename, | 
| integer, intent(in) | filetype, | ||
| integer, intent(in), optional | iostat, | ||
| character, dimension(*), intent(in), optional | iomsg ) | 
Print a message to StdErr on file open error, and stop the execution of the current program.
| filename | Filename | 
| filetype | File type: 0: (0)utput, 1: (1)nput | 
| ioStat | IO status (optional): 0-ok, otherwise not ok. The latter makes the stop command appear on screen | 
| ioMsg | IO status message (optional; default = none) | 
Definition at line 388 of file system.f90.
References file_open_error().
Referenced by execute_command_line_and_return_str().

| subroutine sufr_system::file_read_end_error | ( | character, dimension(*), intent(in) | filename, | 
| integer, intent(in) | line, | ||
| integer, intent(in) | readstatus, | ||
| integer, intent(in) | stopcode, | ||
| integer, intent(in) | exitstatus, | ||
| character, dimension(*), intent(in), optional | message ) | 
Print a message to StdErr on read error or reaching the end of a file while reading, and optionally stop the code.
| filename | Filename | 
| line | Line number where read error occurred - 0: no line | 
| readstatus | Read status provided by iostat | 
| stopcode | Stop the execution of the code: 0-no, 1-yes | 
| exitstatus | Exit code: 0-ok, 1-not ok. The latter makes the stop command appear on screen | 
| message | Custom message (optional; default = none) | 
Definition at line 601 of file system.f90.
References file_end_error(), file_end_quit(), file_read_error(), and file_read_error_quit().

| subroutine sufr_system::file_read_error | ( | character, dimension(*), intent(in) | filename, | 
| integer, intent(in) | line, | ||
| character, dimension(*), intent(in), optional | procedure, | ||
| integer, intent(in), optional | iostat, | ||
| character, dimension(*), intent(in), optional | iomsg ) | 
Print a message to StdErr on file read error.
| filename | Filename | 
| line | Line number where read error occurred - 0: no line | 
| procedure | Name of the procedure this subroutine is called from (without "()" - optional; default = none) | 
| ioStat | IO status code (optional) | 
| ioMsg | IO status message (optional; default = none) | 
Definition at line 424 of file system.f90.
References sufr_constants::program_name.
Referenced by file_read_end_error(), and file_read_error_quit().
| subroutine sufr_system::file_read_error_quit | ( | character, dimension(*), intent(in) | filename, | 
| integer, intent(in) | line, | ||
| integer, intent(in) | status, | ||
| character, dimension(*), intent(in), optional | procedure, | ||
| integer, intent(in), optional | iostat, | ||
| character, dimension(*), intent(in), optional | iomsg ) | 
Print a message to StdErr on file read error, and stop the execution of the current program.
| filename | Filename | 
| line | Line number where read error occurred - 0: no line | 
| status | Exit code: 0-ok, 1-not ok. The latter makes the stop command appear on screen | 
| procedure | Name of the procedure this subroutine is called from (without "()"; optional; default = none) | 
| ioStat | IO status code (optional) | 
| ioMsg | IO status message (optional; default = none) | 
Definition at line 462 of file system.f90.
References file_read_error().
Referenced by execute_command_line_and_return_str(), and file_read_end_error().

| subroutine sufr_system::file_skip_header | ( | integer, intent(in) | unit, | 
| integer, intent(in) | nlines ) | 
Skip the next (e.g. first) lines of a file.
| unit | File unit | 
| nLines | Number of lines to skip | 
Definition at line 971 of file system.f90.
References sufr_dummy::dumstr.
| subroutine sufr_system::file_write_error | ( | character, dimension(*), intent(in) | filename, | 
| integer, intent(in) | line ) | 
Print a message to StdErr on file write error.
| filename | Filename | 
| line | Line number where write error occurred - 0: no line | 
Definition at line 497 of file system.f90.
References sufr_constants::program_name.
| subroutine sufr_system::file_write_error_quit | ( | character, dimension(*), intent(in) | filename, | 
| integer, intent(in) | line, | ||
| integer, intent(in) | status ) | 
Print a message to StdErr on file write error, and stop the execution of the current program.
| filename | Filename | 
| line | Line number where write error occurred - 0: no line | 
| status | Exit code: 0-ok, 1-not ok. The latter makes the stop command appear on screen | 
Definition at line 522 of file system.f90.
References sufr_constants::program_name.
| subroutine sufr_system::find_free_io_unit | ( | integer, intent(out) | unit | ) | 
Find the first unused I/O unit larger than 100.
| unit | I/O unit; unit > 100 (output) | 
Definition at line 950 of file system.f90.
Referenced by execute_command_line_and_return_str(), sufr_pgplot::pgplot_settings(), and sufr_text::replace_string_in_textfile().
| subroutine sufr_system::print_cputime | ( | integer, intent(in), optional | sp, | 
| integer, intent(in), optional | dec, | ||
| integer, intent(in), optional | unit ) | 
Print CPU time since the first execution of the program.
| sp | Number of leading spaces (optional; default = 0) | 
| dec | Number of decimals in the time (optional; default = 3) | 
| unit | Output unit (0: stdErr, 6: stdOut; optional; default = 6) | 
Definition at line 901 of file system.f90.
References sufr_kinds::double.
| subroutine sufr_system::print_runtimes | ( | integer, intent(in), optional | calltype, | 
| integer, intent(in), optional | sp, | ||
| integer, intent(in), optional | dec ) | 
Print run times: wall time and CPU time.
| calltype | Type of call: 1-reset time; 2-print and reset time; 3-print time (optional; default = 1 on first call, else 3) | 
| sp | Number of leading spaces (optional; default = 0) | 
| dec | Number of decimals in the time (optional; default = 3) | 
Definition at line 830 of file system.f90.
References sufr_kinds::double, sufr_kinds::long, and warn().

| subroutine sufr_system::printprogressbar | ( | real(double), intent(in) | frac, | 
| real(double), intent(in), optional | timestamp0 ) | 
Print a text progress bar to the screen, optionally with estimated time left.
| frac | Fraction of the task completed | 
| timestamp0 | Timestamp of start of task (optional; default = don't print time left) | 
Definition at line 762 of file system.f90.
References sufr_constants::cursorup, sufr_kinds::double, timestamp(), and tms().

| subroutine sufr_system::quit_program | ( | character, dimension(*), intent(in) | message | ) | 
Print a message to StdOut and stop the execution of the current program.
| message | Exit message | 
Definition at line 34 of file system.f90.
Referenced by sufr_command_line::split_short_cl_options().
| subroutine sufr_system::quit_program_error | ( | character, dimension(*), intent(in) | message, | 
| integer, intent(in) | status ) | 
Print an error message to StdErr and stop the execution of the current program.
| message | Exit/error message | 
| status | Exit code: 0-ok, 1-not ok. The latter makes the stop command appear on screen | 
Definition at line 77 of file system.f90.
References sufr_constants::program_name.
Referenced by sufr_statistics::bin_data_1d(), sufr_statistics::bin_data_1d_sp(), sufr_statistics::bin_data_2d(), sufr_statistics::bin_data_2d_sp(), execute_command_line_and_return_int(), execute_command_line_verbose(), sufr_numerics::gcd(), sufr_numerics::gcd2(), sufr_getopt::getopt_get_command_argument(), sufr_getopt::getopt_optarg_to_dbl(), sufr_getopt::getopt_optarg_to_int(), sufr_getopt::getopt_optarg_to_real(), sufr_sports::heartrate2power(), sufr_statistics::histogram_1d_onthefly(), sufr_statistics::histogram_2d_onthefly(), sufr_numerics::lcm(), sufr_fitting::linear_fit_yerr(), sufr_statistics::mean(), sufr_statistics::mean_sp(), sufr_statistics::mean_weight(), sufr_statistics::median(), sufr_statistics::median_sp(), sufr_fitting::nonlin_fit_example_myfunc(), sufr_statistics::prob_range(), sufr_statistics::prob_range_sp(), sufr_sorting::sorted_index_list(), sufr_statistics::stdev(), sufr_statistics::stdev_sp(), and sufr_statistics::stdev_weight().
| subroutine sufr_system::quit_program_warning | ( | character, dimension(*), intent(in) | message, | 
| integer, intent(in) | status ) | 
Print a warning to StdOut and stop the execution of the current program.
| message | Exit message/warning | 
| status | Exit code: 0-ok, 1-not ok. This makes the stop command appear on screen | 
Definition at line 52 of file system.f90.
References sufr_constants::program_name.
| pure subroutine sufr_system::swapdbl | ( | real(double), intent(inout) | dbl1, | 
| real(double), intent(inout) | dbl2 ) | 
Swap two double-precision real variables.
| dbl1 | Double 1 | 
| dbl2 | Double 2 | 
Definition at line 1033 of file system.f90.
References sufr_kinds::double.
Referenced by sufr_fitting::nonlin_fit_example_myfunc().
| pure subroutine sufr_system::swapint | ( | integer, intent(inout) | int1, | 
| integer, intent(inout) | int2 ) | 
Swap two integer variables.
| int1 | Integer 1 | 
| int2 | Integer 2 | 
Definition at line 993 of file system.f90.
Referenced by sufr_numerics::gcd2().
| pure subroutine sufr_system::swapreal | ( | real, intent(inout) | rl1, | 
| real, intent(inout) | rl2 ) | 
Swap two single-precision real variables.
| rl1 | real 1 | 
| rl2 | real 2 | 
Definition at line 1013 of file system.f90.
| subroutine sufr_system::swapstr | ( | character, dimension(*), intent(inout) | str1, | 
| character, dimension(*), intent(inout) | str2 ) | 
Swap two strings.
| str1 | String 1 (I/O) | 
| str2 | String 2 (I/O) | 
Definition at line 1053 of file system.f90.
References warn().

| subroutine sufr_system::syntax_print | ( | character, dimension(*), intent(in) | syntax, | 
| character, dimension(*), intent(in), optional | descr ) | 
Print a syntax message to StdErr.
| syntax | Description of syntax | 
| descr | Program description (optional; default = none) | 
Definition at line 288 of file system.f90.
References sufr_constants::program_name.
| subroutine sufr_system::syntax_quit | ( | character, dimension(*), intent(in) | syntax, | 
| integer, intent(in), optional | status, | ||
| character, dimension(*), intent(in), optional | descr ) | 
Print a syntax message to StdErr and stop the execution of the current program.
| syntax | Description of syntax | 
| status | Exit code: 0-ok, 1-not ok. The latter makes the stop command appear on screen (optional; default = 0) | 
| descr | Program description (optional; default = none) | 
Definition at line 310 of file system.f90.
References sufr_constants::program_name.
| subroutine sufr_system::system_time | ( | integer, intent(out) | year, | 
| integer, intent(out) | month, | ||
| integer, intent(out) | day, | ||
| integer, intent(out) | hour, | ||
| integer, intent(out) | minute, | ||
| real(double), intent(out) | second, | ||
| real(double), intent(out), optional | tz ) | 
Get date and time from the system clock.
| year | Current year CE | 
| month | Current month | 
| day | Current day of month | 
| hour | Current hour of day | 
| minute | Current minute of time | 
| second | Current second of time | 
| tz | Time zone in hours (optional) | 
Definition at line 703 of file system.f90.
References sufr_kinds::double, and sufr_dummy::dumstr99.
| real(double) function sufr_system::timestamp | 
Return the time stamp in seconds since 1970-01-01 00:00:00 UTC.
| timestamp | Unix timestamp: number of seconds since 1970-01-01 00:00:00 UTC, accuracy: 1ms | 
Definition at line 738 of file system.f90.
References sufr_kinds::double, sufr_dummy::dumstr99, timestamp(), and sufr_date_and_time::ymdhms2jd().
Referenced by printprogressbar(), and timestamp().

| pure character function, dimension(8) sufr_system::tms | ( | real(double), intent(in) | t | ) | 
Print time as mm:ss.s string, input in hours.
| t | Time (h) | 
| tms | Time as mm:ss.s string | 
Definition at line 801 of file system.f90.
References sufr_kinds::double, and tms().
Referenced by printprogressbar(), and tms().

| subroutine sufr_system::warn | ( | character, dimension(*), intent(in) | message, | 
| integer, intent(in), optional | unit ) | 
Print a warning to StdOut or StErr.
| message | Warning message | 
| unit | Output unit: 0-StdErr, 1-StdOut (optional; default = 0) | 
Definition at line 645 of file system.f90.
References sufr_constants::program_name.
Referenced by sufr_statistics::correlation(), sufr_fitting::linear_fit_yerr(), sufr_interpolate::linear_interpolate_array(), sufr_statistics::mean(), sufr_fitting::nonlin_fit_example_myfunc(), print_runtimes(), sufr_statistics::prob_range(), swapstr(), sufr_text::utf16to8(), and sufr_optics::wavelength2rgb().