Note
Function that reads a script file. Keywords are identified and corresponding actions are triggered.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=512), | intent(in) | :: | job_file |
job file with macros to execute |
subroutine read_job(job_file) !================================================================================================ !<@note Function that reads a script file. Keywords are identified and corresponding actions are !< triggered. !<@endnote !------------------------------------------------------------------------------------------------ implicit none character(len=512), intent(in) :: job_file !! *job file with macros to execute* integer (kind=I4) :: vide character(len=512) :: keyword logical (kind=I4) :: first ! script file call get_unit( JOB ) open(unit = JOB, file = trim(job_file), status = 'old') call check_empty_lines() ! witness file call get_unit( SPY ) open(unit = SPY, file = "out/spy.txt", status = 'unknown') LINE_READ = 0 first = .true. ! determine if calc_z_f has been already used ! default function used: the tangent function PARAM%func_gen = FCT_TANG ! default is 2 bounds when generating profiles PARAM%nparam = 2 PARAM%calc_mstt = .true. PARAM%calc_zf = .true. ! default cutting plane for correlation lengths PARAM%orig_surf%cut = 0.5 PARAM%curr_surf%cut = 0.5 o: do keyword = repeat( ' ', len(keyword) ) read(JOB, *, iostat = vide) keyword ; LINE_READ = LINE_READ + 1 ! remove unwanted characters from keyword keyword = str_remove_chars(string = trim(keyword), chars = '- # *') write(SPY, '(a6,I4.4,a)') "line: ", LINE_READ, ' ', trim(keyword) selectcase( keyword(1:8) ) case('ACF_THEO') ! desired acf call acf_theo() case('ADD_NOIS') ! add noise to current surface call add_nois() case('ALLOCATE') ! allocate tabs in PARAM type call alloc_tabs() case('ANALYSIS') call surface_analysis() case('APOD_ACF') ! apodize acf call apod_acf() case('APOD_SUR') ! apodize surface call apod_sur() case('CALC_ACF') ! determine the surface acf call calc_acf() case('CALC_FFH') ! deigital filter call calc_ffh() case('CALC_ORD') ! determine height order call calc_ord() case('CALC_Z_F') ! final heights call calc_z_f() case('CALC_Z_I') ! starting heights call calc_z_i() case('DEF_SIZE') ! image size call def_size() case('DIGI_FIL') ! apply digital filter call digi_fil() case('END_LOOP') ! loop end call end_loop() case('END_SCRI') ! close the script reading call end_scri() exit o case('MAKE_MSK') ! turn image into mask call make_msk() case('MAKE_SCR') ! make secratches call make_scratches() case('MAKE_TEX') ! build a texture call make_tex() case('NB_PROCS') ! number of threads call nb_procs() case('PLT__ACF') ! print the correlation graphs and/or determine ! if the stop criterion is reached. call plt__acf() case('READ_PRF') ! read image call read_img() case('REPR_IMG') ! reproduce image call repr_img() case('SAVE_ACF') ! save the acf surface if ( sum( PARAM%imp_acf ) == 0 ) then call save_img( tab = PARAM%acf_surf ) ! IN: real acf else call save_img( tab = PARAM%imp_acf ) ! IN: wanted acf endif case('SAVE_PRF') ! save image call save_img( tab = PARAM%surf ) ! IN: surface to save case('SMOOTH__') ! low-pass filter call smooth__() case('SPCT_SUR') ! surface spectrum frequencies call spct_sur() case('STA_LOOP') ! loop start call sta_loop() case('STA_SCRI') ! start script call sta_scri() case('STA_THEO') ! desired stat moments call sta_theo() case('STAT_SUR') ! surface moments as reference call stat_sur() case('SUB_SURF') ! extract the best surface call sub_surf() endselect enddo o close(JOB) contains subroutine check_empty_lines() !! Check for empty lines in the script implicit none do read(JOB, '(A)', iostat = vide) keyword if (vide < 0) then rewind(JOB) return endif if (len_trim(keyword) == 0) stop 'Empty line in script file' enddo return endsubroutine check_empty_lines endsubroutine read_job