Like this
subroutine test(input, flag)
integer, intent(in) :: input
logical, intent(out) :: flag
flag = input>=0
end subroutine
and
call test(3,myflag)
will set myflag to .true.
Note
- that subroutines return values through their argument lists;
- the use of the
intent
clause to tell the compiler what the subroutine can do with its arguments; - my example is very simple and you will probably want to adapt it to your needs.