Re: Avoiding nested IF conditionals,and STOP statement
- From: dpb <none@xxxxxxx>
- Date: Wed, 24 Sep 2008 14:37:24 -0500
s_siouris wrote:
....
There are a few points in my program where if the input is not....
suitable, then I want to terminate the program. For example, if I am
opening a number of files, at each one I want to exit the program if
the file hasn't opened correctly. Chapman's style is to put IF
conditionals one inside the other, avoiding the STOP statement. I find
these nested IF's a little bit too much if there are a lot of cases
where I want to terminate the program prematurely, so I would like
some advice on how to approach this, avoiding the nested IF's, and
also avoiding the STOP statements.
I personally don't think there's anything in a situation such as that more suitable than a single
If(failure)
write(*,*) 'Error msg'//missing_file(1:len_trim(missing_file))
stop ! nnn optional
End If
If there are many and a pattern is present, perhaps wrap in a subroutine that can be called would be an option.
I wouldn't see any purpose whatsoever at nesting If's however...
--
.
- References:
- Avoiding nested IF conditionals,and STOP statement
- From: s_siouris
- Avoiding nested IF conditionals,and STOP statement
- Prev by Date: Re: Scope of implicit none
- Next by Date: Re: Alternative to the STOP statement?
- Previous by thread: Avoiding nested IF conditionals,and STOP statement
- Next by thread: Re: Avoiding nested IF conditionals,and STOP statement
- Index(es):
Relevant Pages
|
|