Ӧ
COMPUTER APPLICATIONS
1999 19 6 Vol.19 No.6 1999



ϱFortranӻ
־ֽ
ժҪ̽VC++,Fortran,OpenGL лϱ̵ķ÷ַԸԵŵ㣬Ƴḻʣ˻ԻĽ棬޶еFortranԱдĳԴʵּĿӻеFortranԱдԴ˳ԣá
ؼʡVC++,Fortran,OpenGLϱ̣ӻ
PROGRAMMING ON MECHANICS CALCULATION
WITH MIXED LANGUAGES
Zhang ZhihuaWang LinjiangL Qingfeng
Nanjing University of Aeronautics and Astronautics, Jiangsu.Nanjing 210016
AbstractUsing VC++ to design colorful friendly interface,using Fortran to calculate,using OpenGL to draw, this paper dwells on programming with mixed languages to the full advantage of every one.It is valuable for many procedures compiled in Fortran before to be Visualized for better use. The attempt with existed software compiled by authors results in success.
KeywordsVC++, Fortran, OpenGLProgramming with mixed languages, Visualization
1
еĻеƣѧ㣬̷඼FortranԱдġ΢˾ƳPowerStationƳµFortran90ԣԼVC++4.0һĹƽ̨DeveloperstudioͨϱFortranܺVC++Сֻϱ̵ĸձ壬ṩһͨöҼ㷽еFortranʹӵһȫµWindows棬ûʹá
2ϱ̵˼·
FortranǰһʽģͨĻԭʼļݣ㣬󣬰ѼļСһԭʼݵ׼ʮַ׳ĶҲʮַġڿԷӦVC++ĶԻòĵд̲ӴʾOpenGL ⺯ͼͼ档ڼͱмFortranɡ
2.1VC++Fortranϱ̵Ĺ
ͬ΢壬ʹͬһƽ̨֮ĹͨǷǳġһĵCPPļǰ
extern "C" {
void stdcall ( *); }
ȻҪ㴦Ϻ(&+͵ı͵)ҪָǣֻϱҪʽݵģ⴫ǰΪ俪רڴ棬ݴ̺ʱͬʱԭFortranи죬SubroutineFunctionVC++еĴݺĴݱͬԪ͵תһfloatreal*4double real*8,int integerĹؼǣͨInsert˵е Files into ProjectFortranǶVC++ĿУͨBuild˵еsettingsLink ѡмLibfmt.lib,defaultlibryעLibfcmt.libC\C++ѡмMultithreaded, FortranѡмMultithreaded Full optimization
2.2ĵ
ĵͨCtypedPtrArrayģCobArray󱣴ս4ݣ5ݴͳFortranԳԱװԲⱣļҲЩĸ,Serialize׽⣬ôCobArray м̳Add(),GetAt(),GetSize()ܷʵݵӺͲҡ
2.3Ӵ
ӴͨݽдȻȷӳ䷽ʽͨ߼豸תȷԭ㣬ûʣߡ
2.4OpenGLԽкô
OpenGLSGI,SUN,HP,DEC,Microsoft˾Ƴάͼο׼ʮַʵãOpenGLѳΪάͼεͨñ׼OpenGL ڹƽ̨DevelopstadioϵԣҲǶVC++еӴӳ䣬ЧάOpenGLƣô˼ֽԴӸǶȹ۲ģͣͨɫʵı仯ӳӦķֲҪָҪͨBuild˵еsettingsLink ѡмopengl32.lib glu32.lib glaux.lib.
OpenGLǶӴУؼǱдbSetupPixelFormat뽫һظʽṹ͵ǰ豸Ĺ
BOOL CCubeView::bSetupPixelFormat()
{ 
static PIXELFORMATDESCRIPTOR pfd =
{ sizeof(PIXELFORMATDESCRIPTOR), // size of this pfd
1, // version number
PFDDRAWTOWINDOW | // support window
PFDSUPPORTOPENGL | // support OpenGL
PFDDOUBLEBUFFER, // double buffered
PFDTYPERGBA, // RGBA type
24, // 24-bit color depth
0, 0, 0, 0, 0, 0, // color bits ignored
0, // no alpha buffer
0, // shift bit ignored
0, // no accumulation buffer
0, 0, 0, 0, // accum bits ignored
32, // 32-bit z-buffer
0, // no stencil buffer
0, // no auxiliary buffer
PFDMAINPLANE, // main layer
0, // reserved
0, 0, 0 // layer masks ignored
}; }
3PowerStation ¹
PowerStationѱ㷺ӦãȱٱҪʹָϣ๦ûбãԻϱ̽еĹؼܡ
3.1ǿDebugԹ
Developerstudioƽ̨УԳ쳣㣬ѡInfoviewerеFPS4.0 books online,Project Wokspace ڵInfoview߰Ťôʾеרۣ˫Builder Errorר⣬ʾCompile error,Linker Tools error,Runtime error,Math errorȷר⣬ϸ˸ִԭͨȷѡBuild˵Debugѡrun to cursorִеܷݴݴ󴦣DebugԴڣڴ״̬£ĵǰֵĻʾѡ񵥲ִͨ۲ı仯жǷȷݡֹܶڻϱҪΪݴݶڻϱžá
3.2PowerStationṩѧ⣬Դ
PowerStationṩ1000̬ӿ⣬˹ѧĸ棬һ漰ѧ㣬ȫдйصԴ룬ҲÿйصԴ룬ΪԶ̬ӿʽڣֻд CALL+Ҫ⺯ɣεõҪ⺯ѡInfoviewerеFPS4.0 books online,Project Wokspace ڵInfoview߰Ťôʾеרۣ˫IMSL libraries Referenceר,ʾ⣬IMSL Math Library(ͨѧ΢ֻ־)IMSL stat Library(ͳƿ)IMSL Math Library Special Function (⺯)ɲѰ⺯˫⺯ֿ⺯ϸʹ˵һڳͷUSE MSIMSL,ѧ⡣
3.3Fortran 90ԵԽ
80Fortran൱ռ๦ܸǿCC++AdaԽԽǲáһANSIίԱŬƳFortran 77׼ĸ°棬1990꣬±׼ļɣ˱׼ΪFortran 90Fortran 90Fortran 77,Ҫ¹,㡢ģ黯ơṹࡢָ롢ģӿڣԶ׼ЩֲܽFortran77ԵĲ㣻Fortran 77ģͬʱЩʹCԵͬ๦ЩǵӦ֡ĳЩضϣʵFortran 90ص㣬ҲϺõЧԽ(subroutine)Ϊͬļʹ̳Ϊģ飬ѸģĳЩĳԱһʵģ黯ƣʵ˱ķװʹøģ飬ͬʱҲб
4ϱʵ
ͨFortranԱдؽ߽Ԫ⺬׶Ƶĸ԰ӦӦǿӵĳVC++,OpenGLϱ̼һѺãֱ۵Windows򡣳ͼ1ʾȡԻͼ2ʾ

ͼ1

ͼ2ȡĶԻ
ͼĻ˼·ڰϻ7000С񣬽Ľڵ㹲14760йڵ㣩ͨFortran߽ԪӦֵ(x,y,xy)ȻӦСӦVon Mises൱ӦԸӦֱֵСֵл11С䣬ÿ丳費ͬɫʣһÿͨӦĴСɫ꣬7000ɫʵСıʱͼͱƳСӦͼͼ3ʾ Von Mises൱Ӧͼͼ4ʾ

ͼ3СӦͼ

ͼ4Von Mises൱Ӧͼ
5
̽һָ촫ͳFortranԱдĳͨ÷ʵ֤˷ʵеġͨ÷߶Զһ˽⣬ͬʱ PowerStationVC++OpenGLƽ̨ͳһʹԭӵ򻯡÷ʹԳ¾ɵļԻҪǿǰԴԼıʱ䡣
߼飺־ʿооѹմɻϡӦֽоԱо򣺼ѧ硡оԱо򣺷ɻơ
ߵλϾպѧ.Ͼ(210016
ο
1ݡ㣬ƳΪ. Իϱ.ϾϾѧ,19941-5
2ݡRedwine Cooper. Upgrading to Fortran 90. Springer-Verlag New York,Inc19951-35
3ݡ¹Ԩ. Fortran 90. й, 19941-10
4ݡMichael J.Young. Visul C++ 4 ŵͨ.ӹҵ ,1997202-207
5ݡScott Stanfield,Ralph Arvesen. Visul C++ 4Աָ. еҵ199756-76
6ݡDavid J.Kruglinski. Visul C++Ļ.廪ѧ, 199650-57
ո:1999-03-15(޸ĸ)
