Bonjour,
j'ai un problème avec une modification de code que j'ai à faire en Fortran pour mon labo et le Fortran est en quelque sorte ma bête noire...
Je dois récupérer des valeurs de variables dans un fichier texte, qui doit se compléter à chaque tour de boucle. Voici la source (modif en bleu) :
J'obtiens des erreurs à la compilation (normal... c'est la loi de Murphy !) :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69 subroutine bond (nb, ib, jb, icb, & rk, req, ntb, x, & f, omega, eb, ndrv, nbel, natsys) ! ----- routine to get bond energy and forces for the potential ! of cb*(b-b0)**2 implicit double precision (a-h,o-z) dimension ib(nb),jb(nb),icb(nb),rk(2),req(2),x(2), & f(2),omega(2),nbel(2) dimension xij(3) !*********** open(30, file = "bond.log", iostat = ios) !-- Si le fichier ne peut etre cree, Alors Signaler une erreur. if (IOS.ne.0) THEN WRITE(* , *) "Could not create bond.log" !-- Ecriture de l'en-tete write(30 ,* ) "BOND.LOG : enregistrement de i3, j3, ipc, req(ipc), rk(ipc) " write(30, *) "newline" !*********** eb = 0.0d+00 do 40 n = 1,nb i3 = ib(n) j3 = jb(n) ipc = icb(n) rij2 = 0.e0 do 10 m = 1,3 xij(m) = x(i3+m)-x(j3+m) rij2 = rij2+xij(m)**2 10 continue if(ntb /= 0) call percon(rij2,xij) rij = sqrt(rij2) db = rij-req(ipc) df = rk(ipc)*db ebh = df*db if (ebh > 100.0) then write(6,101) i3/3+1,j3/3+1,rij,req(ipc),rk(ipc),ebh 101 format('Bad bond:',2i5,4e12.5) end if eb = eb+ebh if(ndrv == 2) then dv1 = 2.0e0*df dv2 = 2.0e0*rk(ipc) call difbon(omega,dv1,dv2,xij,rij,i3,j3,nbel) end if df = 2.0e0*df/rij do 20 m = 1,3 xh = xij(m)*df f(i3+m) = f(i3+m)-xh f(j3+m) = f(j3+m)+xh 20 continue !********* write(30, *) n " ieme Passage de la boucle : " write(30,*) "i3 = " i3 & ", j3= " j3 & ", ipc= " ipc & ", req("ipc")= " req(ipc) & ", rk("ipc")= " rk(ipc) write(30,*) "newline" write(30,*) "***" write(30,*) "newline" !********* 40 continue return end subroutine bond
Je suis mauvais en Fortran que c'en est abhérant ! J'ai beau lire des docs sur Internet, j'y pompe rien. Corrigez-moi si je me trompe mais, un write s'écrit bien WRITE(unit, fmt) ?
/lib/cpp -P -I/usr/local/motion/amber/amber8/src/include bond.f > _bond.f
f90 -c -O2 -free -o bond.o _bond.f
if (IOS.ne.0) THEN WRITE(* , *) "Could not create bond.log"
^
"_bond.f", Line = 69, Column = 26: ERROR: Unknown statement. Expected
assignment statement but found "W" instead of "=" or "=>".
enregistrement de i3, j3, ipc, req(ipc), rk(ipc) "
^
"_bond.f", Line = 71, Column = 7: ERROR: Continuation of character context in
free source form requires an "&" as the first nonblank character of the next
line.
write(30, *) n " ieme Passage de la boucle : "
^
"_bond.f", Line = 73, Column = 22: ERROR: Unexpected syntax: "EOS" was expected
but found """.
write(30,*) "i3 = " i3
^
"_bond.f", Line = 74, Column = 27: ERROR: Unexpected syntax: "EOS" was expected
but found "I".
& ", j3= " j3
^
"_bond.f", Line = 75, Column = 15: ERROR: A continuation line can only follow a
line continued with the "&" symbol.
& ", ipc= " ipc
^
"_bond.f", Line = 76, Column = 15: ERROR: A continuation line can only follow a
line continued with the "&" symbol.
& ", req("ipc")= " req(ipc)
^
"_bond.f", Line = 77, Column = 15: ERROR: A continuation line can only follow a
line continued with the "&" symbol.
& ", rk("ipc")= " rk(ipc)
^
"_bond.f", Line = 78, Column = 15: ERROR: A continuation line can only follow a
line continued with the "&" symbol.
f90comp: 85 SOURCE LINES
f90comp: 8 ERRORS, 0 WARNINGS, 0 OTHER MESSAGES, 0 ANSI
*** Error code 1
make: Fatal error: Command failed for target `bond.o'
Merci pour votre aide. En plus, c'est assez urgent vu que je finis mon stage bientôt. Mon maître de stage fait du Fortran fréquemment (même s'il n'a rien codé depuis 4 mois) mais il ne voit pas l'erreur ?! Alors moi...
Meric d'avance
Partager