资源描述:
《Brief Introduction to the Fortran 90 programming language》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、PY502,ComputationalPhysics(Fall2006)BriefIntroductiontotheFortran90programminglanguageAndersW.Sandvik,DepartmentofPhysics,BostonUniversity1IntroductionTherearethreeversionsofFortraninusetoday;Fortran77/90/95,wherethenumbersindicate(approximately)theyearthestandardwaspublished(t
2、hereisalsoanextension,HighPerformanceFortran,whichcontainscompilerdirectivesforparallelcomputing).Anewrevision,Fortran2003(formerlyknownasFortran2000),isalsobecomingavailablenow.AnewminorrevisioncalledFortran2008isalreadyintheworks.ThisbriefintroductionfocusesonFortran90.Fortra
3、n95mainlyaddsadvancedfeaturesthatwillnotbeneededinthisclass.SincemanyusefulsubroutinesareavailableinFortran77,someofthedifferencesbetweenthe77and90versionswillbepointedoutaswell.Ingeneral,theversionsarebackwardcompatible,sothatFortran77codeisalsovalidFortran90(however,someFortra
4、n77featuresthatareconsideredoutdatedorredundantarenotedinFortran95ascandidatesforremovalinfuturerevisions).Onlytheverybasiclanguagefeatureswillbediscussedhere,mainlyintheformofsimpleexamples.Theintentionistoexplainthoselanguageelementsthatareneededtoquicklygetstartedinscientific
5、programming,andtogiveanoverviewofFortran90forthosethatmaybeexperiencedinanotherlanguage.Formoredetailsandmoreadvancedlanguageelements,consultanytextonFortran90,e.g.,Fortran90/95Explained,byM.MetcalfandJ.Reid(OxfordUniversityPress,secondedition,2002)orFortran90/95forScientistsan
6、dEngineers,byS.Chapman(McGrawHill,2004).Therearealsonumerousresouceson-line.Thistutorialisorganizedinsevensections:1)Introduction,2)Variablesanddeclarations,3)Pro-gramcontrolconstructs,4)Proceduresandprogramstructure,5)Intrinsicprocedures,6)Externalfilesandoutputformatting,and7)
7、Allocatable,assumed-shape,andautomaticarrays.Manyoftheelementarylanguagefeaturesareintroducedastheyareneeded,andthereforethewholetextshouldbereadfromstarttofinishbythosewhodonothaveanypriorknowledgeofFortran.Carefulexaminationoftheexampleprogramsisalsostronglyrecommended;theyare
8、alsoavailablefordownloadattheweb-siteofthecourse:physi