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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

use of enum() and format() in fortran

Status
Not open for further replies.

byter101

Programmer
Jul 6, 2009
10
US
hello,

how does an "enum" array work, as in below? I understand the exp() function.

enum(i)=enum(i)*exp(-0.8/24)

there's a simpler line elsewhere:
enum(i)=0
but i can't figure it out.

additionally, what is "format()" doing, what purpose does that darn 1007 serve, and what would this potentially affect in my code?:

1007 format(i4,1x,i4,1x,a3,1x,e12.6)

optionally, if there is anyone who knows C++, how would I translate these statements over? I will probably be able to figure it out when I know how they work, but there's usually good advice out there
thank you
 
1007 is numeric identifier for the format, the descriptors mean:
i - integer
x - space
a - alphanumeric
E - exponencial

For example this Fortran-code
format.f90
Code:
write (*, 1007) 1234, 5678, 'abc', 1.41
1007     format(i4,1x,i4,1x,a3,1x,ES12.5e3)
end
is equivalent with this C-code
format.c
Code:
int main() {
  printf("%4d %4d %3s %12.5E\n", 1234, 5678, "abc", 1.41);
}
because they produces the same output
Code:
$ g95 format.f90 -o formatf

$ gcc format.c -o formatc

$ formatf
1234 5678 abc 1.41000E+000

$ formatc
1234 5678 abc 1.41000E+000
 
The enum(i) is just the ith element of an array called enum.

Brooks
 
but i don't have an 'enum' array declared anywhere, and it shows up in blue in the IDE like its a data type or cast or something..
 
okay it is just an array; i missed it. Its just weird that it shows up a different color in the editor. oh well, thanks guys
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top