§Ö³t¤Jªù

 

±Ò°Ê VMWare Player ¨Ó¼½©ñ¹w¥ýÄé¦nªº Linux §@·~¨t²Î¤§µêÀÀ¾÷¾¹¡C

±q Windows ªº¶}©l

¨ä¤¤ªº ¡A

§ä´M VM Ware ¥Ø¿ý¡AÂI¿ïùØ­±ªº VMware Player

 

¦pªG¬O³Ìªñ¦³¨Ï¥Î¹L VMware Player¡A«h¤]¥i¥Hª½±µ±q ¶}©l ªº ¿ï³æ¤¤°_°Ê

 

¶}±Ò VMware Player ¤§«á¡A·|¸ß°ÝµêÀÀ¾÷¾¹ªº¼v¹³³]©wÀɦb¨ºùØ

 

¿ï¦n«á«ö [¶}±Ò]¡A«h·|³ê¿ôµêÀÀ¾÷¾¹¡]¦pªG«e¤@¦¸¦b¨Ï¥Î«á¬O°µ¥ð¯vªº°Ê§@ªº¸Ü¡^¡A¦^´_¨ì¤§«e¨Ï¥Î¤§ª¬ºAªº³Ì«áµe­±¡C

 

¦pªG«e¤@¦¸¬OµêÀÀ¾÷¾¹ªºÃö¾÷¡A«h¬O§¹¥þ¬Û¦ü©ó¤@¯ë¹q¸£¶}¾÷ªºµe­±

 

µn¤J¨t²Î¡]­Y¤wµn¤J«h¥i¸õ¹L¡^

¶}¾÷°T®§¶]§¹¤§«á¡A·|¶i¤J UNIX ¤§ X-µøµ¡ªº¹Ï§Îµn¤J¤¶­±

 

¥H student ¬°±b¸¹¨Ã¥H student ¬°±K½X¨Óµn¤J

 

±K½X±µ¨ü«á¡A·|ªá¤@¨Ç®É¶¡§@¸ü¤Jªº°Ê§@¡A

 

µM«á¶i¤J X-window ®à­±Àô¹Ò

 

¶}±Ò¤@­Ó²×ºÝ¾÷µøµ¡

¦A¤U¤@¨B¡A§Ú­Ì´N­n¶}±Ò¤@­Ó²×ºÝ¾÷µøµ¡¡A¨ä¹ê¥¦ªº±¶®|¤v¸g¦b®à­±¥H¤Î¤W±Æ menu bar ³£¦³¤F¡]¬Ý°_¨Ó¹³¤@­Ó¿Ã¹õªº¹Ï¥Ü¡^¡A¦Ü¤Ö³Ì¼Ð·Çªº¤èªk¡A¬O±qÀ³¥Îµ{¦¡¿ï³æ¤W¥h¿ï

 

¦p¦¹¡A´N·|¦³¤@­Ó²×ºÝ¾÷µøµ¡³Q¶}°_¨Ó

 

·Æ¹«´å¼Ð­n±q VM ¤¤¸õ¥X¨Ó¦^¨ì Windows ®à­±ªºÀô¹Ò¡A«h¦P®É«ö Ctrl ¤Î Alt ¨â­ÓÁä¡A¨Æ¹ê¤W¦b VM Player ªº°T®§Äæ¡]¥ª¤U¨¤¡^¤]·|¦³´£¥Ü¡C

 

¦b¾Þ§@¹Lµ{¤¤ªº¥ô¦ó¶¥¬q°±¤îµêÀÀ¾÷¾¹ªº¤èªk¡A

 

 

¥Î UNIX «ü¥O "ls" ¨Ó¬d¬Ý¥Ø«e¥Ø¿ý¤UªºÀÉ®×

ls ¡]¦C¥X¥Ø«e¥Ø¿ý¤UªºÀɮשΤl¥Ø¿ý¦WºÙ¡^

ls -l ¡]¥H¸ûªø¤§°T®§¡A ¦C¥X¥Ø«e¥Ø¿ý¤UªºÀɮשΤl¥Ø¿ý¦WºÙ¡Aª`·N ls »P -l ¤§¶¡¦³ªÅ®æ¡^

pwd¡]¦L¥X¥Ø«e¤u§@¥Ø¿ý present working directory¡^

cd "¥Ø¿ý¦WºÙ" ¡]Åܧó¥Ø¿ý¦ì¸m¡A¶i¤J¨ì "¥Ø¿ý¦WºÙ" ªº¥Ø¿ý¤§¤º¡^

 

¶]¤@¤U¹q¸£¼ÒÀÀ½d¨Òµ{¦¡ªº¥i°õ¦æÀÉ

¦b²×ºÝ¾÷µøµ¡¤U¡A¥ý¥´ cd ½T¹ê¦^¨ì¨Ï¥ÎªÌ home ¥Ø¿ý¡A¤U ls ¥i¨£ Desktop »P examples ¨â­Ó¥Ø¿ý¡C¥´ cd examples ¶i¤J examples ¥Ø¿ý¡A¥i¥Î pwd ¦L¥X¥Ø«e¥Ø¿ý¥H¨Ñ½T»{¡AµM«á¥´ ls ¬Ý³o­Ó¥Ø¿ý¤U¦³¤°»òÀÉ®×

§A·|¬Ý¨ì staticel.x ³o­ÓÀɮס]ºñ¦âÅã¥Ü¥¦¬O¤@­Ó°õ¦æÀÉ¡A¦ý³oºØÃC¦â°Ï¤À¨Ã«D©Ò¦³ UNIX ²×ºÝ¾÷¬Ò³q¥Î¡^¡A¥´ ./staticel.x ¨Ã«ö Enter Áä¡A¹q¤O½u¼ÒÀÀ´N·|¶}©l

 

§â¹q¤O½u®i¥Ü¹ÏÃö±¼ªº¤èªk¡A¬O¥ýÂI¿ï terminal ¤WÃä®Ø¨Ï¨ä¦^¨ì³Ì¤W¼hÅã¥Ü¡A¦p¤U

¦A¦P®É«ö¤U Ctrl »P c §â¹Ï§Î®i¥Üµ{¦¡ staticel.x ±þ±¼¡C

 

 

¥Î vi ¤À§O¶}±Ò´X­Ó½d¨ÒÀɮרÓÀ˵ø¨ä¤º®e¡A ¤@¦¸¬Ý¤@­¶¡A¨Ã¾Ç²ß¤£§ó°Ê¦Ó¦w¥þ°h¥X¤§¤èªk

¡]·í³õÁ¿¸Ñ»P½m²ß¡^

¶i¤J vi »P°h¥X vi ªº¤èªk¡G¶i¤J¬O¥´ vi "ÀɦW"¡A Àɮצs¦b´NÅã¥Ü¡A¤£¦s¦b´N·s«Ø¡F­n°h¥X vi¡A¬O«ö ESC ¸õ²æ¥X¥´¦r¾÷¼Ò¦¡¦Ó¤J½s¿è©R¥O¼Ò¦¡¡]·|¦A¸Ô²ÓÁ¿¡^¡A¥´«_¸¹»P q ¦p":q"¡A¥i¤£­×§ï°h¥X¡C­YÂsÄý¹Lµ{¤¤¦³¤£·V¥´¤J½s¿è«ü¥O¡A«h¦b ":q" ®É vi ·|´£¿ô§A©|¥¼¶J¦s¡A«h§A¥²¶·¥´ "q!" ±j¨î©ñ±ó­×§ï°h¥X¡C

­YÀɮ׬O¤°»ò¦r¤¸³£¨S¦³¡A«h¿Ã¹õ¥ª¦C¥Ñ ~ ¦ûº¡¡A¥Nªí¨ºùبƹê¤W¬O¨S¦³¦r¤¸ªº¡C

«ö Ctrl »P f ¬Ý¤U¤@­¶¡BCtrl »P b ¬Ý¤W¤@­¶¡C

Ãö©ó vi ªº¶i¤@¨B¸ê°T½Ð¨£§Ú¥t¤@­Óºô­¶

¥H¤U¥½¬Ý´X­Ó Fortran (Fortran 77) µ{¦¡¡G

³Ì²³æªº¡A¬O©w¸q¤Fµ{¦¡¡A¦ý¤°»ò¤]³]°µ¡]ª`·N±q²Ä¤C®æ¶}©l¼g«ü¥O¡A²Ä¤»®æ­n«O¯dµ¹©µ¦ù²Å¸¹¥Î¡^¡A¹³¤U¦Ó³o­Ó½d¨Ò¡G¡]¤S¡AFortran »y¨¥¤¤¤j¤p¼g¬O¤£¤Àªº¡^ ¡]¥t¥~¡A¦h¥[¤J¨ÇªÅ¦æ¦b¨ä¤¤¤]¨S¦³¼vÅT¡^

program empty

end

¤@¼Ë¬O¤°»ò¨Æ±¡³£¤£°µ¡A¦h¼g¤F­Óµù¸Ñ¡C¥ô¤@¦æªº²Ä¤@®æ¥´ c¡]§Y comment ¤§·N¡^¡A«h¸Ó¦æ¾ã­Ó·í§@µù¸Ñ¡A§¹¤µ»Pµ{¦¡«ü¥OµLÃö

program empty

c This program does nothing, and this is a comment line.

end

«Ü¦hµ{¦¡®Ñªº¤Jªù¤¶²Ð³£¬O±Ð¤H®a¼g¤@­Ó¦L¥X "Hello, world." ªº¸Ü¨ì¿Ã¹õ¤W¡A¦b Fortran ªº¼gªk¬O¹³¤U¨Ò³o¼Ë¡G

program hello_world

write(*,*) 'Hello, world.'

end

³oªí¥Ü Fortran ¬O¥Î write ¨Ó¦rªF¦è¡A¦Ó«á­±ªº (*,*) ¥Nªí "¡] ¿é¥X¨ì¹w³]¸Ë¸m¡A¥H¹w³]®æ¦¡¬°¤§ ¡^"¡C

¦A¨Ó¬Ý¤@­Ó¯à§@­pºâ 1 + 2 + 3 + ... + 10 ªºµ{¦¡¡Aª`·N¨Ï¥ÎÅܼƭn«Å§i¡]«Å§i¨ä¬°¹ê¼Æ real ©Î¾ã¼Æ integer¡^¡A¨Ã¥B a = b + c ¦bµ{¦¡¤¤¥Nªí§â b ¥[ c ªºµ²ªG©ñ¤J a¡A¦Ó¤£¬O¼Æ¾Ç¤¤¤§«íµ¥¦¡¨ººØ·N«ä¡]­nÂIªº¦a¤è¤w¼Ð¤FÂŦâ¡^¡A

program add_from_one_to_ten

c This is a program that will do 1+2+3...+10

c and print the result to screen

integer i, sum

write (*,*) 'Adding from one to ten ...'

write (*,*)

sum = 0

do i =1, 10

sum = sum + i

end do

write (*,*) 'The total is :', sum

end

§Ú­Ì¬Æ¦Ü¥i¥H¼g¤@­Ó¥i¥H¥ý½Ð¨Ï¥ÎªÌ¿é¤J n¡A¦A¶i¦æ±q 1 ³s¥[¨ì n ªºµ{¦¡¡A­«ÂI³B§Ú­Ì¥ÎÂŦâ¼Ð¥X¡A¦p¤U¡G

program add_from_one_to_n

c This is a program that will do 1+2+3...+n for a given n value.

integer i, sum, n

write (*,*) 'Please type in an integer value n for

read (*,*) n

write (*,*) 'Adding from one to ten ...'

write (*,*)

sum = 0

do i =1, n

sum = sum + i

end do

write (*,*) 'The total is :', sum

end

¬Ý§¹¤F¯à°µ­pºâªºµ{¦¡¡A²{¦b¨Ó¬Ý¤@¤U¯àµe¹Ïªº Fortran µ{¦¡¡AFortran ¥»¨­¨Ã¥¼¤º«Øø¹Ï«ü¥O¡A§Ú­Ì¬OÂǥѩI¥s¡]Fortran «ü¥O call¡^pgplot ³o­Ó§K¶Oªº¦Û¥Ñ³nÅé¨Ó¹F¦¨

program pg_basic

c This program demonstrate basic pgplot functions (routines).

real y(100), x(100), delta_x, point_y(5), point_x(5)

integer i, pgopen

if (pgopen('?').le.0) stop

delta_x = 5.0/100.0

do i=1, 100

x(i) = (i-1)*delta_x

y(i) = x(i)**2

end do

do i=1, 5

point_x(i) = i

point_y(i) = i**2

end do

call pgenv(0.0, 10.0, 0.0, 20.0, 0, 1)

call pglab('x','y', 'y=x**2')

call pgline(100, x, y)

call pgpt(5, point_x, point_y, 9)

call pgclos

end

¦³Ãö©ó pgplot ªº¶i¤@¨B¸ê®Æ¡A½Ð¬Ý§Ú¥t¤@­Óºô­¶¡C

 

¸Õ¥Î¨t²Î¤º«Ø¤§ fortran compiler ¨Ó²£¥Í¨º´X­Óµ{¦¡­ì©l½Xªº¥i°õ¦æÀÉ¡A¨Ã¸ÕµÛ°õ¦æ¥¦­Ì

¡]·í³õÁ¿¸Ñ»P½m²ß¡^

­Y¬O¤@¯ë­pºâªºµ{¦¡¡A¥u»Ý¥´¡]§Ú­Ì¥H¨Ï¥Î gfortran ³o­Ó fortran compiler ¬°¨Ò¡A¦b§Oªº¨t²Î§A¦³¥i¯à·|¥Î¨ìªº¬O f77 ©Î g77¡G

gfortran hello.f <Enter>

¥H¤W§@ªk¨ä¥i°õ¦æÀÉ·|¤@«ß¥s°µ a.out¡]­n°õ¦æ®É¡A¥´ ./a.out <Enter>¡^¡C©ÎªÌ¬O§A¤]¥i¥H¥´¡G

gfortran -o hello.x hello.f <Enter>

«h¨ä¥i°õ¦æÀÉ·|¨Ì§A­n¨D³Q©R¦W¬° hello.x¡C¡]­n°õ¦æ®É¡A¥´ ./hello.x <Enter>¡^

»Ý­n¥Î¨ì pgplot ø¹Ïªº°Æµ{¦¡®w¡]§Y¥Ø¿ý¤Uªº libpgplot.a¡^®É¡A«h²¤¬°½ÆÂø¤@ÂI¡A­n¥´¡]ª`·N¥H¤U¤å¦r­n¥´¦b¦P¤@¦æ¡A¤£¯à¥Î <Enter> Â_¶}¡^¡G

gfortran -o pg_basic.x -L/usr/X11R6/lib -lX11 pg_basic.f libpgplot.a

¨ä¤¤ libpgplot.a ¬O ø¹Ï°Æµ{¦¡®w¨º¤@¾ã¥]ÀɮסA¦Ó -L/usr/X11R6/lib -lX11 «h¬O§i¶D fortran ½sĶ¾¹­n¤Þ¤J X¡Ðµøµ¡Ã¸¹Ïªº°Ê§@ªº°ò¥»µ{¦¡®w X11¡]¨ä¹ê»ÚÀɦW¥s libX11.a¡^¡A¦]¦¹¨âªÌ³£¬O»Ý­nªº¡C

©Î¬O¤]¥i¥H¥´¡]¥H¤U¤å¦r­n¥´¦b¦P¤@¦æ¡^¡G

gfortran -o pg_basic.x pg_basic.f -L/usr/X11R6/lib -lX11 -L /usr/local/pgplot -lpgplot

 

¦b UNIX ¤§¤U¨Ï¥Î Fortran ½sĶ¾¹ªº¬ÛÃö¤Jªù¸ê®Æ

 

 

¥Î vi ¼g¤@¡B¨â­Ó³Ì²³æªºµ{¦¡¡A¶¶«K¾Ç¥Î vi ªº³Ì°ò¥»«ü¥O

¡]·í³õÁ¿¸Ñ»P½m²ß¡^

Ãö©ó vi ªº¶i¤@¨B¸ê°T½Ð¨£§Ú¥t¤@­Óºô­¶¡Afortran ¨â¤p®É§Ö³t¤Jªù«h¬Ý³oùØ¡C

 

 

µn¥X¨t²Î¤ÎÃö¾÷©ÎµêÀÀ¾÷¾¹¥ð¯v¤§¤èªk

¥ð¯v

³Ì¤è«Kªº§@ªk¡A¬OµL½×¤u§@¨ì¨º­Ó¶¥¬q¡A´Nª½±µ±NµêÀÀ¾÷¾¹ ª½±µ¥ð¯v¡A±q VMware Player ¥ª¤W¨¤ Player ¤U©Ô¿ï³æ¤¤«ö Exit

·|­n¨D½T»{°Ê§@

µêÀÀ¾÷¾¹´N·|¶}©l¥ð¯v¡Aª`·N»Ý­nµ¹¥¦¤@ÂI®É¶¡¡AVMware Player ¤~¯à§¹¦¨¨Ã°h¥X¡C

¤U¦¸¦A¥Î VMware Player ¶}±ÒµêÀÀ¾÷¾¹®É¡A´N·|±q¥ð¯v«eªºµe­±Ä~Äò¹B§@¤U¥h¡A¦]¦¹³o¬O³Ì¤è«Kªº§@ªk¡C

µn¥X

­n±q¤W±Æ¹Ï¥Ü¤¤ªº®à­±¥´¶}¿ï³æ¡A¨Ã¿ïµn¥X«ö¤U

³o¼Ë´N·|¦^¨ìµn¤Jµe­±¡A§A¤]¥i¥H¿ï¾Ü¥ð¯v¡A¤U¦¸¦A±Ò°Ê¦Ü¤Ö¬Ù¤U¶}¾÷¹Lµ{©Òªáªº®É¶¡

 

Ãö¾÷

³oùØ«üªº¬OµêÀÀ¾÷¾¹Ãö¾÷¡A§A¥i¥H¦bµn¥X«áÃö¾÷¡A©Î¬O¦b X-window ¤u§@¨ì¤@¬q¸¨¤§«á´N±q¤W±Æ¹Ï¥Üªº®à­±¿ï³æ¤¤«öÃö¾÷¡C¡]Ãö¾÷¦b¯u¹ê¦øªA¾¹©Î¦h¤H¨Ï¥ÎÀô¹Ò¤~·|»P¥ð¯vªº®ÄªG¤ñ¸û¤£¦P¡A¦]¦¹¦b¦¹¨Ã¤£±`¥Î¡C¡^

­n¨D½T»{ªº¹ï¸Ü®Ø·|¥X²{¡A½T»{Ãö¾÷«á¡A¨t²Î·|³v¨BÃö±¼¨ä¦b­I´º¤¤¹B§@ªºµ{¦¡¦Ó¦³³v±øªº°T®§¥X²{

«ÝÃö¾÷§¹¦¨¡A¾ã­Ó VMware Player ¤]·|ÀH§Y°h¥X¡C