CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Main CFD Forum

How to compile this kind of code

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   September 21, 2006, 15:44
Default How to compile this kind of code
  #1
Harry
Guest
 
Posts: n/a
Hi, Guys

How to compile the following fortran code by f77

Program 'test'

# include "head1.h"

# include "head2.h"

a=1

b=2

c=3

call test(b,

& include "head2.h"

end

*********************************

subroutine test(1,

& include "head2.h" # include "head1.h"

print*,a,b,c

return

end

***************************

head1.h includes the following line

# define _tes a

****************************

head2.h includes the following line

# real*8 c

  Reply With Quote

Old   September 21, 2006, 16:08
Default Re: How to compile this kind of code
  #2
Harry
Guest
 
Posts: n/a
a interesting thing. a old style of programming. it seems the code is written by mixing languages c and fortran. the main part is coded by f77 except the definition of variables by C language. Since the code never call any C-language subroutine, I really get lost. How to complie this type of codes? any hint would be appreciated.
  Reply With Quote

Old   September 21, 2006, 17:38
Default Re: How to compile this kind of code
  #3
andy
Guest
 
Posts: n/a
Change the name of the file from program.f to program.F and it will compile on almost all a unix-like systems.

The statements beginning with #include are for the cpp program which is the C pre-processor. Capitalising the extension is the naming convention for first running a program through cpp on unix-like systems.

FORTRAN, unlike C, is a portable language and does not understand directories which are different on different systems. Hence FORTRANs include can only look in the same directory as the main file. This is not how include files are usually used for larger programs hence the switch to using cpp for many using unix-like systems.
  Reply With Quote

Old   September 21, 2006, 22:30
Default Re: How to compile this kind of code
  #4
Harry
Guest
 
Posts: n/a
Done!thank you very much.
  Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
PV3FoamReader compile error.... PEM_GUY OpenFOAM Installation 6 April 5, 2010 17:22
What is the Better Way to Do CFD? John C. Chien Main CFD Forum 54 April 23, 2001 08:10
user friendly cfd code waqar Main CFD Forum 19 August 18, 2000 16:31
own Code vs. commercial code Bernhard Mueck Main CFD Forum 10 February 16, 2000 11:07
State of the art in CFD technology Juan Carlos GARCIA SALAS Main CFD Forum 39 November 1, 1999 15:34


All times are GMT -4. The time now is 22:53.