Fortran_Fortran Structure and Style - Wikibooks, Open Books for an Open World
-
Upload
goce-vasilevski -
Category
Documents
-
view
3 -
download
1
Transcript of Fortran_Fortran Structure and Style - Wikibooks, Open Books for an Open World
-
3/23/2015 Fortran/FortranstructureandstyleWikibooks,openbooksforanopenworld
http://en.wikibooks.org/wiki/Fortran/Fortran_structure_and_style 1/1
Fortran/FortranstructureandstyleStyle
OlderversionsofFortranhadstrictguidelinesonhowaprogramwasformatted.Howevernewversions,especiallyFortran90andabovehavemodernized,allowingmoreflexibility.
OriginallyFortranrequiredallstatementstobeinALLCAPS,andinfactthelanguageitselfwascalledFORTRAN(incaps).Itremainsabitcustomary,thoughcompletelyunnecessary,toputFortrancommandsinALLCAPS.
PROGRAMtestIMPLICITNONEINTEGERfourfour=4WRITE(*,*)fourENDPROGRAM
Whitespaceandemptylinesusuallywon'tmatterinF90orabove,butinrarecaseserrorswillpopup.However,unlikemanyotherlanguagessuchasC,C++,andJava,thelinedelimiter''isoptional,soeachlineofcodemaystayonitsownline!
Structure
ThereisaGOTOcommand,butdon'tuseittoomuch.UseDOloopsearlyandoften.Encapsulateyourcodeintofunctionsandsubroutinesmakingiteasiertoprogramathigherlevels,andallowingotherstounderstandwhatsgoingon.Commentyourcodewell.Don'tcommenteveryline,butexplainhoweverythingworks.
Retrievedfrom"http://en.wikibooks.org/w/index.php?title=Fortran/Fortran_structure_and_style&oldid=2124554"
Thispagewaslastmodifiedon23June2011,at00:42.TextisavailableundertheCreativeCommonsAttributionShareAlikeLicense.additionaltermsmayapply.Byusingthissite,youagreetotheTermsofUseandPrivacyPolicy.
http://creativecommons.org/licenses/by-sa/3.0/http://wikimediafoundation.org/wiki/Privacy_policyhttp://wikimediafoundation.org/wiki/Terms_of_Usehttp://en.wikibooks.org/w/index.php?title=Fortran/Fortran_structure_and_style&oldid=2124554