Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

[FGSL] [Brent's method]?

Status
Not open for further replies.

ignacio82

Technical User
Feb 15, 2012
9
0
0
US
I'm trying to use FGSL to maximize a function.

My problem is that the function I'm trying to maximize is a combination of many other functions and I don't know how to set the paremeters of those and then pass everything into FGSL.
For example, in line 212 I declare the first function that is part of my objective function. The parameters of this function are p1:)).
Then I keep defining other functions and finally in line 366 I declare my objective function
Finally in line 405 I have a subrutine that uses FGSL to calculate the maximum of my objective function. I try to define the parameters in 435 and then i pass them to fgsl in 496.

Thanks for the help!
 
Well, Ignacio, as you did not receive any help as yet, I would like to give it a try, allthough I do not know anything about fgsl.

But the file you appended shows in a format that is extremely hard to read. It would be better if you would copy your code directly into this thread, enclose it with the tags code and /code, both tags in [] to show in a more legible format.

Maybe we can find out what is wrong.

Norbert


The optimist believes we live in the best of all possible worlds - the pessimist fears this might be true.
 
I made some progress. Now I'm getting this error when I try to compile.
<code>
ifort -L/share/apps/contrib/fgsl/intel12/lib64 -o dissertation.X agents.o dissertation.o -lfgsl_ifort -lgsl -lgslcblas
agents.o: In function `agents_mp_c_child_':
agents.f90:(.text+0x2f8b): undefined reference to `m_'
make: *** [dissertation.X] Error 1
</code>

This is my updated code
<code>
module agents
use fgsl
use, intrinsic :: iso_c_binding
implicit none

type child_s6
!Choices
real(fgsl_double) :: a_prime_child
!States
real(fgsl_double) :: I, a_parent, &
a_child, b1, b2, b3,&
b4, epsilon_w, &
epsilon_h, epsilon_s, &
a_parent_t_plus_one, &
delta_c, &
Psi, Wage, m, rb, &
rl, mu, lambda1, &
lambda2
integer(fgsl_int) :: h_t_minus_1, big_H, &
big_S, s, h, s_earn, &
age, tipo, &
big_S_prime, &
big_H_prime, e
!Indicators
integer(fgsl_int) :: age_lt_17, age_lt_18, &
age_ge_20, &
age_lt_21, age_ge_22, &
age_lt_25, age_ge_28, &
h0, h20,h40, &
h20_t_minus_1, &
h40_t_minus_1, s_gt_0,&
h0_t_minus_1, e_high,&
type2, type3, type4, &
s_t_plus_one_ge_122, &
a_child_gt_0
!Outcomes
real(fgsl_double) :: W, utility_c, Emaxc, &
c_child

contains
procedure :: calc_W

end type child_s6

contains

integer function e_high(e)
integer :: e
if (e==1) then
e_high = 1
else
e_high=0
endif
end function e_high

integer function h0(h)
integer :: h
if (h==0) then
h0 = 1
else
h0=0
endif
end function h0

integer function h20(h)
integer :: h
if (h==20) then
h20 = 1
else
h20=0
endif
end function h20

integer function h40(h)
integer :: h
if (h==40) then
h40 = 1
else
h40=0
endif
end function h40

integer function age_lt_18(age)
integer :: age
if (age.lt.18) then
age_lt_18 = 1
else
age_lt_18 =0
endif
end function age_lt_18

integer function age_ge_20(age)
integer :: age
if (age.ge.20) then
age_ge_20 = 1
else
age_ge_20 =0
endif
end function age_ge_20

integer function age_lt_21(age)
integer :: age
if (age.lt.21) then
age_lt_21 = 1
else
age_lt_21 = 0
endif
end function age_lt_21

integer function age_ge_22(age)
integer :: age
if (age.ge.22) then
age_ge_22 = 1
else
age_ge_22 = 0
endif
end function age_ge_22

integer function age_lt_25(age)
integer :: age
if (age.lt.25) then
age_lt_25 = 1
else
age_lt_25 = 0
endif
end function age_lt_25

integer function age_ge_28(age)
integer :: age
if (age.lt.28) then
age_ge_28 = 1
else
age_ge_28 = 0
endif
end function age_ge_28

integer function s_gt_0(s)
integer :: s
if (s.gt.0) then
s_gt_0 = 1
else
s_gt_0 =0
endif
end function s_gt_0

integer function s_t_plus_one_ge_122(big_S_prime)
integer :: big_S_prime
if (big_S_prime.ge.122) then
s_t_plus_one_ge_122 = 1
else
s_t_plus_one_ge_122 =0
endif
end function s_t_plus_one_ge_122

integer function type2(tipo)
integer :: tipo
if (tipo==2) then
type2 = 1
else
type2 = 0
endif
end function type2

integer function type3(tipo)
integer :: tipo
if (tipo==3) then
type3 = 1
else
type3 = 0
endif
end function type3

integer function type4(tipo)
integer :: tipo
if (tipo==4) then
type4 = 1
else
type4 = 0
endif
end function type4

integer function a_child_gt_0(a_child)
real(c_double), value :: a_child
if (a_child.gt.0) then
a_child_gt_0 = 1
else
a_child_gt_0 = 0
endif
end function a_child_gt_0

integer function a_child_lt_0(a_child)
real(c_double) :: a_child
if (a_child.lt.0) then
a_child_lt_0 = 1
else
a_child_lt_0 = 0
endif
end function a_child_lt_0

!Human Capital function
REAL FUNCTION Psi (age,tipo,big_S,big_H,h_t_minus_1,alpha01, alpha02, &
alpha03, alpha04, alpha1, alpha2, alpha3, alpha4, alpha5,&
alpha6, alpha7)
integer(fgsl_int), value :: age,tipo,big_S,big_H, &
h_t_minus_1
real(c_double) :: alpha01, alpha02, &
alpha03, alpha04, &
alpha1, alpha2, &
alpha3, alpha4, &
alpha5, alpha6, alpha7
Psi = exp(alpha01+alpha02*type2(tipo)+alpha03*type3(tipo)+&
alpha04*type4(tipo)+alpha1*(big_S)+alpha2*(big_H)+&
alpha3*(big_H)**2+alpha4*h20(h_t_minus_1)+&
alpha5*h40(h_t_minus_1)+alpha6*(age)&
+alpha7*age_lt_18(age))
END FUNCTION Psi

!Hourly Wage Functions
REAL FUNCTION Wage (h, big_H, big_S, h_t_minus_1, epsilon_w, age, tipo, &
alpha01, alpha02, alpha03, alpha04, alpha1, alpha2, &
alpha3, alpha4, alpha5, alpha6, alpha7, alpha8, alpha9, &
alpha10, alpha11)
integer(fgsl_int), value :: h, big_H, big_S, &
h_t_minus_1, age, tipo
real(c_double) :: alpha01, alpha02, &
alpha03, alpha04, &
alpha1, alpha2, &
alpha3, alpha4, &
alpha5, alpha6, &
alpha7, epsilon_w, &
alpha8, alpha9, &
alpha10, alpha11

if (h==40) then
Wage = Psi (age,tipo,big_S,big_H,h_t_minus_1,alpha01, alpha02, &
alpha03, alpha04, alpha1, alpha2, alpha3, alpha4, alpha5,&
alpha6, alpha7)*exp(epsilon_w)
else
Wage = Psi (age,tipo,big_S,big_H,h_t_minus_1,alpha01, alpha02, &
alpha03, alpha04, alpha1, alpha2, alpha3, alpha4, alpha5,&
alpha6, alpha7)*exp(epsilon_w)*&
exp(alpha8+alpha9*big_S+alpha10*big_H+alpha11*age)
endif
END FUNCTION Wage


!Children's terminal Emax Functions
REAL FUNCTION Emaxc (a_parent_t_plus_one, I, a_prime_child,s, big_S_prime, &
big_H_prime, h, age,tipo,alpha01, alpha02, &
alpha03, alpha04, alpha1, alpha2, alpha3, alpha4, &
alpha5,alpha6, alpha7, beta1, beta2, beta3, beta4, &
beta5, beta6, beta7, beta8, beta9, beta10, beta11, &
beta12, beta13, beta14, beta15, beta16, beta17, beta18,&
beta19)
integer(fgsl_int), value :: big_S_prime, &
big_H_prime, h, age, &
tipo, s
real(c_double) :: alpha01, alpha02, &
alpha03, alpha04, &
alpha1, alpha2, &
alpha3, alpha4, &
alpha5, alpha6, &
alpha7, epsilon_w, &
a_parent_t_plus_one, &
I, a_prime_child, &
beta1, beta2, beta3, &
beta4, beta5, beta6, &
beta7, beta8, beta9, &
beta10, beta11, &
beta12, beta13, &
beta14, beta15, &
beta16, beta17, &
beta18, beta19

Emaxc = beta1*Psi(age,tipo,big_S_prime,big_H_prime,h,alpha01, alpha02, &
alpha03, alpha04, alpha1, alpha2, alpha3, alpha4, alpha5,&
alpha6, alpha7) + &
beta2*Psi(age,tipo,big_S_prime,big_H_prime,h,alpha01, alpha02, &
alpha03, alpha04, alpha1, alpha2, alpha3, alpha4, alpha5,&
alpha6, alpha7)*&
Psi(age,tipo,big_S_prime,big_H_prime,h,alpha01, alpha02, &
alpha03, alpha04, alpha1, alpha2, alpha3, alpha4, alpha5,&
alpha6, alpha7) + &
beta3*a_prime_child + beta4*a_prime_child*a_prime_child+ &
beta5* s_gt_0(s) + &
beta6*h20(h) + &
beta7*h40(h)+&
beta8*Psi(age,tipo,big_S_prime,big_H_prime,h,alpha01, alpha02, &
alpha03, alpha04, alpha1, alpha2, alpha3, alpha4, alpha5,&
alpha6, alpha7)*a_prime_child+&
beta9*s_t_plus_one_ge_122(big_S_prime)+&
beta10*Psi(age,tipo,big_S_prime,big_H_prime,h,alpha01, alpha02, &
alpha03, alpha04, alpha1, alpha2, alpha3, alpha4, alpha5,&
alpha6, alpha7)*type2(tipo) +&
beta11*Psi(age,tipo,big_S_prime,big_H_prime,h,alpha01, alpha02, &
alpha03, alpha04, alpha1, alpha2, alpha3, alpha4, alpha5,&
alpha6, alpha7)*type3(tipo)+&
beta12*Psi(age,tipo,big_S_prime,big_H_prime,h,alpha01, alpha02, &
alpha03, alpha04, alpha1, alpha2, alpha3, alpha4, alpha5,&
alpha6, alpha7)*type4(tipo)+&
beta13*a_prime_child*type2(tipo)+&
beta14*a_prime_child*type3(tipo)+&
beta15*a_prime_child*type4(tipo)+&
beta16*a_parent_t_plus_one+&
beta17*a_parent_t_plus_one*a_parent_t_plus_one+&
beta18*I+beta19*I*I

END FUNCTION Emaxc


!Transfer function
REAL FUNCTION m (b1, b2, b3, b4, s, s_earn, h)
integer(fgsl_int), value :: s, s_earn, h
real(c_double) :: b1, b2, b3, b4
m = b1+b2*s+b3*s_earn+b4*h
if (m.lt.0) then
m=0.0
endif
END FUNCTION m

!Cost of college function VER
REAL FUNCTION p (s)
integer(fgsl_int), value :: s
p = 1000.0*s
END FUNCTION p


!Budget constraint
REAL FUNCTION c_child (b1, b2, b3, b4, s, s_earn, h, big_H, h_t_minus_1, &
epsilon_w, rl, a_child,rb,a_prime_child, big_S, age,tipo,&
alpha01, alpha02, alpha03, alpha04, alpha1, alpha2, &
alpha3, alpha4, alpha5, alpha6, alpha7, alpha8, alpha9, &
alpha10, alpha11)
integer(fgsl_int), value :: s, s_earn, h, big_H,&
h_t_minus_1, big_S, &
age, tipo
real(c_double) :: m, b1, b2, b3, b4, &
epsilon_w, rl, &
a_child,rb, &
a_prime_child, &
epsilon_h, alpha01, &
alpha02, alpha03, &
alpha04, alpha1, &
alpha2, alpha3, &
alpha4, alpha5, &
alpha6, alpha7, &
alpha8, alpha9, &
alpha10, alpha11

c_child= Wage (h, big_H, big_S, h_t_minus_1, epsilon_w, age,&
tipo, alpha01, alpha02, alpha03, alpha04, alpha1, alpha2, &
alpha3, alpha4, alpha5, alpha6, alpha7, alpha8, alpha9, &
alpha10, alpha11)*h+ &
m (b1, b2, b3, b4, s, s_earn, h) + &
(1.0+rl)*a_child_gt_0(a_child)*&
a_child+(1.0+rb)*a_child*a_child_lt_0(a_child)-&
a_prime_child-p(s)
END FUNCTION c_child

!Child's mu
REAL FUNCTION mu (age,mu1, mu2, mu3, mu4)
integer(fgsl_int), value :: age
real(c_double) :: mu1, mu2, mu3, mu4

mu = exp(mu1*age_lt_18(age)+mu2*age_lt_21(age)+mu3*age_lt_25(age)+&
mu4*age_ge_28(age))

END FUNCTION mu

!Child's lambda1
REAL FUNCTION lambda1 (tipo,lambda_gle10, lambda_gle102, lambda_gle103, &
lambda_gle104, epsilon_h)
integer(fgsl_int), value :: tipo
real(c_double) :: lambda_gle10, &
lambda_gle102, &
lambda_gle103, &
lambda_gle104, &
epsilon_h
lambda1 = lambda_gle10 + lambda_gle102*type2(tipo)+&
lambda_gle103*type3(tipo)+lambda_gle104*type4(tipo)+ epsilon_h
END FUNCTION lambda1

!Child's lambda2
REAL FUNCTION lambda2 (tipo,lambda_gle20, lambda_gle202, lambda_gle203, &
lambda_gle204, epsilon_s)
integer(fgsl_int), value :: tipo
real(c_double) :: lambda_gle20, &
lambda_gle202, &
lambda_gle203, &
lambda_gle204, &
epsilon_s
lambda2 = lambda_gle20 + lambda_gle202*type2(tipo)+&
lambda_gle203*type3(tipo)+lambda_gle204*type4(tipo)+ epsilon_s
END FUNCTION lambda2

!Child's utility
FUNCTION utility_c (age,mu1, mu2, mu3, mu4, b1, b2, b3, b4, s, s_earn, &
h, big_H, h_t_minus_1, epsilon_w, rl, a_child,rb, &
a_prime_child, big_S, tipo, alpha01, alpha02, &
alpha03, alpha04, alpha1, alpha2, alpha3, alpha4, &
alpha5, alpha6, alpha7, alpha8, alpha9, alpha10, &
alpha11,lambda_gle10, lambda_gle102, lambda_gle103,&
lambda_gle104, epsilon_h,lambda_gle20, &
lambda_gle202, lambda_gle203, lambda_gle204, &
epsilon_s, e )
integer(fgsl_int), value :: age, s, s_earn, h, &
big_H, h_t_minus_1, &
big_S, tipo, e
real(fgsl_double) :: b1, b2, b3, b4, &
epsilon_w, rl, &
a_child, rb, &
a_prime_child, &
alpha01, &
alpha02, alpha03, &
alpha04, alpha1, &
alpha2, alpha3, &
alpha4, alpha5, &
alpha6, alpha7, &
alpha8, alpha9, &
alpha10, alpha11,&
lambda_gle10, &
lambda_gle102, &
lambda_gle103,&
lambda_gle104, &
epsilon_h, &
lambda_gle20, &
lambda_gle202, &
lambda_gle203, &
lambda_gle204, &
epsilon_s, lambda0, &
kappah, lambda3, &
lambda4, lambda5, &
lambda6, lambda7, &
lambda8, lambda9,&
mu1, mu2, mu3, mu4,&
utility_c


utility_c = mu(age,mu1, mu2, mu3, mu4)*(1.0/lambda0)*&
(c_child (b1, b2, b3, b4, s, s_earn, h, big_H, h_t_minus_1, &
epsilon_w, rl, a_child,rb, a_prime_child, big_S, &
age,tipo, alpha01, alpha02, alpha03, alpha04, &
alpha1, alpha2, alpha3, alpha4, alpha5, alpha6, &
alpha7, alpha8, alpha9, alpha10, alpha11))**lambda0&
+lambda1 (tipo,lambda_gle10, lambda_gle102, lambda_gle103, &
lambda_gle104, epsilon_h)*(h20(h)+kappah*h40(h))+ &
lambda2 (tipo,lambda_gle20, lambda_gle202, lambda_gle203, &
lambda_gle204, epsilon_s)*s+&
lambda3*h20(h)*s+ &
lambda4*h40(h)*s+ &
lambda5*age_ge_20(age)*s_gt_0(s)+&
lambda6*h20(h)*h20(h_t_minus_1)+&
lambda7*h40(h)*h40(h_t_minus_1)*kappah+&
lambda8*h0(h)*h0(h_t_minus_1)*age_ge_22(age)+&
lambda9*e_high(e)
END FUNCTION utility_c

!Objective function 6
FUNCTION objective_6 (a_prime_child, params6) bind(c)
real(c_double), value :: a_prime_child
type(c_ptr), value :: params6
real(c_double) :: objective_6, delta_c
real(fgsl_double), pointer :: p6:))

call c_f_pointer(params6, p6, (/69/))

objective_6 = (utility_c (p6(1),p6(2), p6(3), p6(4), p6(5), p6(6), &
p6(7), p6(8), p6(9), p6(10), p6(11), &
p6(12), p6(13),p6(14), p6(15), p6(16), &
p6(17),p6(18), a_prime_child, p6(19), &
p6(20), p6(21), p6(22), p6(23), p6(24),&
p6(25), p6(26), p6(27), p6(28), p6(29), &
p6(30), p6(31), p6(32), p6(33), p6(34), &
p6(35),p6(36), p6(37), p6(38), p6(39), &
p6(40),p6(41), p6(42), p6(43), p6(44), &
p6(45), p6(46) ) + &
delta_c * Emaxc (p6(47), p6(48), a_prime_child, &
p6(10), p6(49), p6(50), p6(12), &
p6(1),p6(20),p6(21), p6(22),p6(23),&
p6(24), p6(25), p6(26), p6(27), &
p6(28), p6(29),p6(30), p6(31), &
p6(51), p6(52), p6(53), p6(54), &
p6(55), p6(56), p6(57), p6(58), &
p6(59), p6(60), p6(61), p6(62), &
p6(63), p6(64), p6(65), p6(66), &
p6(67), p6(68), p6(69)))&
*(-1)
END FUNCTION objective_6

subroutine calc_W (this, mu1, mu2, mu3, mu4, alpha01, alpha02, alpha03, &
alpha04, alpha1, alpha2, alpha3, alpha4, alpha5, alpha6, &
alpha7, alpha8, alpha9, alpha10, alpha11, lambda_gle10, &
lambda_gle102, lambda_gle103, lambda_gle104, &
lambda_gle20, lambda_gle202, lambda_gle203, &
lambda_gle204, beta1, beta2, beta3, beta4, beta5, beta6,&
beta7, beta8, beta9, beta10, beta11, beta12, beta13, &
beta14, beta15, beta16, beta17, beta18, beta19, &
lower, higher, guess)
integer(fgsl_int), parameter :: itmax = 1e9
real(fgsl_double), parameter :: eps=1.0E-4_fgsl_double
real(fgsl_double), target :: fpar6(69)
integer(fgsl_int) :: status, i
real(fgsl_double) :: xmin, xlo, xhi
type(fgsl_min_fminimizer) :: min_fslv
type(fgsl_function) :: func
type(c_ptr) :: ptr6
class (child_s6), intent (inout) :: this
real(fgsl_double), intent(in) :: mu1, mu2, mu3, mu4, &
alpha01, alpha02, &
alpha03, alpha04, &
alpha1, alpha2, &
alpha3, alpha4, &
alpha5, alpha6, &
alpha7, alpha8, &
alpha9, alpha10, &
alpha11, lambda_gle10,&
lambda_gle102, &
lambda_gle103, &
lambda_gle104, &
lambda_gle20, &
lambda_gle202, &
lambda_gle203, &
lambda_gle204, &
beta1, beta2, beta3, &
beta4, beta5, beta6, &
beta7, beta8, beta9, &
beta10, beta11, &
beta12, beta13, &
beta14, beta15, &
beta16, beta17, &
beta18, beta19, &
lower, higher, guess

!set parameters
fpar6(1) = this%age
fpar6(2) = mu1
fpar6(3) = mu2
fpar6(4) = mu3
fpar6(5) = mu4
fpar6(6) = this%b1
fpar6(7) = this%b2
fpar6(8) = this%b3
fpar6(9) = this%b4
fpar6(10) = this%s
fpar6(11) = this%s_earn
fpar6(12) = this%h
fpar6(13) = this%big_H
fpar6(14) = this%h_t_minus_1
fpar6(15) = this%epsilon_w
fpar6(16) = this%rl
fpar6(17) = this%a_child
fpar6(18) = this%rb
fpar6(19) = this%big_S
fpar6(20) = this%tipo
fpar6(21) = alpha01
fpar6(22) = alpha02
fpar6(23) = alpha03
fpar6(24) = alpha04
fpar6(25) = alpha1
fpar6(26) = alpha2
fpar6(27) = alpha3
fpar6(28) = alpha4
fpar6(29) = alpha5
fpar6(30) = alpha6
fpar6(31) = alpha7
fpar6(32) = alpha8
fpar6(33) = alpha9
fpar6(34) = alpha10
fpar6(35) = alpha11
fpar6(36) = lambda_gle10
fpar6(37) = lambda_gle102
fpar6(38) = lambda_gle103
fpar6(39) = lambda_gle104
fpar6(40) = this%epsilon_h
fpar6(41) = lambda_gle20
fpar6(42) = lambda_gle202
fpar6(43) = lambda_gle203
fpar6(44) = lambda_gle204
fpar6(45) = this%epsilon_s
fpar6(46) = this%e

fpar6(47) = this%a_parent_t_plus_one
fpar6(48) = this%I
fpar6(49) = this%big_S_prime
fpar6(50) = this%big_H_prime
fpar6(51) = beta1
fpar6(52) = beta2
fpar6(53) = beta3
fpar6(54) = beta4
fpar6(55) = beta5
fpar6(56) = beta6
fpar6(57) = beta7
fpar6(58) = beta8
fpar6(59) = beta9
fpar6(60) = beta10
fpar6(61) = beta11
fpar6(62) = beta12
fpar6(63) = beta13
fpar6(64) = beta14
fpar6(65) = beta15
fpar6(66) = beta16
fpar6(67) = beta17
fpar6(68) = beta18
fpar6(69) = beta19

ptr6 = c_loc(fpar6)

!Choose the minimizer method, in this case brent
min_fslv = fgsl_min_fminimizer_alloc(fgsl_min_fminimizer_brent)
!Choose the function to minimize
func = fgsl_function_init(objective_6, ptr6)
if (fgsl_well_defined(min_fslv)) then
!set the brent's guess to "guess" the min to "lower" and the max to "higher"
status = fgsl_min_fminimizer_set(min_fslv, func, guess, &
lower, higher)
i = 0
do
i = i + 1
status = fgsl_min_fminimizer_iterate(min_fslv)
if (status /= FGSL_SUCCESS .or. i > itmax) then
write(6, *) 'Failed to iterate or converge. Aborting.'
exit
end if
xmin = fgsl_min_fminimizer_x_minimum(min_fslv)
xlo = fgsl_min_fminimizer_x_lower(min_fslv)
xhi = fgsl_min_fminimizer_x_upper(min_fslv)
status = fgsl_min_test_interval (xlo, xhi, eps, 0.0_fgsl_double)
if (status == FGSL_SUCCESS) exit
end do
end if
!Set the optimal values
this%a_prime_child = xmin
this%W = objective_6(this%a_prime_child, ptr6)
this%c_child = c_child (this%b1, this%b2, this%b3, this%b4, this%s, &
this%s_earn, this%h, this%big_H, &
this%h_t_minus_1, this%epsilon_w, this%rl, &
this%a_child, this%rb, this%a_prime_child, &
this%big_S, this%age, this%tipo, alpha01, &
alpha02, alpha03, alpha04, alpha1, alpha2, &
alpha3, alpha4, alpha5, alpha6, alpha7, alpha8, &
alpha9, alpha10, alpha11)
!NEED TO CALC U TOO
!free
call fgsl_min_fminimizer_free(min_fslv)
call fgsl_function_free(func)
end subroutine calc_W

end module agents
</code>
 
IMO, you didn't post the part where the error occurs.
Where is the function agents_mp_c_child_ ?
 
I am not familiar with this compiler / linker of yours and the errormessages it apparently issues. There might be a clue in what mikrom says.

But still there is the next line of the message saying

agents.f90:(.text+0x2f8b): undefined reference to `m_'

which apparently refers to your tranferfunction named 'm'

I receive similar messages when there is a problem with calls to and from C-programs, windows API in my case. Usually this is caused by an error in the compiler directive that on my compiler (Compaq) looks like

Code:
	Integer Function WinWndProc (hWnd, iMessage, wParam, lParam)	
		!DEC$ IF DEFINED(_X86_)
		!DEC$ ATTRIBUTES STDCALL, ALIAS : '_WinWndProc@16' :: WinWndProc
		!DEC$ ELSE
		!DEC$ ATTRIBUTES STDCALL, ALIAS : 'WinWndProc' :: WinWndProc
		!DEC$ ENDIF

The program unit that generates the call to Windows API which eventually leads to the call of the callback function must have an interface included like

Code:
	interface				
		integer function WinWndProc(hwnd, message, wPAram, lParam) 
			!DEC$ IF DEFINED(_X86_)
			!DEC$ ATTRIBUTES STDCALL, ALIAS : '_WinWndProc@16' :: WinWndProc
			!DEC$ ELSE
			!DEC$ ATTRIBUTES STDCALL, ALIAS : 'WinWndProc' :: WinWndProc
			!DEC$ ENDIF
		integer hwnd, message, wParam, lParam
		end function WinWndProc
	end interface

If I do not include these two features into my code I receive an errormessage from the linker that my routine is missing under the name of _WinWndProc@

Maybe FGSL needs the same or similar interfacing.
Maybe this helps.

Norbert


The optimist believes we live in the best of all possible worlds - the pessimist fears this might be true.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top