- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a routine to get 4 command line argument:
module chk_argumnt
CONTAINS
subroutine chk(x,y)
implicit none
integer::ac
real*4::x,y!,v_a,v_b,e_a,e_b
character(4)::cx,cy,atn1,atn2
! ac=command_argument_count()
write(*,*)command_argument_count()
call get_command_argument(1,cx)
call get_command_argument(2,cy)
call get_command_argument(3,atn1)
call get_command_argument(4,atn2)
read(cy,*)y
read(cx,*)x
write(*,*)atn1,cx,atn2,cy
write(*,*)"from module",x,y
end subroutine chk
end module chk_argumnt
module chk_argumnt
CONTAINS
subroutine chk(x,y)
implicit none
integer::ac
real*4::x,y!,v_a,v_b,e_a,e_b
character(4)::cx,cy,atn1,atn2
! ac=command_argument_count()
write(*,*)command_argument_count()
call get_command_argument(1,cx)
call get_command_argument(2,cy)
call get_command_argument(3,atn1)
call get_command_argument(4,atn2)
read(cy,*)y
read(cx,*)x
write(*,*)atn1,cx,atn2,cy
write(*,*)"from module",x,y
end subroutine chk
end module chk_argumnt
now i want to use them in another routine to initialize variable/
parameters:
program main
use chk_argumnt
real*4::tx=x*10,ty=y*10
! real*4,parameter::tx=x*10,ty=y*10
call chk(x,y)
write(*,*) x
write(*,*) y
end program main
but i cannot do that. What my aim is to supply the main four
parameters from commandline. how can i do that?
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
sorry for doubleposting.....i dont know if i can delete thread.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - roddur
sorry for doubleposting.....i dont know if i can delete thread.
When you are logged in, you should have a Delete button below the thread.
PARAMETER means a compile time constant. The compiler ought to refuse to compile anything which attempts to store run-time data in a PARAMETER constant.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - tim18
When you are logged in, you should have a Delete button below the thread.
PARAMETER means a compile time constant. The compiler ought to refuse to compile anything which attempts to store run-time data in a PARAMETER constant.
Using the protected attribute will cause variables to be read-only from outside the module (or scoping unit I think), i.e. within the module they may be modified, but to any programs which access the module via use association these ariables will behave as if they are parameters (i.e. they cannot appear on the left hand side of an assignment statement etc.).
I have attached a copy of a module I use to do exactly this: get command line arguments and options, as well as a few other things.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page