*comment This is a demostration and test of the macro preprocessor in action. This text will only be seen in the generated list `file. *endcomment test set 1 expression analysis set command comment command replace command delete command page command substitutions dump_command error command default command remove command *error ('This is a test of the error directive-you should not see any others') *set(test_l_1=.true.) *set(test_l_2=.false.) *set(test_i_1=1) *set(test_i_2=+2) *set(test_i_3=-2) *set(test_s_1=' string with embeded blanks and blanks at each end ') *if(test_l_1.ne..true.) *error ('Test 1.1 failed') *endif *if($test_l_2$.ne..false.) *error('Test 1.2 failed') *endif *if(.false.) *error('Test 1.3 failed') *elseif(test_i_1.ne.1) *error( 'Test 1.4 failed') *endif *if(test_i_2.ne.2) *error( 'Test 1.5 failed') *endif *if(test_i_3.eq.-2) *else *error('Test 1.6 failed') *endif *if(test_s_1.eq.' string with embeded blanks and blanks at each end ') *else *error(' Test 1.7 failed') *endif *comment dump command in list `file only *endcomment *dump *replace(test_i_2=test_i_2+1) *if(test_i_2.ne.3) *error('Test 1.8 failed') *endif *delete(test_l_1) *delete(test_l_2) *delete(test_i_1) *delete(test_i_2) *delete(test_i_3) *delete(test_s_1) *set(a=1) *default(a=.true.) *default(b=.false.) *if(type(a).ne.'INTEGER') *error('Test 1.9 failed') *endif *if(b.ne..false.) *error('Test 1.10 failed') *endif *remove(a) *remove(b) *remove(c) *comment deleted all symbols *endcomment *page *comment start of new page *endcomment test 2 list command reset command substitutions *list(list_test) line 1 line 2 line 3 line 4 line 5 line 6 line 7 line 8 *endlist *set(l_1='$list_test$') *set(l_2='$list_test$') *set(l_3='$list_test$') *set(l_4='$list_test$') *set(l_5='$list_test$') *set(l_6='$list_test$') *set(l_7='$list_test$') *set(l_8='$list_test$') *set(l_9='$list_test$') *set(l_10='$list_test$') *reset(list_test) *set(l_11='$list_test$') *reset(list_test) *if(l_1.ne.list_test) *error('Test 2.1 failed') *elseif(l_2.ne.list_test) *error('Test 2.2 failed') *elseif(l_3.ne.list_test) *error('Test 2.3 failed') *elseif(l_4.ne.list_test) *error('Test 2.4 failed') *elseif(l_5.ne.list_test) *error('Test 2.5 failed') *elseif(l_6.ne.list_test) *error('Test 2.6 failed') *elseif(l_7.ne.list_test) *error('Test 2.7 failed') *elseif(l_8.ne.list_test) *error('Test 2.8 failed') *elseif(l_9.ne.list_test) *error('Test 2.9 failed') *elseif(l_10.ne.list_test) *error('Test 2.10 failed') *else *reset(list_test) *endif *if(l_11.eq.list_test) *else *error('Test 2.11 failed') *endif *delete(list_test) *delete(l_1) *delete(l_2) *delete(l_3) *delete(l_4) *delete(l_5) *delete(l_6) *delete(l_7) *delete(l_8) *delete(l_9) *delete(l_10) *delete(l_11) *mlist(a,b,c,d) '123' '4567' '891' 'defg' 'hij' '`'aa' '11111' 'defg' '' '' '123' *endmlist a b c D a b c D a b c D a b c D a b c D *delete(a) *delete(b) *delete(c) *delete(d) *page test 3 macro facility *macro(test_macro) line 1 line 2 test_sub line 3 *endmacro *set(test_sub=.TRUE.) *domacro(test_macro) *delete(test_sub) *domacro(test_macro)(test_sub='addendum') *delete(test_macro) *macro(test) *default(a=.true.) *default(b=.false.) *if(type(a)$.ne.'STRING') *error('macro a') *endif *if($type(b).ne.'LOGICAL') *error('macro b') *endif *endmacro *domacro(test)(a='string') *remove(test) *page test 4 if simple and complex evaluation of simple expressions *set(test_true=.true.) *set(test_false=.false.) *if(.true.) this line should print out-simple if ok *else *error('Test 4.1 failed') *endif *if(.false.) *error ('Test 4.2 failed') *else else test ok *endif *if(test_false) *error('Test 4.3 failed') *elseif(test_true) elseif test ok *else *error( 'Test 4.3 failed at else') *endif *if(test_false) *error('Test 4.4 failed at if') *elseif(.false.) *error('Test 4.4 failed at first elseif') *elseif(test_true) second if-elseif test ok *else *error('Test 4.4 failed at else') *endif *if(.true.) level-1 nested if-ok *if(.true.) level-2 nested if-ok *elseif(.true.) *error('Test 4.5 failed at level 2 elseif') *else *error('Test 4.5 failed at level 2 else') *endif back to level 1 *elseif(.true.) *error('Test 4.5 failed at level 1 elseif') *endif *if(test_false) *error('Test 4.6 failed at if') *elseif(test_true) passed substitution in if test *else *error('Test 4.6 failed at else') *endif *set(test_1=1) *set(test_2=test_1+1) *set(test_3='abC') *if(test_1.eq.1) if with numeric compare passed ok *else *error('Test 4.7 failed') *endif *if(test_false.eq..false.) passed logical compare *else *error('Test 4.8 failed') *endif *if(test_3.eq.'abc') *ERROR('Test 4.9 failed at if') *elseif(test_3.eq.'abC') passed string compare *else *error('Test 4.9 failed at else') *endif *if(test_2.ne.2) *error('Test 4.10 failed') *else complex set ok *endif *delete(test_1) *delete(test_2) *delete(test_3) *delete(test_true) *delete(test_false) *page set up do loop tests *set(limit1=-1) *set(limit2=+1) *set(limit3=0) *do (i=limit1,limit2) x($i$)=y(i$+5) *do (j=limit2,limit1) z($i,j)=i+j *enddo *enddo *do (i=-5,5,3) x(i)=i *enddo *do (i=limit1-1,limit2+1,limit3+1) i *enddo *delete(limit1) *delete(limit2) *delete(limit3) *page include one of the macro programs include `files here for a test *include(parameters.inc) *page option command label_command error command *option(quote_char=+) *set(temp_1=+message useing alternate quote char+) temp_1 *option(quote_char=') *set(temp_2='message useing default quote char') temp_2 *option(directive_char=+) +set(temp_3='message useing alternate directive character') temp_3 +option(directive_char=*) *option(sub_char=+) *set(test_sub='abc-def') useing alternate sustitution char->+test_sub+<- *option(sub_char=$) *option(l_output=.false.) this line should not appear in the output (.SRC.) `file *option(l_output=.true.) *option(l_list=.false.) this comment should not appear in the list `file *option(l_list=.true.) *option(l_sub=.false.) subs disabled ->test_sub *option(l_sub=.true.) subs enabled ->test_sub *option(l_show=.true.) *do (i=1,2) j=i *do( k=-1,-2) l=k *enddo *enddo *option(l_show=.false.) test of automatic unique label_generation and starting value set label label0 label1 label2 label3 label4 label5 label6 label7 label8 label9 label label0 label1 label2 label3 label4 label5 label6 label7 label8 label9 *option(next_label=1) label label label0 label0 *option(next_label0=10) label label label0 label0 *option(next_label1=15) label1 label1 *option(next_label2=15) label2 label2 *option(next_label3=15) label3 label3 *option(next_label4=15) label4 label4 *option(next_label5=15) label5 label5 *option(next_label6=15) label6 label6 *option(next_label7=15) label7 label7 *option(next_label8=15) label8 label8 *option(next_label9=15) label9 label9 test of escape char and option to change `` `label: *option(escape_char=\) \\ \label: *option(escape_char=`) *delete(temp_1) *delete(temp_2) *delete(temp_3) *page test of def and type functions *if($def(test_sub)$) *else *error('Test 7.1 failed') *endif *if($def(sub_test)$) *error('Test 7.2 failed') *endif *set(t_1=.true.) *set(t_2=123) *set(t_3='a string') *set(s_1=$type(t_1)$) *set(s_2=$type(t_2)$) *set(s_3=$type(t_3)$) *set(s_4=$type(t_4)$) *if(s_1.ne.'LOGICAL') *error('Test 7.3 failed') *endif *if(s_2.ne.'INTEGER') *error('Test 7.4 failed') *endif *if(s_3.ne.'STRING') *error('Test 7.5 failed') *endif *if(s_4.ne.'UNKNOWN') *error('Test 7.6 failed') *endif *set(a='abc') *if($length(a)$.ne.3) *error('Test 7.7 failed') *endif *replace(a=.true.) *if($length(a)$.ne.6) *error('Test 7.8 failed') *endif *replace(a=1234) *if($length(a)$.ne.4) *error('Test 7.9 failed') *endif *delete (a) *list(a) 1 2 3 4 5 6 7 8 9 *endlist *if(length(a).ne.9) *error('Test 7.10 failed') *endif *delete(a) *macro(a) a b c d *endmacro *if($length(a)$.ne.4) *error('Test 7.11 failed') *endif *delete(a) *delete(test_sub) *delete(t_1) *delete(t_2) *delete(t_3) *delete(s_1) *delete(s_2) *delete(s_3) *delete(s_4) *page test of detabbing functions and coresponding options Line handled with no detabbing, Tabbed between words *option(L_DETAB=.true.) Line handled with detabbing, Tabbed between words *option(L_DETAB=.false.) Line handled with no detabbing, Tabbed between words *option(l_detab=.true.) *option(tab=-1) *option(tab=-9) *option(tab=-17) *option(tab=-25) *option(tab=-33) *option(tab=-41) *option(tab=-49) *option(tab=-57) *option(tab=-65) *option(tab=-73) *option(tab=-81) *option(tab=5) *option(tab=10) *option(tab=15) *option(tab=20) *option(tab=25) *option(tab=30) *option(tab=35) *option(tab=40) *option(tab=45) *option(tab=50) *option(tab=55) *option(tab=60) *option(tab=65) *option(tab=70) *option(tab=75) *option(tab=80) *option(tab=85) *option(tab=90) tabed line should line up as shown v v v v v v v v v v v v v v v v ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ FORTRAN tab convention test *option(l_fortran=.true.) *option(l_detab=.false.) First line with no detab 1 second line with no detab *option(l_detab=.true.) First line with detab 1 second line with detab test the tab reset option-tabed line show line up as shown *option(tab=0) *option(l_fortran=.false.) v v v v v v v v ^ ^ ^ ^ ^ ^ ^ ^ *page test of `file output directives open(append code as open and append use mostof same code) append close redirect *append(1,'nl:') *redirect(1) *close(0) *append(2,'test.src') *redirect(2) code appended to channel 2 *redirect(1) *close(2) *append(0,'test.src') *redirect(0) code appended to channel 0 *close(1) *end