|
From: Robert D. <rob...@gm...> - 2025-10-21 17:45:19
|
Ivan, sorry to hear you're having trouble with Gentran. It is probably
some relatively simple bug, but I don't know enough about Gentran to
fix it.
I've had some luck using f90 (Fortran 90) to generate C code. First
I'll replace "^" (exponent) expressions with "pow" -- one could of
course substitute any function.
var:-((sqrt(m_piM^4+W^8*cost^2-W^8+4*P0^2*W^6)+((cost^2-1)*m_nuc^2+W^2*cost^2-W^2)*m_piM^4+sqrt(m_piM^2+P0^2)*(4*W^2*m_nuc*m_piM^2-4*W^2*m_nuc^3+4*W^4*m_nuc)+((2-2*cost^2)*m_nuc^4-4*W^2*cost^2*m_nuc^2-2*W^4*cost^2-2*W^4)*m_piM^2+(cost^2-1)*m_nuc^6+(W^2-W^2*cost^2)*m_nuc^4+(W^4-W^4*cost^2)*m_nuc^2+W^6*cost^2-W^6)/((cost^2-1)*m_piM^4+((2-2*cost^2)*m_nuc^2-2*W^2*cost^2-2*W^2)*m_piM^2+(cost^2-1)*m_nuc^4+(2*W^2-2*W^2*cost^2)*m_nuc^2+W^4*cost^2-W^4));
var1: subst ("^" = pow, var);
load (f90);
f90_output_line_length_max: 100000;
f90 (var1);
Here's what I get:
-((pow(pow(m_piM,4)+pow(W,8)*pow(cost,2)-pow(W,8)+4*pow(P0,2)*pow(W,6),1.0d0/2.0d0)+(4*pow(W,2)*m_nuc*pow(m_piM,2)-4*pow(W,2)*pow(m_nuc,3)+4*pow(W,4)*m_nuc)*pow(pow(m_piM,2)+pow(P0,2),1.0d0/2.0d0)+((pow(cost,2)-1)*pow(m_nuc,2)+pow(W,2)*pow(cost,2)-pow(W,2))*pow(m_piM,4)+((2-2*pow(cost,2))*pow(m_nuc,4)-4*pow(W,2)*pow(cost,2)*pow(m_nuc,2)-2*pow(W,4)*pow(cost,2)-2*pow(W,4))*pow(m_piM,2)+(pow(cost,2)-1)*pow(m_nuc,6)+(pow(W,2)-pow(W,2)*pow(cost,2))*pow(m_nuc,4)+(pow(W,4)-pow(W,4)*pow(cost,2))*pow(m_nuc,2)+pow(W,6)*pow(cost,2)-pow(W,6))*pow((pow(cost,2)-1)*pow(m_piM,4)+((2-2*pow(cost,2))*pow(m_nuc,2)-2*pow(W,2)*pow(cost,2)-2*pow(W,2))*pow(m_piM,2)+(pow(cost,2)-1)*pow(m_nuc,4)+(2*pow(W,2)-2*pow(W,2)*pow(cost,2))*pow(m_nuc,2)+pow(W,4)*pow(cost,2)-pow(W,4),-1))
Note that this is all on one line -- f90 introduces continuation
characters (ampersand) when the expression is longer than
f90_output_line_length_max.
There are other possibilities -- maybe you can say more about what you
are trying to do.
Robert
|