diff --git a/lib_f90/dkdo.f90 b/lib_f90/dkdo.f90 index 678d88d9..eaf49ada 100644 --- a/lib_f90/dkdo.f90 +++ b/lib_f90/dkdo.f90 @@ -58,7 +58,7 @@ SUBROUTINE do_loop (line, lend, length) lblock = .false. IF (ier_num.ne.0) THEN IF(lmakro .AND. lmacro_close) THEN - CALL macro_close + CALL macro_close(-1) ENDIF ENDIF do_macro = ' ' @@ -139,7 +139,7 @@ SUBROUTINE do_do_init(line, length) lblock_read = .FALSE. lblock = .FALSE. IF(lmakro .AND. lmacro_close) THEN - CALL macro_close + CALL macro_close(-1) ENDIF do_macro = ' ' ENDIF @@ -441,7 +441,7 @@ SUBROUTINE do_insert_line!(jlevel) WRITE (ier_msg (1), 3000) WRITE (ier_msg (2), 3100) line (1:41) IF(lmakro .AND. lmacro_close) THEN - CALL macro_close + CALL macro_close(-1) ENDIF ENDIF 3000 FORMAT ('Erroneous line in block structure') @@ -580,7 +580,7 @@ SUBROUTINE do_execute_block(lend) ! ier_num = -5 ! ier_typ = ER_FORT IF(lmakro .AND. lmacro_close) THEN - CALL macro_close + CALL macro_close(-1) ENDIF ENDIF ! diff --git a/lib_f90/envir_mod.f90 b/lib_f90/envir_mod.f90 index 5d6b59d5..d165a30a 100644 --- a/lib_f90/envir_mod.f90 +++ b/lib_f90/envir_mod.f90 @@ -29,6 +29,7 @@ MODULE envir_mod CHARACTER(LEN=PREC_STRING) :: win_dir CHARACTER(LEN=PREC_STRING) :: start_line CHARACTER(LEN=PREC_STRING) :: current_dir + CHARACTER(LEN=PREC_STRING) :: macro_s_dir CHARACTER(LEN=PREC_STRING) :: terminal_emu = ' ' CHARACTER(LEN=PREC_STRING) :: terminal_exe = ' ' CHARACTER(LEN=PREC_STRING) :: terminal_wrp = '/tmp/terminal_wrapper.sh' diff --git a/lib_f90/lib_trans.f90 b/lib_f90/lib_trans.f90 index 246b0a96..636ca10d 100644 --- a/lib_f90/lib_trans.f90 +++ b/lib_f90/lib_trans.f90 @@ -113,7 +113,7 @@ subroutine lib_trans_menu(idata, value, laver, outfile, old_inc, old_eck, old_vi RETURN ELSE IF(lmacro_close) THEN - CALL macro_close + CALL macro_close(-1) prompt_status = PROMPT_ON ENDIF ENDIF diff --git a/lib_f90/macro.f90 b/lib_f90/macro.f90 index 1f54d368..159b4926 100644 --- a/lib_f90/macro.f90 +++ b/lib_f90/macro.f90 @@ -48,6 +48,7 @@ SUBROUTINE file_kdo(line, ilen) is_stored = .false. ! assume macro does not exist in storage IF(macro_level==0 .AND. .NOT.lmakro) THEN sprompt = prompt ! Store prompt at top macro level start + macro_s_dir = current_dir ! Store starting directory ENDIF macro_level = macro_level + 1 CALL build_macro_name(line, ilen, filename, MAXW, ianz, cpara, lpara, werte) @@ -153,7 +154,7 @@ SUBROUTINE file_kdo(line, ilen) ier_num = - 12 ier_typ = ER_MAC oprompt = prompt - CALL macro_close + CALL macro_close(-1) IF(lblock) THEN ! If inside do/if terminate the block lblock_dbg = .false. lblock = .false. @@ -198,7 +199,7 @@ SUBROUTINE file_kdo(line, ilen) ier_num = - 12 ier_typ = ER_MAC oprompt = prompt - CALL macro_close + CALL macro_close(-1) IF(lblock) THEN ! If inside do/if terminate the block lblock_dbg = .false. lblock = .false. @@ -317,9 +318,12 @@ SUBROUTINE build_macro_name(line, ilen, filename, MAXW, & ! --Get filename from command line and string for parameters ! string = line -ip = INDEX (string, ' ') -string (ip:ip) = ',' +if(string(1:1)/='"') then + ip = INDEX (string, ' ') + string (ip:ip) = ',' +endif length = -IABS(ilen) +! CALL get_params (string, ianz, cpara, lpara, maxw, length) ! ! --Try to build filename @@ -523,7 +527,7 @@ SUBROUTINE macro_read (line, laenge) lmakro = .false. lmakro_disp = .FALSE. ! Macro display error off macro_level = 0 - CALL macro_close + CALL macro_close( 0) ELSE mac_tree_active => mac_tree_active%parent ! DEALLOCATE(mac_tree_active%kid) @@ -553,7 +557,7 @@ SUBROUTINE macro_read (line, laenge) lmakro = .false. lmakro_disp = .FALSE. ! Macro display error off macro_level = 0 - CALL macro_close + CALL macro_close( 0) ELSE mac_tree_active => mac_tree_active%parent ! DEALLOCATE(mac_tree_active%kid) @@ -741,7 +745,7 @@ SUBROUTINE macro_terminate lmakro = .false. lmakro_disp = .FALSE. ! Macro display error off macro_level = 0 - CALL macro_close + CALL macro_close( 0) ELSE mac_tree_active => mac_tree_active%parent macro_level = macro_level - 1 @@ -753,26 +757,41 @@ END SUBROUTINE macro_terminate ! !*****7**************************************************************** ! -SUBROUTINE macro_close +SUBROUTINE macro_close(ierror) !- ! Closes the macro file, switches macro status off and sets the ! macro level back to zero. ! The macro tree is deallocated. -! In an interactive session (promot /= redirect ) the stored +! In an interactive session (prompt /= redirect ) the stored ! macros are deallocated. This allows the user to modify a macro ! and run the modified version !+ USE class_macro_internal +use envir_mod USE macro_mod USE mpi_slave_mod USE errlist_mod USE prompt_mod +use support_mod +! IMPLICIT none ! +integer, intent(in) :: ierror ! Macro closure du to error +! +character(len=PREC_STRING) :: line +integer :: length +! IF(mpi_is_slave) THEN RETURN ENDIF ! +if(ierror<0) then + write(output_io,*) ' ' + line = macro_s_dir + length = len_trim(line) + call do_chdir(line, length, .true.) +endif +! IF(prompt_status/=PROMPT_OFF) THEN WRITE(output_io,*) ' ' ENDIF @@ -929,14 +948,14 @@ SUBROUTINE macro_continue (zeile, lcomm) IF(str_comp(cpara(1), pname, 3, lpara(1), len_str(pname))) THEN cprompt = prompt ! Remember current prompt, as macro close ! goes all the way back.... - CALL macro_close + CALL macro_close( 0) lmakro_dbg = .false. prompt = cprompt ! Set current prompt as active prompt lblock_dbg = .false. lblock = .false. ELSEIF(str_comp(cpara(1), 'suite', 3, lpara (1), 5)) THEN lmakro_dbg = .false. - CALL macro_close + CALL macro_close( 0) lblock_dbg = .false. lblock = .false. IF(pname /= 'suite') THEN @@ -947,13 +966,13 @@ SUBROUTINE macro_continue (zeile, lcomm) ier_num = - 6 ier_typ = ER_COMM lmakro_dbg = .false. - CALL macro_close + CALL macro_close(-1) ENDIF ELSE ier_num = - 6 ier_typ = ER_COMM lmakro_dbg = .false. - CALL macro_close + CALL macro_close(-1) ENDIF ! END SUBROUTINE macro_continue