Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Fortran > use module to p...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 19 Topic 8158 of 8551
Post > Topic >>

use module to pass data between procedures

by Mike <SulfateIon@[EMAIL PROTECTED] > Apr 22, 2008 at 01:22 AM

Hi

  I'd like to use module to pass data between procedures.
In the following, subroutine FCN is an argument of subroutine CDGRD
which calculates gradient (IMSL).  I have comment those statements
related to IMSL.

module shared_data
implicit none
save
real,dimension(2) :: y
end module shared_data

module A
contains
!C
SUBROUTINE FCN (N, X, F)
use shared_data
INTEGER N
REAL X(N), F
!C
F = y(1)*X(1) +y(2)*x(1)- 3.*X(2)
!C
RETURN
END SUBROUTINE FCN
end	module A

!module B
!contains
!subroutine mm(XC,XSCALE,GC,N)
!use A
!INTEGER I, N, NOUT
!real :: EPSFCN
!REAL,dimension(N) :: GC, XC, XSCALE
!!C Set function noise.
!EPSFCN = 0.

!CALL CDGRD (FCN, N, XC, XSCALE, EPSFCN, GC)

!CALL UMACH (2, NOUT)
!WRITE (NOUT,99999) (GC(I),I=1,N)
!99999 FORMAT (' The gradient is', 2F8.2, /)

!END subroutine mm
!end module B

program main
!use B
use shared_data
!integer,parameter :: N=2
!C Initialization.
!REAL,dimension(N) :: XC=(/1.,2./), XSCALE=(/1.,1./);
!The gradient
!REAL,dimension(N) :: GC
real,dimension(2) :: y

y=(/-2.,-1./);
!do i=1,2
!	xc(1)=(i-1)*0.5;
!do j=1,2
!	xc(2)=(j-1)*1.;
!call mm(XC,XSCALE,GC,N)
!enddo;enddo
end

after compiled by CVF6.6c:
Error: The attributes of this name conflict with those made accessible
by a USE statement.   [Y]
y=(/-2.,-1./);
^
Error: The shapes of the array expressions do not conform.   [Y]

I know I have declared twice: one in main program and the other in
module (module shared_data).
How to pass y array to FCN? please note that FCN can have only three
arguments.

thank you in advance.

Mike
 




 19 Posts in Topic:
use module to pass data between procedures
Mike <SulfateIon@[EMAI  2008-04-22 01:22:42 
Re: use module to pass data between procedures
Arjen Markus <arjen.ma  2008-04-22 01:36:33 
Re: use module to pass data between procedures
"A. Belli" <  2008-04-22 10:42:02 
Re: use module to pass data between procedures
"Les" <l.nei  2008-04-22 10:03:32 
Re: use module to pass data between procedures
Mike <SulfateIon@[EMAI  2008-04-22 07:38:31 
Re: use module to pass data between procedures
nospam@[EMAIL PROTECTED]   2008-04-22 08:14:07 
Re: use module to pass data between procedures
"Les" <l.nei  2008-04-22 16:32:56 
Re: use module to pass data between procedures
Mike <SulfateIon@[EMAI  2008-04-23 01:30:23 
Re: use module to pass data between procedures
Dave Seaman <dseaman@[  2008-04-23 12:26:25 
Re: use module to pass data between procedures
nospam@[EMAIL PROTECTED]   2008-04-23 07:31:38 
Re: use module to pass data between procedures
Mike <SulfateIon@[EMAI  2008-04-23 21:24:49 
Re: use module to pass data between procedures
Mike <SulfateIon@[EMAI  2008-04-24 00:20:54 
Re: use module to pass data between procedures
Mike <SulfateIon@[EMAI  2008-04-24 00:38:34 
Re: use module to pass data between procedures
Dave Seaman <dseaman@[  2008-04-24 13:20:47 
Re: use module to pass data between procedures
Mike <SulfateIon@[EMAI  2008-04-24 19:32:55 
Re: use module to pass data between procedures
Dave Seaman <dseaman@[  2008-04-25 03:28:09 
Re: use module to pass data between procedures
Mike <SulfateIon@[EMAI  2008-04-25 23:42:48 
Re: use module to pass data between procedures
Dave Seaman <dseaman@[  2008-04-26 15:13:03 
Re: use module to pass data between procedures
Mike <SulfateIon@[EMAI  2008-04-26 00:36:46 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 22:41:41 CDT 2008.