ma27d.c 141 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057
  1. /* ma27d.f -- translated by f2c (version 20200916).
  2. You must link the resulting object file with libf2c:
  3. on Microsoft Windows system, link with libf2c.lib;
  4. on Linux or Unix systems, link with .../path/to/libf2c.a -lm
  5. or, if you install libf2c.a in a standard place, with -lf2c -lm
  6. -- in that order, at the end of the command line, as in
  7. cc *.o -lf2c -lm
  8. Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
  9. http://www.netlib.org/f2c/libf2c.zip
  10. */
  11. #include "f2c.h"
  12. /* Table of constant values */
  13. static integer c__1 = 1;
  14. static integer c__2 = 2;
  15. /* COPYRIGHT (c) 1982 AEA Technology */
  16. /* ######DATE 20 September 2001 */
  17. /* September 2001: threadsafe version of MA27 */
  18. /* 19/3/03. Array ICNTL in MA27GD made assumed size. */
  19. /* Subroutine */ int ma27id_(integer *icntl, doublereal *cntl)
  20. {
  21. /* Stream number for error messages */
  22. /* Parameter adjustments */
  23. --cntl;
  24. --icntl;
  25. /* Function Body */
  26. icntl[1] = 6;
  27. /* Stream number for diagnostic messages */
  28. icntl[2] = 6;
  29. /* Control the level of diagnostic printing. */
  30. /* 0 no printing */
  31. /* 1 printing of scalar parameters and first parts of arrays. */
  32. /* 2 printing of scalar parameters and whole of arrays. */
  33. icntl[3] = 0;
  34. /* The largest integer such that all integers I in the range */
  35. /* -ICNTL(4).LE.I.LE.ICNTL(4) can be handled by the shortest integer */
  36. /* type in use. */
  37. icntl[4] = 2139062143;
  38. /* Minimum number of eliminations in a step that is automatically */
  39. /* accepted. if two adjacent steps can be combined and each has less */
  40. /* eliminations then they are combined. */
  41. icntl[5] = 1;
  42. /* Control whether direct or indirect access is used by MA27C/CD. */
  43. /* Indirect access is employed in forward and back substitution */
  44. /* respectively if the size of a block is less than */
  45. /* ICNTL(IFRLVL+MIN(10,NPIV)) and ICNTL(IFRLVL+10+MIN(10,NPIV)) */
  46. /* respectively, where NPIV is the number of pivots in the block. */
  47. icntl[6] = 32639;
  48. icntl[7] = 32639;
  49. icntl[8] = 32639;
  50. icntl[9] = 32639;
  51. icntl[10] = 14;
  52. icntl[11] = 9;
  53. icntl[12] = 8;
  54. icntl[13] = 8;
  55. icntl[14] = 9;
  56. icntl[15] = 10;
  57. icntl[16] = 32639;
  58. icntl[17] = 32639;
  59. icntl[18] = 32639;
  60. icntl[19] = 32689;
  61. icntl[20] = 24;
  62. icntl[21] = 11;
  63. icntl[22] = 9;
  64. icntl[23] = 8;
  65. icntl[24] = 9;
  66. icntl[25] = 10;
  67. /* Not used */
  68. icntl[26] = 0;
  69. icntl[27] = 0;
  70. icntl[28] = 0;
  71. icntl[29] = 0;
  72. icntl[30] = 0;
  73. /* Control threshold pivoting. */
  74. cntl[1] = .1;
  75. /* If a column of the reduced matrix has relative density greater than */
  76. /* CNTL(2), it is forced into the root. All such columns are taken to */
  77. /* have sparsity pattern equal to their merged patterns, so the fill */
  78. /* and operation counts may be overestimated. */
  79. cntl[2] = 1.;
  80. /* An entry with absolute value less than CNTL(3) is never accepted as */
  81. /* a 1x1 pivot or as the off-diagonal of a 2x2 pivot. */
  82. cntl[3] = 0.;
  83. /* Not used */
  84. cntl[4] = 0.f;
  85. cntl[5] = 0.f;
  86. return 0;
  87. } /* ma27id_ */
  88. /* Subroutine */ int ma27ad_(integer *n, integer *nz, integer *irn, integer *
  89. icn, integer *iw, integer *liw, integer *ikeep, integer *iw1, integer
  90. *nsteps, integer *iflag, integer *icntl, doublereal *cntl, integer *
  91. info, doublereal *ops)
  92. {
  93. /* Format strings */
  94. static char fmt_10[] = "(/,/,\002 ENTERING MA27AD WITH N NZ "
  95. " LIW IFLAG\002,/,21x,i7,i7,i9,i7)";
  96. static char fmt_20[] = "(\002 MATRIX NON-ZEROS\002,/,4(i9,i6),/,(i9,i6,i"
  97. "9,i6,i9,i6,i9,i6))";
  98. static char fmt_30[] = "(\002 IKEEP(.,1)=\002,10i6,/,(12x,10i6))";
  99. static char fmt_80[] = "(\002 **** ERROR RETURN FROM MA27AD **** INFO("
  100. "1)=\002,i3)";
  101. static char fmt_90[] = "(\002 VALUE OF N OUT OF RANGE ... =\002,i10)";
  102. static char fmt_110[] = "(\002 VALUE OF NZ OUT OF RANGE .. =\002,i10)";
  103. static char fmt_150[] = "(\002 LIW TOO SMALL, MUST BE INCREASED FROM\002"
  104. ",i10,\002 TO AT LEAST\002,i10)";
  105. static char fmt_170[] = "(/,\002 LEAVING MA27AD WITH NSTEPS INFO(1) "
  106. "OPS IERROR\002,\002 NRLTOT NIRTOT\002,/,20x,2i7,f7.0,3i7,/,20x"
  107. ",\002 NRLNEC NIRNEC NRLADU NIRADU NCMPA\002,/,20x,6i7)";
  108. static char fmt_180[] = "(\002 IKEEP(.,2)=\002,10i6,/,(12x,10i6))";
  109. static char fmt_190[] = "(\002 IKEEP(.,3)=\002,10i6,/,(12x,10i6))";
  110. /* System generated locals */
  111. integer ikeep_dim1, ikeep_offset, iw1_dim1, iw1_offset, i__1;
  112. /* Builtin functions */
  113. integer s_wsfe(cilist *), do_fio(integer *, char *, ftnlen), e_wsfe(void);
  114. /* Local variables */
  115. static integer i__, k, l1, l2, iwfr, lliw;
  116. extern /* Subroutine */ int ma27gd_(integer *, integer *, integer *,
  117. integer *, integer *, integer *, integer *, integer *, integer *,
  118. integer *, integer *, integer *), ma27hd_(integer *, integer *,
  119. integer *, integer *, integer *, integer *, integer *, integer *,
  120. integer *, integer *, integer *, integer *, doublereal *),
  121. ma27jd_(integer *, integer *, integer *, integer *, integer *,
  122. integer *, integer *, integer *, integer *, integer *, integer *,
  123. integer *, integer *), ma27kd_(integer *, integer *, integer *,
  124. integer *, integer *, integer *, integer *, integer *, integer *,
  125. integer *), ma27ld_(integer *, integer *, integer *, integer *,
  126. integer *, integer *, integer *, integer *, integer *), ma27md_(
  127. integer *, integer *, integer *, integer *, integer *, integer *,
  128. integer *, integer *, integer *, integer *, integer *, integer *,
  129. integer *, doublereal *);
  130. /* Fortran I/O blocks */
  131. static cilist io___2 = { 0, 0, 0, fmt_10, 0 };
  132. static cilist io___4 = { 0, 0, 0, fmt_20, 0 };
  133. static cilist io___5 = { 0, 0, 0, fmt_30, 0 };
  134. static cilist io___10 = { 0, 0, 0, fmt_80, 0 };
  135. static cilist io___11 = { 0, 0, 0, fmt_90, 0 };
  136. static cilist io___12 = { 0, 0, 0, fmt_80, 0 };
  137. static cilist io___13 = { 0, 0, 0, fmt_110, 0 };
  138. static cilist io___14 = { 0, 0, 0, fmt_80, 0 };
  139. static cilist io___15 = { 0, 0, 0, fmt_150, 0 };
  140. static cilist io___16 = { 0, 0, 0, fmt_170, 0 };
  141. static cilist io___17 = { 0, 0, 0, fmt_30, 0 };
  142. static cilist io___18 = { 0, 0, 0, fmt_180, 0 };
  143. static cilist io___19 = { 0, 0, 0, fmt_190, 0 };
  144. /* THIS SUBROUTINE COMPUTES A MINIMUM DEGREE ORDERING OR ACCEPTS A GIVEN */
  145. /* ORDERING. IT COMPUTES ASSOCIATED ASSEMBLY AND ELIMINATION */
  146. /* INFORMATION FOR MA27B/BD. */
  147. /* N MUST BE SET TO THE MATRIX ORDER. IT IS NOT ALTERED. */
  148. /* NZ MUST BE SET TO THE NUMBER OF NON-ZEROS INPUT. IT IS NOT */
  149. /* ALTERED. */
  150. /* IRN(I),I=1,2,...,NZ MUST BE SET TO THE ROW NUMBERS OF THE */
  151. /* NON-ZEROS. IT IS NOT ALTERED UNLESS IT IS EQUIVALENCED */
  152. /* TO IW (SEE DESCRIPTION OF IW). */
  153. /* ICN(I),I=1,2,...,NZ MUST BE SET TO THE COLUMN NUMBERS OF THE */
  154. /* NON-ZEROS. IT IS NOT ALTERED UNLESS IT IS EQUIVALENCED */
  155. /* TO IW (SEE DESCRIPTION OF IW). */
  156. /* IW NEED NOT BE SET ON INPUT. IT IS USED FOR WORKSPACE. */
  157. /* IRN(1) MAY BE EQUIVALENCED TO IW(1) AND ICN(1) MAY BE */
  158. /* EQUIVALENCED TO IW(K), WHERE K.GT.NZ. */
  159. /* LIW MUST BE SET TO THE LENGTH OF IW. IT MUST BE AT LEAST 2*NZ+3*N */
  160. /* FOR THE IFLAG=0 ENTRY AND AT LEAST NZ+3*N FOR THE IFLAG=1 */
  161. /* ENTRY. IT IS NOT ALTERED. */
  162. /* IKEEP NEED NOT BE SET UNLESS AN ORDERING IS GIVEN, IN WHICH CASE */
  163. /* IKEEP(I,1) MUST BE SET TO THE POSITION OF VARIABLE I IN THE */
  164. /* ORDER. ON OUTPUT IKEEP CONTAINS INFORMATION NEEDED BY MA27B/BD. */
  165. /* IKEEP(I,1) HOLDS THE POSITION OF VARIABLE I IN THE PIVOT ORDER. */
  166. /* IKEEP(I,2), IKEEP(I,3) HOLD THE NUMBER OF ELIMINATIONS, ASSEMBLIES */
  167. /* AT MAJOR STEP I, I=1,2,...,NSTEPS. NOTE THAT WHEN AN ORDER IS */
  168. /* GIVEN IT MAY BE REPLACED BY ANOTHER ORDER THAT GIVES IDENTICAL */
  169. /* NUMERICAL RESULTS. */
  170. /* IW1 IS USED FOR WORKSPACE. */
  171. /* NSTEPS NEED NOT BE SET. ON OUTPUT IT CONTAINS THE NUMBER OF MAJOR */
  172. /* STEPS NEEDED FOR A DEFINITE MATRIX AND MUST BE PASSED UNCHANGED */
  173. /* TO MA27B/BD. */
  174. /* IFLAG MUST SET TO ZERO IF THE USER WANTS THE PIVOT ORDER CHOSEN */
  175. /* AUTOMATICALLY AND TO ONE IF HE WANTS TO SPECIFY IT IN IKEEP. */
  176. /* ICNTL is an INTEGER array of length 30 containing user options */
  177. /* with integer values (defaults set in MA27I/ID) */
  178. /* ICNTL(1) (LP) MUST BE SET TO THE STREAM NUMBER FOR ERROR MESSAGES. */
  179. /* ERROR MESSAGES ARE SUPPRESSED IF ICNTL(1) IS NOT POSITIVE. */
  180. /* IT IS NOT ALTERED. */
  181. /* ICNTL(2) (MP) MUST BE SET TO THE STREAM NUMBER FOR DIAGNOSTIC */
  182. /* MESSAGES. DIAGNOSTIC MESSAGES ARE SUPPRESSED IF ICNTL(2) IS NOT */
  183. /* POSITIVE. IT IS NOT ALTERED. */
  184. /* ICNTL(3) (LDIAG) CONTROLS THE LEVEL OF DIAGNOSTIC PRINTING. */
  185. /* 0 NO PRINTING */
  186. /* 1 PRINTING OF SCALAR PARAMETERS AND FIRST PARTS OF ARRAYS. */
  187. /* 2 PRINTING OF SCALAR PARAMETERS AND WHOLE OF ARRAYS. */
  188. /* ICNTL(4) (IOVFLO) IS THE LARGEST INTEGER SUCH THAT ALL INTEGERS */
  189. /* I IN THE RANGE -IOVFLO.LE.I.LE.IOVFLO CAN BE HANDLED BY THE */
  190. /* SHORTEST INTEGER TYPE IN USE. */
  191. /* ICNT(5) (NEMIN) MUST BE SET TO THE MINIMUM NUMBER OF ELIMINATIONS */
  192. /* IN A STEP THAT IS AUTOMATICALLY ACCEPTED. IF TWO ADJACENT STEPS */
  193. /* CAN BE COMBINED AND EACH HAS LESS ELIMINATIONS THEN THEY ARE */
  194. /* COMBINED. */
  195. /* ICNTL(IFRLVL+I) I=1,20, (IFRLVL) MUST BE SET TO CONTROL WHETHER */
  196. /* DIRECT OR INDIRECT ACCESS IS USED BY MA27C/CD. INDIRECT ACCESS */
  197. /* IS EMPLOYED IN FORWARD AND BACK SUBSTITUTION RESPECTIVELY IF THE */
  198. /* SIZE OF A BLOCK IS LESS THAN ICNTL(IFRLVL+(MIN(10,NPIV)) AND */
  199. /* ICNTL(IFRLVL+10+MIN(10,NPIV)) RESPECTIVELY, WHERE NPIV IS THE */
  200. /* NUMBER OF PIVOTS IN THE BLOCK. */
  201. /* ICNTL(I) I=26,30 are not used. */
  202. /* CNTL is an DOUBLE PRECISION array of length 5 containing user options */
  203. /* with real values (defaults set in MA27I/ID) */
  204. /* CNTL(1) (U) IS USED TO CONTROL THRESHOLD PIVOTING. IT IS NOT */
  205. /* ALTERED. */
  206. /* CNTL(2) (FRATIO) has default value 1.0. If a column of the */
  207. /* reduced matrix has relative density greater than CNTL(2), it */
  208. /* is forced into the root. All such columns are taken to have */
  209. /* sparsity pattern equal to their merged patterns, so the fill */
  210. /* and operation counts may be overestimated. */
  211. /* CNTL(3) (PIVTOL) has default value 0.0. An entry with absolute */
  212. /* value less than CNTL(3) is never accepted as a 1x1 pivot or */
  213. /* as the off-diagonal of a 2x2 pivot. */
  214. /* CNTL(I) I=4,5 are not used. */
  215. /* INFO is an INTEGER array of length 20 which is used to return */
  216. /* information to the user. */
  217. /* INFO(1) (IFLAG) is an error return code, zero for success, greater */
  218. /* than zero for a warning and less than zero for errors, see */
  219. /* INFO(2). */
  220. /* INFO(2) (IERROR) HOLDS ADDITIONAL INFORMATION IN THE EVENT OF ERRORS. */
  221. /* IF INFO(1)=-3 INFO(2) HOLDS A LENGTH THAT MAY SUFFICE FOR IW. */
  222. /* IF INFO(1)=-4 INFO(2) HOLDS A LENGTH THAT MAY SUFFICE FOR A. */
  223. /* IF INFO(1)=-5 INFO(2) IS SET TO THE PIVOT STEP AT WHICH SINGULARITY */
  224. /* WAS DETECTED. */
  225. /* IF INFO(1)=-6 INFO(2) IS SET TO THE PIVOT STEP AT WHICH A CHANGE OF */
  226. /* PIVOT SIGN WAS FOUND. */
  227. /* IF INFO(1)= 1 INFO(2) HOLDS THE NUMBER OF FAULTY ENTRIES. */
  228. /* IF INFO(1)= 2 INFO(2) IS SET TO THE NUMBER OF SIGNS CHANGES IN */
  229. /* THE PIVOTS. */
  230. /* IF INFO(1)=3 INFO(2) IS SET TO THE RANK OF THE MATRIX. */
  231. /* INFO(3) and INFO(4) (NRLTOT and NIRTOT) REAL AND INTEGER STRORAGE */
  232. /* RESPECTIVELY REQUIRED FOR THE FACTORIZATION IF NO COMPRESSES ARE */
  233. /* ALLOWED. */
  234. /* INFO(5) and INFO(6) (NRLNEC and NIRNEC) REAL AND INTEGER STORAGE */
  235. /* RESPECTIVELY REQUIRED FOR THE FACTORIZATION IF COMPRESSES ARE */
  236. /* ALLOWED AND THE MATRIX IS DEFINITE. */
  237. /* INFO(7) and INFO(8) (NRLADU and NIRADU) REAL AND INTEGER STORAGE */
  238. /* RESPECTIVELY FOR THE MATRIX FACTORS AS CALCULATED BY MA27A/AD */
  239. /* FOR THE DEFINITE CASE. */
  240. /* INFO(9) and INFO(10) (NRLBDU and NIRBDU) REAL AND INTEGER STORAGE */
  241. /* RESPECTIVELY FOR THE MATRIX FACTORS AS FOUND BY MA27B/BD. */
  242. /* INFO(11) (NCMPA) ACCUMULATES THE NUMBER OF TIMES THE ARRAY IW IS */
  243. /* COMPRESSED BY MA27A/AD. */
  244. /* INFO(12) and INFO(13) (NCMPBR and NCMPBI) ACCUMULATE THE NUMBER */
  245. /* OF COMPRESSES OF THE REALS AND INTEGERS PERFORMED BY MA27B/BD. */
  246. /* INFO(14) (NTWO) IS USED BY MA27B/BD TO RECORD THE NUMBER OF 2*2 */
  247. /* PIVOTS USED. */
  248. /* INFO(15) (NEIG) IS USED BY ME27B/BD TO RECORD THE NUMBER OF */
  249. /* NEGATIVE EIGENVALUES OF A. */
  250. /* INFO(16) to INFO(20) are not used. */
  251. /* OPS ACCUMULATES THE NO. OF MULTIPLY/ADD PAIRS NEEDED TO CREATE THE */
  252. /* TRIANGULAR FACTORIZATION, IN THE DEFINITE CASE. */
  253. /* .. Scalar Arguments .. */
  254. /* .. */
  255. /* .. Array Arguments .. */
  256. /* .. */
  257. /* .. Local Scalars .. */
  258. /* .. */
  259. /* .. External Subroutines .. */
  260. /* .. */
  261. /* .. Intrinsic Functions .. */
  262. /* .. */
  263. /* .. Executable Statements .. */
  264. /* Parameter adjustments */
  265. iw1_dim1 = *n;
  266. iw1_offset = 1 + iw1_dim1;
  267. iw1 -= iw1_offset;
  268. ikeep_dim1 = *n;
  269. ikeep_offset = 1 + ikeep_dim1;
  270. ikeep -= ikeep_offset;
  271. --irn;
  272. --icn;
  273. --iw;
  274. --icntl;
  275. --cntl;
  276. --info;
  277. /* Function Body */
  278. for (i__ = 1; i__ <= 15; ++i__) {
  279. info[i__] = 0;
  280. /* L5: */
  281. }
  282. if (icntl[3] <= 0 || icntl[2] <= 0) {
  283. goto L40;
  284. }
  285. /* PRINT INPUT VARIABLES. */
  286. io___2.ciunit = icntl[2];
  287. s_wsfe(&io___2);
  288. do_fio(&c__1, (char *)&(*n), (ftnlen)sizeof(integer));
  289. do_fio(&c__1, (char *)&(*nz), (ftnlen)sizeof(integer));
  290. do_fio(&c__1, (char *)&(*liw), (ftnlen)sizeof(integer));
  291. do_fio(&c__1, (char *)&(*iflag), (ftnlen)sizeof(integer));
  292. e_wsfe();
  293. *nsteps = 0;
  294. k = min(8,*nz);
  295. if (icntl[3] > 1) {
  296. k = *nz;
  297. }
  298. if (k > 0) {
  299. io___4.ciunit = icntl[2];
  300. s_wsfe(&io___4);
  301. i__1 = k;
  302. for (i__ = 1; i__ <= i__1; ++i__) {
  303. do_fio(&c__1, (char *)&irn[i__], (ftnlen)sizeof(integer));
  304. do_fio(&c__1, (char *)&icn[i__], (ftnlen)sizeof(integer));
  305. }
  306. e_wsfe();
  307. }
  308. k = min(10,*n);
  309. if (icntl[3] > 1) {
  310. k = *n;
  311. }
  312. if (*iflag == 1 && k > 0) {
  313. io___5.ciunit = icntl[2];
  314. s_wsfe(&io___5);
  315. i__1 = k;
  316. for (i__ = 1; i__ <= i__1; ++i__) {
  317. do_fio(&c__1, (char *)&ikeep[i__ + ikeep_dim1], (ftnlen)sizeof(
  318. integer));
  319. }
  320. e_wsfe();
  321. }
  322. L40:
  323. if (*n < 1 || *n > icntl[4]) {
  324. goto L70;
  325. }
  326. if (*nz < 0) {
  327. goto L100;
  328. }
  329. lliw = *liw - (*n << 1);
  330. l1 = lliw + 1;
  331. l2 = l1 + *n;
  332. if (*iflag == 1) {
  333. goto L50;
  334. }
  335. if (*liw < (*nz << 1) + *n * 3 + 1) {
  336. goto L130;
  337. }
  338. /* SORT */
  339. ma27gd_(n, nz, &irn[1], &icn[1], &iw[1], &lliw, &iw1[iw1_offset], &iw1[(
  340. iw1_dim1 << 1) + 1], &iw[l1], &iwfr, &icntl[1], &info[1]);
  341. /* ANALYZE USING MINIMUM DEGREE ORDERING */
  342. ma27hd_(n, &iw1[iw1_offset], &iw[1], &lliw, &iwfr, &iw[l1], &iw[l2], &
  343. ikeep[(ikeep_dim1 << 1) + 1], &ikeep[ikeep_dim1 * 3 + 1], &ikeep[
  344. ikeep_offset], &icntl[4], &info[11], &cntl[2]);
  345. goto L60;
  346. /* SORT USING GIVEN ORDER */
  347. L50:
  348. if (*liw < *nz + *n * 3 + 1) {
  349. goto L120;
  350. }
  351. ma27jd_(n, nz, &irn[1], &icn[1], &ikeep[ikeep_offset], &iw[1], &lliw, &
  352. iw1[iw1_offset], &iw1[(iw1_dim1 << 1) + 1], &iw[l1], &iwfr, &
  353. icntl[1], &info[1]);
  354. /* ANALYZE USING GIVEN ORDER */
  355. ma27kd_(n, &iw1[iw1_offset], &iw[1], &lliw, &iwfr, &ikeep[ikeep_offset], &
  356. ikeep[(ikeep_dim1 << 1) + 1], &iw[l1], &iw[l2], &info[11]);
  357. /* PERFORM DEPTH-FIRST SEARCH OF ASSEMBLY TREE */
  358. L60:
  359. ma27ld_(n, &iw1[iw1_offset], &iw[l1], &ikeep[ikeep_offset], &ikeep[(
  360. ikeep_dim1 << 1) + 1], &ikeep[ikeep_dim1 * 3 + 1], &iw[l2],
  361. nsteps, &icntl[5]);
  362. /* EVALUATE STORAGE AND OPERATION COUNT REQUIRED BY MA27B/BD IN THE */
  363. /* DEFINITE CASE. */
  364. /* SET IW(1) SO THAT ARRAYS IW AND IRN CAN BE TESTED FOR EQUIVALENCE */
  365. /* IN MA27M/MD. */
  366. if (*nz >= 1) {
  367. iw[1] = irn[1] + 1;
  368. }
  369. ma27md_(n, nz, &irn[1], &icn[1], &ikeep[ikeep_offset], &ikeep[ikeep_dim1 *
  370. 3 + 1], &ikeep[(ikeep_dim1 << 1) + 1], &iw[l2], nsteps, &iw1[
  371. iw1_offset], &iw1[(iw1_dim1 << 1) + 1], &iw[1], &info[1], ops);
  372. goto L160;
  373. L70:
  374. info[1] = -1;
  375. if (icntl[1] > 0) {
  376. io___10.ciunit = icntl[1];
  377. s_wsfe(&io___10);
  378. do_fio(&c__1, (char *)&info[1], (ftnlen)sizeof(integer));
  379. e_wsfe();
  380. }
  381. if (icntl[1] > 0) {
  382. io___11.ciunit = icntl[1];
  383. s_wsfe(&io___11);
  384. do_fio(&c__1, (char *)&(*n), (ftnlen)sizeof(integer));
  385. e_wsfe();
  386. }
  387. goto L160;
  388. L100:
  389. info[1] = -2;
  390. if (icntl[1] > 0) {
  391. io___12.ciunit = icntl[1];
  392. s_wsfe(&io___12);
  393. do_fio(&c__1, (char *)&info[1], (ftnlen)sizeof(integer));
  394. e_wsfe();
  395. }
  396. if (icntl[1] > 0) {
  397. io___13.ciunit = icntl[1];
  398. s_wsfe(&io___13);
  399. do_fio(&c__1, (char *)&(*nz), (ftnlen)sizeof(integer));
  400. e_wsfe();
  401. }
  402. goto L160;
  403. L120:
  404. info[2] = *nz + *n * 3 + 1;
  405. goto L140;
  406. L130:
  407. info[2] = (*nz << 1) + *n * 3 + 1;
  408. L140:
  409. info[1] = -3;
  410. if (icntl[1] > 0) {
  411. io___14.ciunit = icntl[1];
  412. s_wsfe(&io___14);
  413. do_fio(&c__1, (char *)&info[1], (ftnlen)sizeof(integer));
  414. e_wsfe();
  415. }
  416. if (icntl[1] > 0) {
  417. io___15.ciunit = icntl[1];
  418. s_wsfe(&io___15);
  419. do_fio(&c__1, (char *)&(*liw), (ftnlen)sizeof(integer));
  420. do_fio(&c__1, (char *)&info[2], (ftnlen)sizeof(integer));
  421. e_wsfe();
  422. }
  423. L160:
  424. if (icntl[3] <= 0 || icntl[2] <= 0 || info[1] < 0) {
  425. goto L200;
  426. }
  427. /* PRINT PARAMETER VALUES ON EXIT. */
  428. io___16.ciunit = icntl[2];
  429. s_wsfe(&io___16);
  430. do_fio(&c__1, (char *)&(*nsteps), (ftnlen)sizeof(integer));
  431. do_fio(&c__1, (char *)&info[1], (ftnlen)sizeof(integer));
  432. do_fio(&c__1, (char *)&(*ops), (ftnlen)sizeof(doublereal));
  433. do_fio(&c__1, (char *)&info[2], (ftnlen)sizeof(integer));
  434. do_fio(&c__1, (char *)&info[3], (ftnlen)sizeof(integer));
  435. do_fio(&c__1, (char *)&info[4], (ftnlen)sizeof(integer));
  436. do_fio(&c__1, (char *)&info[5], (ftnlen)sizeof(integer));
  437. do_fio(&c__1, (char *)&info[6], (ftnlen)sizeof(integer));
  438. do_fio(&c__1, (char *)&info[7], (ftnlen)sizeof(integer));
  439. do_fio(&c__1, (char *)&info[8], (ftnlen)sizeof(integer));
  440. do_fio(&c__1, (char *)&info[11], (ftnlen)sizeof(integer));
  441. e_wsfe();
  442. k = min(9,*n);
  443. if (icntl[3] > 1) {
  444. k = *n;
  445. }
  446. if (k > 0) {
  447. io___17.ciunit = icntl[2];
  448. s_wsfe(&io___17);
  449. i__1 = k;
  450. for (i__ = 1; i__ <= i__1; ++i__) {
  451. do_fio(&c__1, (char *)&ikeep[i__ + ikeep_dim1], (ftnlen)sizeof(
  452. integer));
  453. }
  454. e_wsfe();
  455. }
  456. k = min(k,*nsteps);
  457. if (k > 0) {
  458. io___18.ciunit = icntl[2];
  459. s_wsfe(&io___18);
  460. i__1 = k;
  461. for (i__ = 1; i__ <= i__1; ++i__) {
  462. do_fio(&c__1, (char *)&ikeep[i__ + (ikeep_dim1 << 1)], (ftnlen)
  463. sizeof(integer));
  464. }
  465. e_wsfe();
  466. }
  467. if (k > 0) {
  468. io___19.ciunit = icntl[2];
  469. s_wsfe(&io___19);
  470. i__1 = k;
  471. for (i__ = 1; i__ <= i__1; ++i__) {
  472. do_fio(&c__1, (char *)&ikeep[i__ + ikeep_dim1 * 3], (ftnlen)
  473. sizeof(integer));
  474. }
  475. e_wsfe();
  476. }
  477. L200:
  478. return 0;
  479. } /* ma27ad_ */
  480. /* Subroutine */ int ma27bd_(integer *n, integer *nz, integer *irn, integer *
  481. icn, doublereal *a, integer *la, integer *iw, integer *liw, integer *
  482. ikeep, integer *nsteps, integer *maxfrt, integer *iw1, integer *icntl,
  483. doublereal *cntl, integer *info)
  484. {
  485. /* Format strings */
  486. static char fmt_10[] = "(/,/,\002 ENTERING MA27BD WITH N NZ "
  487. " LA LIW\002,\002 NSTEPS U\002,/,21x,i7,i7,i9,i9,i7,1"
  488. "pd10.2)";
  489. static char fmt_20[] = "(\002 MATRIX NON-ZEROS\002,/,1x,2(1p,d16.3,2i6),"
  490. "/,(1x,1p,d16.3,2i6,1p,d16.3,2i6))";
  491. static char fmt_30[] = "(\002 IKEEP(.,1)=\002,10i6,/,(12x,10i6))";
  492. static char fmt_40[] = "(\002 IKEEP(.,2)=\002,10i6,/,(12x,10i6))";
  493. static char fmt_50[] = "(\002 IKEEP(.,3)=\002,10i6,/,(12x,10i6))";
  494. static char fmt_65[] = "(\002 *** WARNING MESSAGE FROM SUBROUTINE MA27B"
  495. "D\002,\002 *** INFO(1) =\002,i2,/,5x,\002MATRIX IS SINGULAR. RA"
  496. "NK=\002,i5)";
  497. static char fmt_80[] = "(\002 **** ERROR RETURN FROM MA27BD **** INFO("
  498. "1)=\002,i3)";
  499. static char fmt_90[] = "(\002 VALUE OF N OUT OF RANGE ... =\002,i10)";
  500. static char fmt_110[] = "(\002 VALUE OF NZ OUT OF RANGE .. =\002,i10)";
  501. static char fmt_140[] = "(\002 LIW TOO SMALL, MUST BE INCREASED FROM\002"
  502. ",i10,\002 TO\002,\002 AT LEAST\002,i10)";
  503. static char fmt_170[] = "(\002 LA TOO SMALL, MUST BE INCREASED FROM \002"
  504. ",i10,\002 TO\002,\002 AT LEAST\002,i10)";
  505. static char fmt_190[] = "(\002 ZERO PIVOT AT STAGE\002,i10,\002 WHEN INP"
  506. "UT MATRIX DECLARED DEFINITE\002)";
  507. static char fmt_210[] = "(\002 CHANGE IN SIGN OF PIVOT ENCOUNTERED\002"
  508. ",\002 WHEN FACTORING ALLEGEDLY DEFINITE MATRIX\002)";
  509. static char fmt_230[] = "(/,\002 LEAVING MA27BD WITH\002,/,10x,\002 MAX"
  510. "FRT INFO(1) NRLBDU NIRBDU NCMPBR\002,\002 NCMPBI NTWO IERRO"
  511. "R\002,/,11x,8i7)";
  512. static char fmt_250[] = "(\002 BLOCK PIVOT =\002,i8,\002 NROWS =\002,i8"
  513. ",\002 NCOLS =\002,i8)";
  514. static char fmt_260[] = "(\002 COLUMN INDICES =\002,10i6,/,(17x,10i6))";
  515. static char fmt_270[] = "(\002 REAL ENTRIES .. EACH ROW STARTS ON A NEW "
  516. "LINE\002)";
  517. static char fmt_280[] = "(1p,5d13.3)";
  518. /* System generated locals */
  519. integer ikeep_dim1, ikeep_offset, i__1, i__2, i__3;
  520. /* Builtin functions */
  521. integer s_wsfe(cilist *), do_fio(integer *, char *, ftnlen), e_wsfe(void);
  522. /* Local variables */
  523. static integer i__, k, j1, j2, jj, kz, nz1, len, iblk, kblk, ipos;
  524. extern /* Subroutine */ int ma27nd_(integer *, integer *, integer *,
  525. doublereal *, integer *, integer *, integer *, integer *, integer
  526. *, integer *, integer *, integer *, integer *), ma27od_(integer *,
  527. integer *, doublereal *, integer *, integer *, integer *,
  528. integer *, integer *, integer *, integer *, integer *, integer *,
  529. integer *, doublereal *, integer *);
  530. static integer iapos, ncols, irows, nrows;
  531. /* Fortran I/O blocks */
  532. static cilist io___20 = { 0, 0, 0, fmt_10, 0 };
  533. static cilist io___22 = { 0, 0, 0, fmt_20, 0 };
  534. static cilist io___24 = { 0, 0, 0, fmt_30, 0 };
  535. static cilist io___26 = { 0, 0, 0, fmt_40, 0 };
  536. static cilist io___27 = { 0, 0, 0, fmt_50, 0 };
  537. static cilist io___29 = { 0, 0, 0, fmt_65, 0 };
  538. static cilist io___30 = { 0, 0, 0, fmt_80, 0 };
  539. static cilist io___31 = { 0, 0, 0, fmt_90, 0 };
  540. static cilist io___32 = { 0, 0, 0, fmt_80, 0 };
  541. static cilist io___33 = { 0, 0, 0, fmt_110, 0 };
  542. static cilist io___34 = { 0, 0, 0, fmt_80, 0 };
  543. static cilist io___35 = { 0, 0, 0, fmt_140, 0 };
  544. static cilist io___36 = { 0, 0, 0, fmt_80, 0 };
  545. static cilist io___37 = { 0, 0, 0, fmt_170, 0 };
  546. static cilist io___38 = { 0, 0, 0, fmt_80, 0 };
  547. static cilist io___39 = { 0, 0, 0, "(A)", 0 };
  548. static cilist io___40 = { 0, 0, 0, fmt_80, 0 };
  549. static cilist io___41 = { 0, 0, 0, fmt_190, 0 };
  550. static cilist io___42 = { 0, 0, 0, fmt_80, 0 };
  551. static cilist io___43 = { 0, 0, 0, fmt_210, 0 };
  552. static cilist io___44 = { 0, 0, 0, fmt_230, 0 };
  553. static cilist io___52 = { 0, 0, 0, fmt_250, 0 };
  554. static cilist io___54 = { 0, 0, 0, fmt_260, 0 };
  555. static cilist io___56 = { 0, 0, 0, fmt_270, 0 };
  556. static cilist io___59 = { 0, 0, 0, fmt_280, 0 };
  557. /* THIS SUBROUTINE COMPUTES THE FACTORISATION OF THE MATRIX INPUT IN */
  558. /* A,IRN,ICN USING INFORMATION (IN IKEEP) FROM MA27A/AD. */
  559. /* N MUST BE SET TO THE ORDER OF THE MATRIX. IT IS NOT ALTERED. */
  560. /* NZ MUST BE SET TO THE NUMBER OF NON-ZEROS INPUT. IT IS NOT */
  561. /* ALTERED. */
  562. /* IRN,ICN,A. ENTRY K (K=1,NZ) OF IRN,ICN MUST BE SET TO THE ROW */
  563. /* AND COLUMN INDEX RESPECTIVELY OF THE NON-ZERO IN A. */
  564. /* IRN AND ICN ARE UNALTERED BY MA27B/BD. */
  565. /* ON EXIT, ENTRIES 1 TO NRLBDU OF A HOLD REAL INFORMATION */
  566. /* ON THE FACTORS AND SHOULD BE PASSED UNCHANGED TO MA27C/CD. */
  567. /* LA LENGTH OF ARRAY A. AN INDICATION OF A SUITABLE VALUE, */
  568. /* SUFFICIENT FOR FACTORIZATION OF A DEFINITE MATRIX, WILL */
  569. /* HAVE BEEN PROVIDED IN NRLNEC AND NRLTOT BY MA27A/AD. */
  570. /* IT IS NOT ALTERED BY MA27B/BD. */
  571. /* IW NEED NOT BE SET ON ENTRY. USED AS A WORK ARRAY BY MA27B/BD. */
  572. /* ON EXIT, ENTRIES 1 TO NIRBDU HOLD INTEGER INFORMATION ON THE */
  573. /* FACTORS AND SHOULD BE PASSED UNCHANGED TO MA27C/CD. */
  574. /* LIW LENGTH OF ARRAY IW. AN INDICATION OF A SUITABLE VALUE WILL */
  575. /* HAVE BEEN PROVIDED IN NIRNEC AND NIRTOT BY MA27A/AD. */
  576. /* IT IS NOT ALTERED BY MA27B/BD. */
  577. /* IKEEP MUST BE UNCHANGED SINCE THE CALL TO MA27A/AD. */
  578. /* IT IS NOT ALTERED BY MA27B/BD. */
  579. /* NSTEPS MUST BE UNCHANGED SINCE THE CALL TO MA27A/AD. */
  580. /* IT IS NOT ALTERED BY MA27B/BD. */
  581. /* MAXFRT NEED NOT BE SET AND MUST BE PASSED UNCHANGED TO MA27C/CD. */
  582. /* IT IS THE MAXIMUM SIZE OF THE FRONTAL MATRIX GENERATED DURING */
  583. /* THE DECOMPOSITION. */
  584. /* IW1 USED AS WORKSPACE BY MA27B/BD. */
  585. /* ICNTL is an INTEGER array of length 30, see MA27A/AD. */
  586. /* CNTL is a DOUBLE PRECISION array of length 5, see MA27A/AD. */
  587. /* INFO is an INTEGER array of length 20, see MA27A/AD. */
  588. /* .. Scalar Arguments .. */
  589. /* .. */
  590. /* .. Array Arguments .. */
  591. /* .. */
  592. /* .. Local Scalars .. */
  593. /* .. */
  594. /* .. External Subroutines .. */
  595. /* .. */
  596. /* .. Intrinsic Functions .. */
  597. /* .. */
  598. /* .. Executable Statements .. */
  599. /* Parameter adjustments */
  600. --iw1;
  601. ikeep_dim1 = *n;
  602. ikeep_offset = 1 + ikeep_dim1;
  603. ikeep -= ikeep_offset;
  604. --irn;
  605. --icn;
  606. --a;
  607. --iw;
  608. --icntl;
  609. --cntl;
  610. --info;
  611. /* Function Body */
  612. info[1] = 0;
  613. if (icntl[3] <= 0 || icntl[2] <= 0) {
  614. goto L60;
  615. }
  616. /* PRINT INPUT PARAMETERS. */
  617. io___20.ciunit = icntl[2];
  618. s_wsfe(&io___20);
  619. do_fio(&c__1, (char *)&(*n), (ftnlen)sizeof(integer));
  620. do_fio(&c__1, (char *)&(*nz), (ftnlen)sizeof(integer));
  621. do_fio(&c__1, (char *)&(*la), (ftnlen)sizeof(integer));
  622. do_fio(&c__1, (char *)&(*liw), (ftnlen)sizeof(integer));
  623. do_fio(&c__1, (char *)&(*nsteps), (ftnlen)sizeof(integer));
  624. do_fio(&c__1, (char *)&cntl[1], (ftnlen)sizeof(doublereal));
  625. e_wsfe();
  626. kz = min(6,*nz);
  627. if (icntl[3] > 1) {
  628. kz = *nz;
  629. }
  630. if (*nz > 0) {
  631. io___22.ciunit = icntl[2];
  632. s_wsfe(&io___22);
  633. i__1 = kz;
  634. for (k = 1; k <= i__1; ++k) {
  635. do_fio(&c__1, (char *)&a[k], (ftnlen)sizeof(doublereal));
  636. do_fio(&c__1, (char *)&irn[k], (ftnlen)sizeof(integer));
  637. do_fio(&c__1, (char *)&icn[k], (ftnlen)sizeof(integer));
  638. }
  639. e_wsfe();
  640. }
  641. k = min(9,*n);
  642. if (icntl[3] > 1) {
  643. k = *n;
  644. }
  645. if (k > 0) {
  646. io___24.ciunit = icntl[2];
  647. s_wsfe(&io___24);
  648. i__1 = k;
  649. for (i__ = 1; i__ <= i__1; ++i__) {
  650. do_fio(&c__1, (char *)&ikeep[i__ + ikeep_dim1], (ftnlen)sizeof(
  651. integer));
  652. }
  653. e_wsfe();
  654. }
  655. k = min(k,*nsteps);
  656. if (k > 0) {
  657. io___26.ciunit = icntl[2];
  658. s_wsfe(&io___26);
  659. i__1 = k;
  660. for (i__ = 1; i__ <= i__1; ++i__) {
  661. do_fio(&c__1, (char *)&ikeep[i__ + (ikeep_dim1 << 1)], (ftnlen)
  662. sizeof(integer));
  663. }
  664. e_wsfe();
  665. }
  666. if (k > 0) {
  667. io___27.ciunit = icntl[2];
  668. s_wsfe(&io___27);
  669. i__1 = k;
  670. for (i__ = 1; i__ <= i__1; ++i__) {
  671. do_fio(&c__1, (char *)&ikeep[i__ + ikeep_dim1 * 3], (ftnlen)
  672. sizeof(integer));
  673. }
  674. e_wsfe();
  675. }
  676. L60:
  677. if (*n < 1 || *n > icntl[4]) {
  678. goto L70;
  679. }
  680. if (*nz < 0) {
  681. goto L100;
  682. }
  683. if (*liw < *nz) {
  684. goto L120;
  685. }
  686. if (*la < *nz + *n) {
  687. goto L150;
  688. }
  689. if (*nsteps < 1 || *nsteps > *n) {
  690. goto L175;
  691. }
  692. /* SORT */
  693. ma27nd_(n, nz, &nz1, &a[1], la, &irn[1], &icn[1], &iw[1], liw, &ikeep[
  694. ikeep_offset], &iw1[1], &icntl[1], &info[1]);
  695. if (info[1] == -3) {
  696. goto L130;
  697. }
  698. if (info[1] == -4) {
  699. goto L160;
  700. }
  701. /* FACTORIZE */
  702. ma27od_(n, &nz1, &a[1], la, &iw[1], liw, &ikeep[ikeep_offset], &ikeep[
  703. ikeep_dim1 * 3 + 1], nsteps, maxfrt, &ikeep[(ikeep_dim1 << 1) + 1]
  704. , &iw1[1], &icntl[1], &cntl[1], &info[1]);
  705. if (info[1] == -3) {
  706. goto L130;
  707. }
  708. if (info[1] == -4) {
  709. goto L160;
  710. }
  711. if (info[1] == -5) {
  712. goto L180;
  713. }
  714. if (info[1] == -6) {
  715. goto L200;
  716. }
  717. /* **** WARNING MESSAGE **** */
  718. if (info[1] == 3 && icntl[2] > 0) {
  719. io___29.ciunit = icntl[2];
  720. s_wsfe(&io___29);
  721. do_fio(&c__1, (char *)&info[1], (ftnlen)sizeof(integer));
  722. do_fio(&c__1, (char *)&info[2], (ftnlen)sizeof(integer));
  723. e_wsfe();
  724. }
  725. goto L220;
  726. /* **** ERROR RETURNS **** */
  727. L70:
  728. info[1] = -1;
  729. if (icntl[1] > 0) {
  730. io___30.ciunit = icntl[1];
  731. s_wsfe(&io___30);
  732. do_fio(&c__1, (char *)&info[1], (ftnlen)sizeof(integer));
  733. e_wsfe();
  734. }
  735. if (icntl[1] > 0) {
  736. io___31.ciunit = icntl[1];
  737. s_wsfe(&io___31);
  738. do_fio(&c__1, (char *)&(*n), (ftnlen)sizeof(integer));
  739. e_wsfe();
  740. }
  741. goto L220;
  742. L100:
  743. info[1] = -2;
  744. if (icntl[1] > 0) {
  745. io___32.ciunit = icntl[1];
  746. s_wsfe(&io___32);
  747. do_fio(&c__1, (char *)&info[1], (ftnlen)sizeof(integer));
  748. e_wsfe();
  749. }
  750. if (icntl[1] > 0) {
  751. io___33.ciunit = icntl[1];
  752. s_wsfe(&io___33);
  753. do_fio(&c__1, (char *)&(*nz), (ftnlen)sizeof(integer));
  754. e_wsfe();
  755. }
  756. goto L220;
  757. L120:
  758. info[1] = -3;
  759. info[2] = *nz;
  760. L130:
  761. if (icntl[1] > 0) {
  762. io___34.ciunit = icntl[1];
  763. s_wsfe(&io___34);
  764. do_fio(&c__1, (char *)&info[1], (ftnlen)sizeof(integer));
  765. e_wsfe();
  766. }
  767. if (icntl[1] > 0) {
  768. io___35.ciunit = icntl[1];
  769. s_wsfe(&io___35);
  770. do_fio(&c__1, (char *)&(*liw), (ftnlen)sizeof(integer));
  771. do_fio(&c__1, (char *)&info[2], (ftnlen)sizeof(integer));
  772. e_wsfe();
  773. }
  774. goto L220;
  775. L150:
  776. info[1] = -4;
  777. info[2] = *nz + *n;
  778. L160:
  779. if (icntl[1] > 0) {
  780. io___36.ciunit = icntl[1];
  781. s_wsfe(&io___36);
  782. do_fio(&c__1, (char *)&info[1], (ftnlen)sizeof(integer));
  783. e_wsfe();
  784. }
  785. if (icntl[1] > 0) {
  786. io___37.ciunit = icntl[1];
  787. s_wsfe(&io___37);
  788. do_fio(&c__1, (char *)&(*la), (ftnlen)sizeof(integer));
  789. do_fio(&c__1, (char *)&info[2], (ftnlen)sizeof(integer));
  790. e_wsfe();
  791. }
  792. goto L220;
  793. L175:
  794. info[1] = -7;
  795. if (icntl[1] > 0) {
  796. io___38.ciunit = icntl[1];
  797. s_wsfe(&io___38);
  798. do_fio(&c__1, (char *)&info[1], (ftnlen)sizeof(integer));
  799. e_wsfe();
  800. }
  801. if (icntl[1] > 0) {
  802. io___39.ciunit = icntl[1];
  803. s_wsfe(&io___39);
  804. do_fio(&c__1, " NSTEPS is out of range", (ftnlen)23);
  805. e_wsfe();
  806. }
  807. goto L220;
  808. L180:
  809. if (icntl[1] > 0) {
  810. io___40.ciunit = icntl[1];
  811. s_wsfe(&io___40);
  812. do_fio(&c__1, (char *)&info[1], (ftnlen)sizeof(integer));
  813. e_wsfe();
  814. }
  815. if (icntl[1] > 0) {
  816. io___41.ciunit = icntl[1];
  817. s_wsfe(&io___41);
  818. do_fio(&c__1, (char *)&info[2], (ftnlen)sizeof(integer));
  819. e_wsfe();
  820. }
  821. goto L220;
  822. L200:
  823. if (icntl[1] > 0) {
  824. io___42.ciunit = icntl[1];
  825. s_wsfe(&io___42);
  826. do_fio(&c__1, (char *)&info[1], (ftnlen)sizeof(integer));
  827. e_wsfe();
  828. }
  829. if (icntl[1] > 0) {
  830. io___43.ciunit = icntl[1];
  831. s_wsfe(&io___43);
  832. e_wsfe();
  833. }
  834. L220:
  835. if (icntl[3] <= 0 || icntl[2] <= 0 || info[1] < 0) {
  836. goto L310;
  837. }
  838. /* PRINT OUTPUT PARAMETERS. */
  839. io___44.ciunit = icntl[2];
  840. s_wsfe(&io___44);
  841. do_fio(&c__1, (char *)&(*maxfrt), (ftnlen)sizeof(integer));
  842. do_fio(&c__1, (char *)&info[1], (ftnlen)sizeof(integer));
  843. do_fio(&c__1, (char *)&info[9], (ftnlen)sizeof(integer));
  844. do_fio(&c__1, (char *)&info[10], (ftnlen)sizeof(integer));
  845. do_fio(&c__1, (char *)&info[12], (ftnlen)sizeof(integer));
  846. do_fio(&c__1, (char *)&info[13], (ftnlen)sizeof(integer));
  847. do_fio(&c__1, (char *)&info[14], (ftnlen)sizeof(integer));
  848. do_fio(&c__1, (char *)&info[2], (ftnlen)sizeof(integer));
  849. e_wsfe();
  850. if (info[1] < 0) {
  851. goto L310;
  852. }
  853. /* PRINT OUT MATRIX FACTORS FROM MA27B/BD. */
  854. kblk = abs(iw[1]);
  855. if (kblk == 0) {
  856. goto L310;
  857. }
  858. if (icntl[3] == 1) {
  859. kblk = 1;
  860. }
  861. ipos = 2;
  862. iapos = 1;
  863. i__1 = kblk;
  864. for (iblk = 1; iblk <= i__1; ++iblk) {
  865. ncols = iw[ipos];
  866. nrows = iw[ipos + 1];
  867. j1 = ipos + 2;
  868. if (ncols > 0) {
  869. goto L240;
  870. }
  871. ncols = -ncols;
  872. nrows = 1;
  873. --j1;
  874. L240:
  875. io___52.ciunit = icntl[2];
  876. s_wsfe(&io___52);
  877. do_fio(&c__1, (char *)&iblk, (ftnlen)sizeof(integer));
  878. do_fio(&c__1, (char *)&nrows, (ftnlen)sizeof(integer));
  879. do_fio(&c__1, (char *)&ncols, (ftnlen)sizeof(integer));
  880. e_wsfe();
  881. j2 = j1 + ncols - 1;
  882. ipos = j2 + 1;
  883. io___54.ciunit = icntl[2];
  884. s_wsfe(&io___54);
  885. i__2 = j2;
  886. for (jj = j1; jj <= i__2; ++jj) {
  887. do_fio(&c__1, (char *)&iw[jj], (ftnlen)sizeof(integer));
  888. }
  889. e_wsfe();
  890. io___56.ciunit = icntl[2];
  891. s_wsfe(&io___56);
  892. e_wsfe();
  893. len = ncols;
  894. i__2 = nrows;
  895. for (irows = 1; irows <= i__2; ++irows) {
  896. j1 = iapos;
  897. j2 = iapos + len - 1;
  898. io___59.ciunit = icntl[2];
  899. s_wsfe(&io___59);
  900. i__3 = j2;
  901. for (jj = j1; jj <= i__3; ++jj) {
  902. do_fio(&c__1, (char *)&a[jj], (ftnlen)sizeof(doublereal));
  903. }
  904. e_wsfe();
  905. --len;
  906. iapos = j2 + 1;
  907. /* L290: */
  908. }
  909. /* L300: */
  910. }
  911. L310:
  912. return 0;
  913. } /* ma27bd_ */
  914. /* Subroutine */ int ma27cd_(integer *n, doublereal *a, integer *la, integer *
  915. iw, integer *liw, doublereal *w, integer *maxfrt, doublereal *rhs,
  916. integer *iw1, integer *nsteps, integer *icntl, integer *info)
  917. {
  918. /* Format strings */
  919. static char fmt_10[] = "(/,/,\002 ENTERING MA27CD WITH N LA "
  920. "LIW MAXFRT\002,\002 NSTEPS\002,/,21x,5i7)";
  921. static char fmt_30[] = "(\002 BLOCK PIVOT =\002,i8,\002 NROWS =\002,i8"
  922. ",\002 NCOLS =\002,i8)";
  923. static char fmt_40[] = "(\002 COLUMN INDICES =\002,10i6,/,(17x,10i6))";
  924. static char fmt_50[] = "(\002 REAL ENTRIES .. EACH ROW STARTS ON A NEW L"
  925. "INE\002)";
  926. static char fmt_60[] = "(1p,5d13.3)";
  927. static char fmt_100[] = "(\002 RHS\002,1p,5d13.3,/,(4x,1p,5d13.3))";
  928. static char fmt_160[] = "(/,/,\002 LEAVING MA27CD WITH\002)";
  929. /* System generated locals */
  930. integer i__1, i__2, i__3;
  931. /* Builtin functions */
  932. integer s_wsfe(cilist *), do_fio(integer *, char *, ftnlen), e_wsfe(void);
  933. /* Local variables */
  934. static integer i__, k, j1, j2, jj, len, iblk, kblk, nblk, ipos;
  935. extern /* Subroutine */ int ma27qd_(integer *, doublereal *, integer *,
  936. integer *, integer *, doublereal *, integer *, doublereal *,
  937. integer *, integer *, integer *, integer *), ma27rd_(integer *,
  938. doublereal *, integer *, integer *, integer *, doublereal *,
  939. integer *, doublereal *, integer *, integer *, integer *, integer
  940. *);
  941. static integer iapos, ncols, latop, irows, nrows;
  942. /* Fortran I/O blocks */
  943. static cilist io___60 = { 0, 0, 0, fmt_10, 0 };
  944. static cilist io___68 = { 0, 0, 0, fmt_30, 0 };
  945. static cilist io___70 = { 0, 0, 0, fmt_40, 0 };
  946. static cilist io___72 = { 0, 0, 0, fmt_50, 0 };
  947. static cilist io___75 = { 0, 0, 0, fmt_60, 0 };
  948. static cilist io___77 = { 0, 0, 0, fmt_100, 0 };
  949. static cilist io___81 = { 0, 0, 0, fmt_160, 0 };
  950. static cilist io___82 = { 0, 0, 0, fmt_100, 0 };
  951. /* THIS SUBROUTINE USES THE FACTORISATION OF THE MATRIX IN A,IW TO */
  952. /* SOLVE A SYSTEM OF EQUATIONS. */
  953. /* N MUST BE SET TO THE ORDER OF THE MATRIX. IT IS NOT ALTERED. */
  954. /* A,IW HOLD INFORMATION ON THE FACTORS AND MUST BE UNCHANGED SINCE */
  955. /* THE CALL TO MA27B/BD. THEY ARE NOT ALTERED BY MA27C/CDD. */
  956. /* LA,LIW MUST BE SET TO THE LENGTHS OF A,IW RESPECTIVELY. THEY */
  957. /* ARE NOT ALTERED. */
  958. /* W USED AS A WORK ARRAY. */
  959. /* MAXFRT IS THE LENGTH OF W AND MUST BE PASSED UNCHANGED FROM THE */
  960. /* CALL TO MA27B/BD. IT IS NOT ALTERED. */
  961. /* RHS MUST BE SET TO THE RIGHT HAND SIDE FOR THE EQUATIONS BEING */
  962. /* SOLVED. ON EXIT, THIS ARRAY WILL HOLD THE SOLUTION. */
  963. /* IW1 USED AS A WORK ARRAY. */
  964. /* NSTEPS IS THE LENGTH OF IW1 WHICH MUST BE AT LEAST THE ABSOLUTE */
  965. /* VALUE OF IW(1). IT IS NOT ALTERED. */
  966. /* ICNTL is an INTEGER array of length 30, see MA27A/AD. */
  967. /* INFO is an INTEGER array of length 20, see MA27A/AD. */
  968. /* .. Scalar Arguments .. */
  969. /* .. */
  970. /* .. Array Arguments .. */
  971. /* .. */
  972. /* .. Local Scalars .. */
  973. /* .. */
  974. /* .. External Subroutines .. */
  975. /* .. */
  976. /* .. Intrinsic Functions .. */
  977. /* .. */
  978. /* .. Executable Statements .. */
  979. /* Parameter adjustments */
  980. --rhs;
  981. --a;
  982. --iw;
  983. --w;
  984. --iw1;
  985. --icntl;
  986. --info;
  987. /* Function Body */
  988. info[1] = 0;
  989. if (icntl[3] <= 0 || icntl[2] <= 0) {
  990. goto L110;
  991. }
  992. /* PRINT INPUT PARAMETERS. */
  993. io___60.ciunit = icntl[2];
  994. s_wsfe(&io___60);
  995. do_fio(&c__1, (char *)&(*n), (ftnlen)sizeof(integer));
  996. do_fio(&c__1, (char *)&(*la), (ftnlen)sizeof(integer));
  997. do_fio(&c__1, (char *)&(*liw), (ftnlen)sizeof(integer));
  998. do_fio(&c__1, (char *)&(*maxfrt), (ftnlen)sizeof(integer));
  999. do_fio(&c__1, (char *)&(*nsteps), (ftnlen)sizeof(integer));
  1000. e_wsfe();
  1001. /* PRINT OUT MATRIX FACTORS FROM MA27B/BD. */
  1002. kblk = abs(iw[1]);
  1003. if (kblk == 0) {
  1004. goto L90;
  1005. }
  1006. if (icntl[3] == 1) {
  1007. kblk = 1;
  1008. }
  1009. ipos = 2;
  1010. iapos = 1;
  1011. i__1 = kblk;
  1012. for (iblk = 1; iblk <= i__1; ++iblk) {
  1013. ncols = iw[ipos];
  1014. nrows = iw[ipos + 1];
  1015. j1 = ipos + 2;
  1016. if (ncols > 0) {
  1017. goto L20;
  1018. }
  1019. ncols = -ncols;
  1020. nrows = 1;
  1021. --j1;
  1022. L20:
  1023. io___68.ciunit = icntl[2];
  1024. s_wsfe(&io___68);
  1025. do_fio(&c__1, (char *)&iblk, (ftnlen)sizeof(integer));
  1026. do_fio(&c__1, (char *)&nrows, (ftnlen)sizeof(integer));
  1027. do_fio(&c__1, (char *)&ncols, (ftnlen)sizeof(integer));
  1028. e_wsfe();
  1029. j2 = j1 + ncols - 1;
  1030. ipos = j2 + 1;
  1031. io___70.ciunit = icntl[2];
  1032. s_wsfe(&io___70);
  1033. i__2 = j2;
  1034. for (jj = j1; jj <= i__2; ++jj) {
  1035. do_fio(&c__1, (char *)&iw[jj], (ftnlen)sizeof(integer));
  1036. }
  1037. e_wsfe();
  1038. io___72.ciunit = icntl[2];
  1039. s_wsfe(&io___72);
  1040. e_wsfe();
  1041. len = ncols;
  1042. i__2 = nrows;
  1043. for (irows = 1; irows <= i__2; ++irows) {
  1044. j1 = iapos;
  1045. j2 = iapos + len - 1;
  1046. io___75.ciunit = icntl[2];
  1047. s_wsfe(&io___75);
  1048. i__3 = j2;
  1049. for (jj = j1; jj <= i__3; ++jj) {
  1050. do_fio(&c__1, (char *)&a[jj], (ftnlen)sizeof(doublereal));
  1051. }
  1052. e_wsfe();
  1053. --len;
  1054. iapos = j2 + 1;
  1055. /* L70: */
  1056. }
  1057. /* L80: */
  1058. }
  1059. L90:
  1060. k = min(10,*n);
  1061. if (icntl[3] > 1) {
  1062. k = *n;
  1063. }
  1064. if (*n > 0) {
  1065. io___77.ciunit = icntl[2];
  1066. s_wsfe(&io___77);
  1067. i__1 = k;
  1068. for (i__ = 1; i__ <= i__1; ++i__) {
  1069. do_fio(&c__1, (char *)&rhs[i__], (ftnlen)sizeof(doublereal));
  1070. }
  1071. e_wsfe();
  1072. }
  1073. L110:
  1074. if (iw[1] < 0) {
  1075. goto L130;
  1076. }
  1077. nblk = iw[1];
  1078. if (nblk > 0) {
  1079. goto L140;
  1080. }
  1081. /* WE HAVE A ZERO MATRIX */
  1082. i__1 = *n;
  1083. for (i__ = 1; i__ <= i__1; ++i__) {
  1084. rhs[i__] = 0.;
  1085. /* L120: */
  1086. }
  1087. goto L150;
  1088. L130:
  1089. nblk = -iw[1];
  1090. /* FORWARD SUBSTITUTION */
  1091. L140:
  1092. i__1 = *liw - 1;
  1093. ma27qd_(n, &a[1], la, &iw[2], &i__1, &w[1], maxfrt, &rhs[1], &iw1[1], &
  1094. nblk, &latop, &icntl[1]);
  1095. /* BACK SUBSTITUTION. */
  1096. i__1 = *liw - 1;
  1097. ma27rd_(n, &a[1], la, &iw[2], &i__1, &w[1], maxfrt, &rhs[1], &iw1[1], &
  1098. nblk, &latop, &icntl[1]);
  1099. L150:
  1100. if (icntl[3] <= 0 || icntl[2] <= 0) {
  1101. goto L170;
  1102. }
  1103. /* PRINT OUTPUT PARAMETERS. */
  1104. io___81.ciunit = icntl[2];
  1105. s_wsfe(&io___81);
  1106. e_wsfe();
  1107. if (*n > 0) {
  1108. io___82.ciunit = icntl[2];
  1109. s_wsfe(&io___82);
  1110. i__1 = k;
  1111. for (i__ = 1; i__ <= i__1; ++i__) {
  1112. do_fio(&c__1, (char *)&rhs[i__], (ftnlen)sizeof(doublereal));
  1113. }
  1114. e_wsfe();
  1115. }
  1116. L170:
  1117. return 0;
  1118. } /* ma27cd_ */
  1119. /* Subroutine */ int ma27gd_(integer *n, integer *nz, integer *irn, integer *
  1120. icn, integer *iw, integer *lw, integer *ipe, integer *iq, integer *
  1121. flag__, integer *iwfr, integer *icntl, integer *info)
  1122. {
  1123. /* Format strings */
  1124. static char fmt_60[] = "(\002 *** WARNING MESSAGE FROM SUBROUTINE MA27A"
  1125. "D\002,\002 *** INFO(1) =\002,i2)";
  1126. static char fmt_70[] = "(i6,\002TH NON-ZERO (IN ROW\002,i6,\002 AND COLU"
  1127. "MN\002,i6,\002) IGNORED\002)";
  1128. /* System generated locals */
  1129. integer i__1, i__2;
  1130. /* Builtin functions */
  1131. integer s_wsfe(cilist *), do_fio(integer *, char *, ftnlen), e_wsfe(void);
  1132. /* Local variables */
  1133. static integer i__, j, k, l, k1, k2, n1, id, jn, lr, last, ndup;
  1134. /* Fortran I/O blocks */
  1135. static cilist io___87 = { 0, 0, 0, fmt_60, 0 };
  1136. static cilist io___88 = { 0, 0, 0, fmt_70, 0 };
  1137. /* SORT PRIOR TO CALLING ANALYSIS ROUTINE MA27H/HD. */
  1138. /* GIVEN THE POSITIONS OF THE OFF-DIAGONAL NON-ZEROS OF A SYMMETRIC */
  1139. /* MATRIX, CONSTRUCT THE SPARSITY PATTERN OF THE OFF-DIAGONAL */
  1140. /* PART OF THE WHOLE MATRIX (UPPER AND LOWER TRIANGULAR PARTS). */
  1141. /* EITHER ONE OF A PAIR (I,J),(J,I) MAY BE USED TO REPRESENT */
  1142. /* THE PAIR. DIAGONAL ELEMENTS AND DUPLICATES ARE IGNORED. */
  1143. /* N MUST BE SET TO THE MATRIX ORDER. IT IS NOT ALTERED. */
  1144. /* NZ MUST BE SET TO THE NUMBER OF NON-ZEROS INPUT. IT IS NOT */
  1145. /* ALTERED. */
  1146. /* IRN(I),I=1,2,...,NZ MUST BE SET TO THE ROW NUMBERS OF THE */
  1147. /* NON-ZEROS ON INPUT. IT IS NOT ALTERED UNLESS IT IS EQUIVALENCED */
  1148. /* TO IW (SEE DESCRIPTION OF IW). */
  1149. /* ICN(I),I=1,2,...,NZ MUST BE SET TO THE COLUMN NUMBERS OF THE */
  1150. /* NON-ZEROS ON INPUT. IT IS NOT ALTERED UNLESS IT IS EQUIVALENCED */
  1151. /* TO IW (SEE DESCRIPTION OF IW). */
  1152. /* IW NEED NOT BE SET ON INPUT. ON OUTPUT IT CONTAINS LISTS OF */
  1153. /* COLUMN INDICES, EACH LIST BEING HEADED BY ITS LENGTH. */
  1154. /* IRN(1) MAY BE EQUIVALENCED TO IW(1) AND ICN(1) MAY BE */
  1155. /* EQUIVALENCED TO IW(K), WHERE K.GT.NZ. */
  1156. /* LW MUST BE SET TO THE LENGTH OF IW. IT MUST BE AT LEAST 2*NZ+N. */
  1157. /* IT IS NOT ALTERED. */
  1158. /* IPE NEED NOT BE SET ON INPUT. ON OUTPUT IPE(I) POINTS TO THE START OF */
  1159. /* THE ENTRY IN IW FOR ROW I, OR IS ZERO IF THERE IS NO ENTRY. */
  1160. /* IQ NEED NOT BE SET. ON OUTPUT IQ(I),I=1,N CONTAINS THE NUMBER OF */
  1161. /* OFF-DIAGONAL N0N-ZEROS IN ROW I INCLUDING DUPLICATES. */
  1162. /* FLAG IS USED FOR WORKSPACE TO HOLD FLAGS TO PERMIT DUPLICATE ENTRIES */
  1163. /* TO BE IDENTIFIED QUICKLY. */
  1164. /* IWFR NEED NOT BE SET ON INPUT. ON OUTPUT IT POINTS TO THE FIRST */
  1165. /* UNUSED LOCATION IN IW. */
  1166. /* ICNTL is an INTEGER array of length 30, see MA27A/AD. */
  1167. /* INFO is an INTEGER array of length 20, see MA27A/AD. */
  1168. /* .. Scalar Arguments .. */
  1169. /* .. */
  1170. /* .. Array Arguments .. */
  1171. /* .. */
  1172. /* .. Local Scalars .. */
  1173. /* .. */
  1174. /* .. Executable Statements .. */
  1175. /* INITIALIZE INFO(2) AND COUNT IN IPE THE */
  1176. /* NUMBERS OF NON-ZEROS IN THE ROWS AND MOVE ROW AND COLUMN */
  1177. /* NUMBERS INTO IW. */
  1178. /* Parameter adjustments */
  1179. --flag__;
  1180. --iq;
  1181. --ipe;
  1182. --irn;
  1183. --icn;
  1184. --iw;
  1185. --icntl;
  1186. --info;
  1187. /* Function Body */
  1188. info[2] = 0;
  1189. i__1 = *n;
  1190. for (i__ = 1; i__ <= i__1; ++i__) {
  1191. ipe[i__] = 0;
  1192. /* L10: */
  1193. }
  1194. lr = *nz;
  1195. if (*nz == 0) {
  1196. goto L120;
  1197. }
  1198. i__1 = *nz;
  1199. for (k = 1; k <= i__1; ++k) {
  1200. i__ = irn[k];
  1201. j = icn[k];
  1202. if (i__ < j) {
  1203. if (i__ >= 1 && j <= *n) {
  1204. goto L90;
  1205. }
  1206. } else if (i__ > j) {
  1207. if (j >= 1 && i__ <= *n) {
  1208. goto L90;
  1209. }
  1210. } else {
  1211. if (i__ >= 1 && i__ <= *n) {
  1212. goto L80;
  1213. }
  1214. }
  1215. ++info[2];
  1216. info[1] = 1;
  1217. if (info[2] <= 1 && icntl[2] > 0) {
  1218. io___87.ciunit = icntl[2];
  1219. s_wsfe(&io___87);
  1220. do_fio(&c__1, (char *)&info[1], (ftnlen)sizeof(integer));
  1221. e_wsfe();
  1222. }
  1223. if (info[2] <= 10 && icntl[2] > 0) {
  1224. io___88.ciunit = icntl[2];
  1225. s_wsfe(&io___88);
  1226. do_fio(&c__1, (char *)&k, (ftnlen)sizeof(integer));
  1227. do_fio(&c__1, (char *)&i__, (ftnlen)sizeof(integer));
  1228. do_fio(&c__1, (char *)&j, (ftnlen)sizeof(integer));
  1229. e_wsfe();
  1230. }
  1231. L80:
  1232. i__ = 0;
  1233. j = 0;
  1234. goto L100;
  1235. L90:
  1236. ++ipe[i__];
  1237. ++ipe[j];
  1238. L100:
  1239. iw[k] = j;
  1240. ++lr;
  1241. iw[lr] = i__;
  1242. /* L110: */
  1243. }
  1244. /* ACCUMULATE ROW COUNTS TO GET POINTERS TO ROW STARTS IN BOTH IPE AND IQ */
  1245. /* AND INITIALIZE FLAG */
  1246. L120:
  1247. iq[1] = 1;
  1248. n1 = *n - 1;
  1249. if (n1 <= 0) {
  1250. goto L140;
  1251. }
  1252. i__1 = n1;
  1253. for (i__ = 1; i__ <= i__1; ++i__) {
  1254. flag__[i__] = 0;
  1255. if (ipe[i__] == 0) {
  1256. ipe[i__] = -1;
  1257. }
  1258. iq[i__ + 1] = ipe[i__] + iq[i__] + 1;
  1259. ipe[i__] = iq[i__];
  1260. /* L130: */
  1261. }
  1262. L140:
  1263. last = ipe[*n] + iq[*n];
  1264. flag__[*n] = 0;
  1265. if (lr >= last) {
  1266. goto L160;
  1267. }
  1268. k1 = lr + 1;
  1269. i__1 = last;
  1270. for (k = k1; k <= i__1; ++k) {
  1271. iw[k] = 0;
  1272. /* L150: */
  1273. }
  1274. L160:
  1275. ipe[*n] = iq[*n];
  1276. *iwfr = last + 1;
  1277. if (*nz == 0) {
  1278. goto L230;
  1279. }
  1280. /* RUN THROUGH PUTTING THE MATRIX ELEMENTS IN THE RIGHT PLACE */
  1281. /* BUT WITH SIGNS INVERTED. IQ IS USED FOR HOLDING RUNNING POINTERS */
  1282. /* AND IS LEFT HOLDING POINTERS TO ROW ENDS. */
  1283. i__1 = *nz;
  1284. for (k = 1; k <= i__1; ++k) {
  1285. j = iw[k];
  1286. if (j <= 0) {
  1287. goto L220;
  1288. }
  1289. l = k;
  1290. iw[k] = 0;
  1291. i__2 = *nz;
  1292. for (id = 1; id <= i__2; ++id) {
  1293. if (l > *nz) {
  1294. goto L170;
  1295. }
  1296. l += *nz;
  1297. goto L180;
  1298. L170:
  1299. l -= *nz;
  1300. L180:
  1301. i__ = iw[l];
  1302. iw[l] = 0;
  1303. if (i__ < j) {
  1304. goto L190;
  1305. }
  1306. l = iq[j] + 1;
  1307. iq[j] = l;
  1308. jn = iw[l];
  1309. iw[l] = -i__;
  1310. goto L200;
  1311. L190:
  1312. l = iq[i__] + 1;
  1313. iq[i__] = l;
  1314. jn = iw[l];
  1315. iw[l] = -j;
  1316. L200:
  1317. j = jn;
  1318. if (j <= 0) {
  1319. goto L220;
  1320. }
  1321. /* L210: */
  1322. }
  1323. L220:
  1324. ;
  1325. }
  1326. /* RUN THROUGH RESTORING SIGNS, REMOVING DUPLICATES AND SETTING THE */
  1327. /* MATE OF EACH NON-ZERO. */
  1328. /* NDUP COUNTS THE NUMBER OF DUPLICATE ELEMENTS. */
  1329. L230:
  1330. ndup = 0;
  1331. i__1 = *n;
  1332. for (i__ = 1; i__ <= i__1; ++i__) {
  1333. k1 = ipe[i__] + 1;
  1334. k2 = iq[i__];
  1335. if (k1 <= k2) {
  1336. goto L240;
  1337. }
  1338. /* ROW IS EMPTY. SET POINTER TO ZERO. */
  1339. ipe[i__] = 0;
  1340. iq[i__] = 0;
  1341. goto L280;
  1342. /* ON ENTRY TO THIS LOOP FLAG(J).LT.I FOR J=1,2,...,N. DURING THE LOOP */
  1343. /* FLAG(J) IS SET TO I IF A NON-ZERO IN COLUMN J IS FOUND. THIS */
  1344. /* PERMITS DUPLICATES TO BE RECOGNIZED QUICKLY. */
  1345. L240:
  1346. i__2 = k2;
  1347. for (k = k1; k <= i__2; ++k) {
  1348. j = -iw[k];
  1349. if (j <= 0) {
  1350. goto L270;
  1351. }
  1352. l = iq[j] + 1;
  1353. iq[j] = l;
  1354. iw[l] = i__;
  1355. iw[k] = j;
  1356. if (flag__[j] != i__) {
  1357. goto L250;
  1358. }
  1359. ++ndup;
  1360. iw[l] = 0;
  1361. iw[k] = 0;
  1362. L250:
  1363. flag__[j] = i__;
  1364. /* L260: */
  1365. }
  1366. L270:
  1367. iq[i__] -= ipe[i__];
  1368. if (ndup == 0) {
  1369. iw[k1 - 1] = iq[i__];
  1370. }
  1371. L280:
  1372. ;
  1373. }
  1374. if (ndup == 0) {
  1375. goto L310;
  1376. }
  1377. /* COMPRESS IW TO REMOVE DUMMY ENTRIES CAUSED BY DUPLICATES. */
  1378. *iwfr = 1;
  1379. i__1 = *n;
  1380. for (i__ = 1; i__ <= i__1; ++i__) {
  1381. k1 = ipe[i__] + 1;
  1382. if (k1 == 1) {
  1383. goto L300;
  1384. }
  1385. k2 = iq[i__] + ipe[i__];
  1386. l = *iwfr;
  1387. ipe[i__] = *iwfr;
  1388. ++(*iwfr);
  1389. i__2 = k2;
  1390. for (k = k1; k <= i__2; ++k) {
  1391. if (iw[k] == 0) {
  1392. goto L290;
  1393. }
  1394. iw[*iwfr] = iw[k];
  1395. ++(*iwfr);
  1396. L290:
  1397. ;
  1398. }
  1399. iw[l] = *iwfr - l - 1;
  1400. L300:
  1401. ;
  1402. }
  1403. L310:
  1404. return 0;
  1405. } /* ma27gd_ */
  1406. /* Subroutine */ int ma27hd_(integer *n, integer *ipe, integer *iw, integer *
  1407. lw, integer *iwfr, integer *nv, integer *nxt, integer *lst, integer *
  1408. ipd, integer *flag__, integer *iovflo, integer *ncmpa, doublereal *
  1409. fratio)
  1410. {
  1411. /* System generated locals */
  1412. integer i__1, i__2, i__3, i__4, i__5;
  1413. doublereal d__1;
  1414. /* Builtin functions */
  1415. integer i_dnnt(doublereal *);
  1416. /* Local variables */
  1417. static integer i__, k, l, k1, k2, id, ie, ke, md, me, ip, jp, kp, is, js,
  1418. ks, ln, ls, ml, ms, np, ns, jp1, jp2, kp0, kp1, kp2, np0, idl,
  1419. idn, len, nel, nflg, lwfr, root;
  1420. extern /* Subroutine */ int ma27ud_(integer *, integer *, integer *,
  1421. integer *, integer *, integer *);
  1422. static integer limit, nvpiv, nvroot;
  1423. /* ANALYSIS SUBROUTINE */
  1424. /* GIVEN REPRESENTATION OF THE WHOLE MATRIX (EXCLUDING DIAGONAL) */
  1425. /* PERFORM MINIMUM DEGREE ORDERING, CONSTRUCTING TREE POINTERS. */
  1426. /* IT WORKS WITH SUPERVARIABLES WHICH ARE COLLECTIONS OF ONE OR MORE */
  1427. /* VARIABLES, STARTING WITH SUPERVARIABLE I CONTAINING VARIABLE I FOR */
  1428. /* I = 1,2,...,N. ALL VARIABLES IN A SUPERVARIABLE ARE ELIMINATED */
  1429. /* TOGETHER. EACH SUPERVARIABLE HAS AS NUMERICAL NAME THAT OF ONE */
  1430. /* OF ITS VARIABLES (ITS PRINCIPAL VARIABLE). */
  1431. /* N MUST BE SET TO THE MATRIX ORDER. IT IS NOT ALTERED. */
  1432. /* IPE(I) MUST BE SET TO POINT TO THE POSITION IN IW OF THE */
  1433. /* START OF ROW I OR HAVE THE VALUE ZERO IF ROW I HAS NO OFF- */
  1434. /* DIAGONAL NON-ZEROS. DURING EXECUTION IT IS USED AS FOLLOWS. IF */
  1435. /* SUPERVARIABLE I IS ABSORBED INTO SUPERVARIABLE J THEN IPE(I)=-J. */
  1436. /* IF SUPERVARIABLE I IS ELIMINATED THEN IPE(I) EITHER POINTS TO THE */
  1437. /* LIST OF SUPERVARIABLES FOR CREATED ELEMENT I OR IS ZERO IF */
  1438. /* THE CREATED ELEMENT IS NULL. IF ELEMENT I */
  1439. /* IS ABSORBED INTO ELEMENT J THEN IPE(I)=-J. */
  1440. /* IW MUST BE SET ON ENTRY TO HOLD LISTS OF VARIABLES BY */
  1441. /* ROWS, EACH LIST BEING HEADED BY ITS LENGTH. */
  1442. /* DURING EXECUTION THESE LISTS ARE REVISED AND HOLD */
  1443. /* LISTS OF ELEMENTS AND SUPERVARIABLES. THE ELEMENTS */
  1444. /* ALWAYS HEAD THE LISTS. WHEN A SUPERVARIABLE */
  1445. /* IS ELIMINATED ITS LIST IS REPLACED BY A LIST OF SUPERVARIABLES */
  1446. /* IN THE NEW ELEMENT. */
  1447. /* LW MUST BE SET TO THE LENGTH OF IW. IT IS NOT ALTERED. */
  1448. /* IWFR MUST BE SET TO THE POSITION IN IW OF THE FIRST FREE VARIABLE. */
  1449. /* IT IS REVISED DURING EXECUTION AND CONTINUES TO HAVE THIS MEANING. */
  1450. /* NV(JS) NEED NOT BE SET. DURING EXECUTION IT IS ZERO IF */
  1451. /* JS IS NOT A PRINCIPAL VARIABLE AND IF IT IS IT HOLDS */
  1452. /* THE NUMBER OF VARIABLES IN SUPERVARIABLE JS. FOR ELIMINATED */
  1453. /* VARIABLES IT IS SET TO THE DEGREE AT THE TIME OF ELIMINATION. */
  1454. /* NXT(JS) NEED NOT BE SET. DURING EXECUTION IT IS THE NEXT */
  1455. /* SUPERVARIABLE HAVING THE SAME DEGREE AS JS, OR ZERO */
  1456. /* IF IT IS LAST IN ITS LIST. */
  1457. /* LST(JS) NEED NOT BE SET. DURING EXECUTION IT IS THE */
  1458. /* LAST SUPERVARIABLE HAVING THE SAME DEGREE AS JS OR */
  1459. /* -(ITS DEGREE) IF IT IS FIRST IN ITS LIST. */
  1460. /* IPD(ID) NEED NOT BE SET. DURING EXECUTION IT */
  1461. /* IS THE FIRST SUPERVARIABLE WITH DEGREE ID OR ZERO */
  1462. /* IF THERE ARE NONE. */
  1463. /* FLAG IS USED AS WORKSPACE FOR ELEMENT AND SUPERVARIABLE FLAGS. */
  1464. /* WHILE THE CODE IS FINDING THE DEGREE OF SUPERVARIABLE IS */
  1465. /* FLAG HAS THE FOLLOWING VALUES. */
  1466. /* A) FOR THE CURRENT PIVOT/NEW ELEMENT ME */
  1467. /* FLAG(ME)=-1 */
  1468. /* B) FOR VARIABLES JS */
  1469. /* FLAG(JS)=-1 IF JS IS NOT A PRINCIPAL VARIABLE */
  1470. /* FLAG(JS)=0 IF JS IS A SUPERVARIABLE IN THE NEW ELEMENT */
  1471. /* FLAG(JS)=NFLG IF JS IS A SUPERVARIABLE NOT IN THE NEW */
  1472. /* ELEMENT THAT HAS BEEN COUNTED IN THE DEGREE */
  1473. /* CALCULATION */
  1474. /* FLAG(JS).GT.NFLG IF JS IS A SUPERVARIABLE NOT IN THE NEW */
  1475. /* ELEMENT THAT HAS NOT BEEN COUNTED IN THE DEGREE */
  1476. /* CALCULATION */
  1477. /* C) FOR ELEMENTS IE */
  1478. /* FLAG(IE)=-1 IF ELEMENT IE HAS BEEN MERGED INTO ANOTHER */
  1479. /* FLAG(IE)=-NFLG IF ELEMENT IE HAS BEEN USED IN THE DEGREE */
  1480. /* CALCULATION FOR IS. */
  1481. /* FLAG(IE).LT.-NFLG IF ELEMENT IE HAS NOT BEEN USED IN THE */
  1482. /* DEGREE CALCULATION FOR IS */
  1483. /* IOVFLO see ICNTL(4) in MA27A/AD. */
  1484. /* NCMPA see INFO(11) in MA27A/AD. */
  1485. /* FRATIO see CNTL(2) in MA27A/AD. */
  1486. /* .. Scalar Arguments .. */
  1487. /* .. */
  1488. /* .. Array Arguments .. */
  1489. /* .. */
  1490. /* .. Local Scalars .. */
  1491. /* LIMIT Limit on number of variables for putting node in root. */
  1492. /* NVROOT Number of variables in the root node */
  1493. /* ROOT Index of the root node (N+1 if none chosen yet). */
  1494. /* .. */
  1495. /* .. External Subroutines .. */
  1496. /* .. */
  1497. /* .. Intrinsic Functions .. */
  1498. /* .. */
  1499. /* If a column of the reduced matrix has relative density greater than */
  1500. /* CNTL(2), it is forced into the root. All such columns are taken to */
  1501. /* have sparsity pattern equal to their merged patterns, so the fill */
  1502. /* and operation counts may be overestimated. */
  1503. /* IS,JS,KS,LS,MS,NS ARE USED TO REFER TO SUPERVARIABLES. */
  1504. /* IE,JE,KE ARE USED TO REFER TO ELEMENTS. */
  1505. /* IP,JP,KP,K,NP ARE USED TO POINT TO LISTS OF ELEMENTS. */
  1506. /* OR SUPERVARIABLES. */
  1507. /* ID IS USED FOR THE DEGREE OF A SUPERVARIABLE. */
  1508. /* MD IS USED FOR THE CURRENT MINIMUM DEGREE. */
  1509. /* IDN IS USED FOR THE NO. OF VARIABLES IN A NEWLY CREATED ELEMENT */
  1510. /* NEL IS USED TO HOLD THE NO. OF VARIABLES THAT HAVE BEEN */
  1511. /* ELIMINATED. */
  1512. /* ME=MS IS THE NAME OF THE SUPERVARIABLE ELIMINATED AND */
  1513. /* OF THE ELEMENT CREATED IN THE MAIN LOOP. */
  1514. /* NFLG IS USED FOR THE CURRENT FLAG VALUE IN ARRAY FLAG. IT STARTS */
  1515. /* WITH THE VALUE IOVFLO AND IS REDUCED BY 1 EACH TIME IT IS USED */
  1516. /* UNTIL IT HAS THE VALUE 2 WHEN IT IS RESET TO THE VALUE IOVFLO. */
  1517. /* .. Executable Statements .. */
  1518. /* INITIALIZATIONS */
  1519. /* Parameter adjustments */
  1520. --flag__;
  1521. --ipd;
  1522. --lst;
  1523. --nxt;
  1524. --nv;
  1525. --ipe;
  1526. --iw;
  1527. /* Function Body */
  1528. i__1 = *n;
  1529. for (i__ = 1; i__ <= i__1; ++i__) {
  1530. ipd[i__] = 0;
  1531. nv[i__] = 1;
  1532. flag__[i__] = *iovflo;
  1533. /* L10: */
  1534. }
  1535. md = 1;
  1536. *ncmpa = 0;
  1537. nflg = *iovflo;
  1538. nel = 0;
  1539. root = *n + 1;
  1540. nvroot = 0;
  1541. /* LINK TOGETHER VARIABLES HAVING SAME DEGREE */
  1542. i__1 = *n;
  1543. for (is = 1; is <= i__1; ++is) {
  1544. k = ipe[is];
  1545. if (k <= 0) {
  1546. goto L20;
  1547. }
  1548. id = iw[k] + 1;
  1549. ns = ipd[id];
  1550. if (ns > 0) {
  1551. lst[ns] = is;
  1552. }
  1553. nxt[is] = ns;
  1554. ipd[id] = is;
  1555. lst[is] = -id;
  1556. goto L30;
  1557. /* WE HAVE A VARIABLE THAT CAN BE ELIMINATED AT ONCE BECAUSE THERE IS */
  1558. /* NO OFF-DIAGONAL NON-ZERO IN ITS ROW. */
  1559. L20:
  1560. ++nel;
  1561. flag__[is] = -1;
  1562. nxt[is] = 0;
  1563. lst[is] = 0;
  1564. L30:
  1565. ;
  1566. }
  1567. /* START OF MAIN LOOP */
  1568. i__1 = *n;
  1569. for (ml = 1; ml <= i__1; ++ml) {
  1570. /* LEAVE LOOP IF ALL VARIABLES HAVE BEEN ELIMINATED. */
  1571. if (nel + nvroot + 1 >= *n) {
  1572. goto L350;
  1573. }
  1574. /* FIND NEXT SUPERVARIABLE FOR ELIMINATION. */
  1575. i__2 = *n;
  1576. for (id = md; id <= i__2; ++id) {
  1577. ms = ipd[id];
  1578. if (ms > 0) {
  1579. goto L50;
  1580. }
  1581. /* L40: */
  1582. }
  1583. L50:
  1584. md = id;
  1585. /* NVPIV HOLDS THE NUMBER OF VARIABLES IN THE PIVOT. */
  1586. nvpiv = nv[ms];
  1587. /* REMOVE CHOSEN VARIABLE FROM LINKED LIST */
  1588. ns = nxt[ms];
  1589. nxt[ms] = 0;
  1590. lst[ms] = 0;
  1591. if (ns > 0) {
  1592. lst[ns] = -id;
  1593. }
  1594. ipd[id] = ns;
  1595. me = ms;
  1596. nel += nvpiv;
  1597. /* IDN HOLDS THE DEGREE OF THE NEW ELEMENT. */
  1598. idn = 0;
  1599. /* RUN THROUGH THE LIST OF THE PIVOTAL SUPERVARIABLE, SETTING TREE */
  1600. /* POINTERS AND CONSTRUCTING NEW LIST OF SUPERVARIABLES. */
  1601. /* KP IS A POINTER TO THE CURRENT POSITION IN THE OLD LIST. */
  1602. kp = ipe[me];
  1603. flag__[ms] = -1;
  1604. /* IP POINTS TO THE START OF THE NEW LIST. */
  1605. ip = *iwfr;
  1606. /* LEN HOLDS THE LENGTH OF THE LIST ASSOCIATED WITH THE PIVOT. */
  1607. len = iw[kp];
  1608. i__2 = len;
  1609. for (kp1 = 1; kp1 <= i__2; ++kp1) {
  1610. ++kp;
  1611. ke = iw[kp];
  1612. /* JUMP IF KE IS AN ELEMENT THAT HAS NOT BEEN MERGED INTO ANOTHER. */
  1613. if (flag__[ke] <= -2) {
  1614. goto L60;
  1615. }
  1616. /* JUMP IF KE IS AN ELEMENT THAT HAS BEEN MERGED INTO ANOTHER OR IS */
  1617. /* A SUPERVARIABLE THAT HAS BEEN ELIMINATED. */
  1618. if (flag__[ke] <= 0) {
  1619. if (ipe[ke] != -root) {
  1620. goto L140;
  1621. }
  1622. /* KE has been merged into the root */
  1623. ke = root;
  1624. if (flag__[ke] <= 0) {
  1625. goto L140;
  1626. }
  1627. }
  1628. /* WE HAVE A SUPERVARIABLE. PREPARE TO SEARCH REST OF LIST. */
  1629. jp = kp - 1;
  1630. ln = len - kp1 + 1;
  1631. ie = ms;
  1632. goto L70;
  1633. /* SEARCH VARIABLE LIST OF ELEMENT KE, USING JP AS A POINTER TO IT. */
  1634. L60:
  1635. ie = ke;
  1636. jp = ipe[ie];
  1637. ln = iw[jp];
  1638. /* SEARCH FOR DIFFERENT SUPERVARIABLES AND ADD THEM TO THE NEW LIST, */
  1639. /* COMPRESSING WHEN NECESSARY. THIS LOOP IS EXECUTED ONCE FOR */
  1640. /* EACH ELEMENT IN THE LIST AND ONCE FOR ALL THE SUPERVARIABLES */
  1641. /* IN THE LIST. */
  1642. L70:
  1643. i__3 = ln;
  1644. for (jp1 = 1; jp1 <= i__3; ++jp1) {
  1645. ++jp;
  1646. is = iw[jp];
  1647. /* JUMP IF IS IS NOT A PRINCIPAL VARIABLE OR HAS ALREADY BEEN COUNTED. */
  1648. if (flag__[is] <= 0) {
  1649. if (ipe[is] == -root) {
  1650. /* IS has been merged into the root */
  1651. is = root;
  1652. iw[jp] = root;
  1653. if (flag__[is] <= 0) {
  1654. goto L130;
  1655. }
  1656. } else {
  1657. goto L130;
  1658. }
  1659. }
  1660. flag__[is] = 0;
  1661. if (*iwfr < *lw) {
  1662. goto L100;
  1663. }
  1664. /* PREPARE FOR COMPRESSING IW BY ADJUSTING POINTERS AND */
  1665. /* LENGTHS SO THAT THE LISTS BEING SEARCHED IN THE INNER AND OUTER */
  1666. /* LOOPS CONTAIN ONLY THE REMAINING ENTRIES. */
  1667. ipe[ms] = kp;
  1668. iw[kp] = len - kp1;
  1669. ipe[ie] = jp;
  1670. iw[jp] = ln - jp1;
  1671. /* COMPRESS IW */
  1672. i__4 = ip - 1;
  1673. ma27ud_(n, &ipe[1], &iw[1], &i__4, &lwfr, ncmpa);
  1674. /* COPY NEW LIST FORWARD */
  1675. jp2 = *iwfr - 1;
  1676. *iwfr = lwfr;
  1677. if (ip > jp2) {
  1678. goto L90;
  1679. }
  1680. i__4 = jp2;
  1681. for (jp = ip; jp <= i__4; ++jp) {
  1682. iw[*iwfr] = iw[jp];
  1683. ++(*iwfr);
  1684. /* L80: */
  1685. }
  1686. /* ADJUST POINTERS FOR THE NEW LIST AND THE LISTS BEING SEARCHED. */
  1687. L90:
  1688. ip = lwfr;
  1689. jp = ipe[ie];
  1690. kp = ipe[me];
  1691. /* STORE IS IN NEW LIST. */
  1692. L100:
  1693. iw[*iwfr] = is;
  1694. idn += nv[is];
  1695. ++(*iwfr);
  1696. /* REMOVE IS FROM DEGREE LINKED LIST */
  1697. ls = lst[is];
  1698. lst[is] = 0;
  1699. ns = nxt[is];
  1700. nxt[is] = 0;
  1701. if (ns > 0) {
  1702. lst[ns] = ls;
  1703. }
  1704. if (ls < 0) {
  1705. ls = -ls;
  1706. ipd[ls] = ns;
  1707. } else if (ls > 0) {
  1708. nxt[ls] = ns;
  1709. }
  1710. L130:
  1711. ;
  1712. }
  1713. /* JUMP IF WE HAVE JUST BEEN SEARCHING THE VARIABLES AT THE END OF */
  1714. /* THE LIST OF THE PIVOT. */
  1715. if (ie == ms) {
  1716. goto L150;
  1717. }
  1718. /* SET TREE POINTER AND FLAG TO INDICATE ELEMENT IE IS ABSORBED INTO */
  1719. /* NEW ELEMENT ME. */
  1720. ipe[ie] = -me;
  1721. flag__[ie] = -1;
  1722. L140:
  1723. ;
  1724. }
  1725. /* STORE THE DEGREE OF THE PIVOT. */
  1726. L150:
  1727. nv[ms] = idn + nvpiv;
  1728. /* JUMP IF NEW ELEMENT IS NULL. */
  1729. if (*iwfr == ip) {
  1730. goto L330;
  1731. }
  1732. k1 = ip;
  1733. k2 = *iwfr - 1;
  1734. /* RUN THROUGH NEW LIST OF SUPERVARIABLES REVISING EACH ASSOCIATED LIST, */
  1735. /* RECALCULATING DEGREES AND REMOVING DUPLICATES. */
  1736. d__1 = *fratio * (*n - nel);
  1737. limit = i_dnnt(&d__1);
  1738. i__2 = k2;
  1739. for (k = k1; k <= i__2; ++k) {
  1740. is = iw[k];
  1741. if (is == root) {
  1742. goto L310;
  1743. }
  1744. if (nflg > 2) {
  1745. goto L170;
  1746. }
  1747. /* RESET FLAG VALUES TO +/-IOVFLO. */
  1748. i__3 = *n;
  1749. for (i__ = 1; i__ <= i__3; ++i__) {
  1750. if (flag__[i__] > 0) {
  1751. flag__[i__] = *iovflo;
  1752. }
  1753. if (flag__[i__] <= -2) {
  1754. flag__[i__] = -(*iovflo);
  1755. }
  1756. /* L160: */
  1757. }
  1758. nflg = *iovflo;
  1759. /* REDUCE NFLG BY ONE TO CATER FOR THIS SUPERVARIABLE. */
  1760. L170:
  1761. --nflg;
  1762. /* BEGIN WITH THE DEGREE OF THE NEW ELEMENT. ITS VARIABLES MUST ALWAYS */
  1763. /* BE COUNTED DURING THE DEGREE CALCULATION AND THEY ARE ALREADY */
  1764. /* FLAGGED WITH THE VALUE 0. */
  1765. id = idn;
  1766. /* RUN THROUGH THE LIST ASSOCIATED WITH SUPERVARIABLE IS */
  1767. kp1 = ipe[is] + 1;
  1768. /* NP POINTS TO THE NEXT ENTRY IN THE REVISED LIST. */
  1769. np = kp1;
  1770. kp2 = iw[kp1 - 1] + kp1 - 1;
  1771. i__3 = kp2;
  1772. for (kp = kp1; kp <= i__3; ++kp) {
  1773. ke = iw[kp];
  1774. /* TEST WHETHER KE IS AN ELEMENT, A REDUNDANT ENTRY OR A SUPERVARIABLE. */
  1775. if (flag__[ke] == -1) {
  1776. if (ipe[ke] != -root) {
  1777. goto L220;
  1778. }
  1779. /* KE has been merged into the root */
  1780. ke = root;
  1781. iw[kp] = root;
  1782. if (flag__[ke] == -1) {
  1783. goto L220;
  1784. }
  1785. }
  1786. if (flag__[ke] >= 0) {
  1787. goto L230;
  1788. }
  1789. /* SEARCH LIST OF ELEMENT KE, REVISING THE DEGREE WHEN NEW VARIABLES */
  1790. /* FOUND. */
  1791. jp1 = ipe[ke] + 1;
  1792. jp2 = iw[jp1 - 1] + jp1 - 1;
  1793. idl = id;
  1794. i__4 = jp2;
  1795. for (jp = jp1; jp <= i__4; ++jp) {
  1796. js = iw[jp];
  1797. /* JUMP IF JS HAS ALREADY BEEN COUNTED. */
  1798. if (flag__[js] <= nflg) {
  1799. goto L190;
  1800. }
  1801. id += nv[js];
  1802. flag__[js] = nflg;
  1803. L190:
  1804. ;
  1805. }
  1806. /* JUMP IF ONE OR MORE NEW SUPERVARIABLES WERE FOUND. */
  1807. if (id > idl) {
  1808. goto L210;
  1809. }
  1810. /* CHECK WHETHER EVERY VARIABLE OF ELEMENT KE IS IN NEW ELEMENT ME. */
  1811. i__4 = jp2;
  1812. for (jp = jp1; jp <= i__4; ++jp) {
  1813. js = iw[jp];
  1814. if (flag__[js] != 0) {
  1815. goto L210;
  1816. }
  1817. /* L200: */
  1818. }
  1819. /* SET TREE POINTER AND FLAG TO INDICATE THAT ELEMENT KE IS ABSORBED */
  1820. /* INTO NEW ELEMENT ME. */
  1821. ipe[ke] = -me;
  1822. flag__[ke] = -1;
  1823. goto L220;
  1824. /* STORE ELEMENT KE IN THE REVISED LIST FOR SUPERVARIABLE IS AND FLAG IT. */
  1825. L210:
  1826. iw[np] = ke;
  1827. flag__[ke] = -nflg;
  1828. ++np;
  1829. L220:
  1830. ;
  1831. }
  1832. np0 = np;
  1833. goto L250;
  1834. /* TREAT THE REST OF THE LIST ASSOCIATED WITH SUPERVARIABLE IS. IT */
  1835. /* CONSISTS ENTIRELY OF SUPERVARIABLES. */
  1836. L230:
  1837. kp0 = kp;
  1838. np0 = np;
  1839. i__3 = kp2;
  1840. for (kp = kp0; kp <= i__3; ++kp) {
  1841. ks = iw[kp];
  1842. if (flag__[ks] <= nflg) {
  1843. if (ipe[ks] == -root) {
  1844. ks = root;
  1845. iw[kp] = root;
  1846. if (flag__[ks] <= nflg) {
  1847. goto L240;
  1848. }
  1849. } else {
  1850. goto L240;
  1851. }
  1852. }
  1853. /* ADD TO DEGREE, FLAG SUPERVARIABLE KS AND ADD IT TO NEW LIST. */
  1854. id += nv[ks];
  1855. flag__[ks] = nflg;
  1856. iw[np] = ks;
  1857. ++np;
  1858. L240:
  1859. ;
  1860. }
  1861. /* MOVE FIRST SUPERVARIABLE TO END OF LIST, MOVE FIRST ELEMENT TO END */
  1862. /* OF ELEMENT PART OF LIST AND ADD NEW ELEMENT TO FRONT OF LIST. */
  1863. L250:
  1864. if (id >= limit) {
  1865. goto L295;
  1866. }
  1867. iw[np] = iw[np0];
  1868. iw[np0] = iw[kp1];
  1869. iw[kp1] = me;
  1870. /* STORE THE NEW LENGTH OF THE LIST. */
  1871. iw[kp1 - 1] = np - kp1 + 1;
  1872. /* CHECK WHETHER ROW IS IS IDENTICAL TO ANOTHER BY LOOKING IN LINKED */
  1873. /* LIST OF SUPERVARIABLES WITH DEGREE ID AT THOSE WHOSE LISTS HAVE */
  1874. /* FIRST ENTRY ME. NOTE THAT THOSE CONTAINING ME COME FIRST SO THE */
  1875. /* SEARCH CAN BE TERMINATED WHEN A LIST NOT STARTING WITH ME IS */
  1876. /* FOUND. */
  1877. js = ipd[id];
  1878. i__3 = *n;
  1879. for (l = 1; l <= i__3; ++l) {
  1880. if (js <= 0) {
  1881. goto L300;
  1882. }
  1883. kp1 = ipe[js] + 1;
  1884. if (iw[kp1] != me) {
  1885. goto L300;
  1886. }
  1887. /* JS HAS SAME DEGREE AND IS ACTIVE. CHECK IF IDENTICAL TO IS. */
  1888. kp2 = kp1 - 1 + iw[kp1 - 1];
  1889. i__4 = kp2;
  1890. for (kp = kp1; kp <= i__4; ++kp) {
  1891. ie = iw[kp];
  1892. /* JUMP IF IE IS A SUPERVARIABLE OR AN ELEMENT NOT IN THE LIST OF IS. */
  1893. if ((i__5 = flag__[ie], abs(i__5)) > nflg) {
  1894. goto L270;
  1895. }
  1896. /* L260: */
  1897. }
  1898. goto L290;
  1899. L270:
  1900. js = nxt[js];
  1901. /* L280: */
  1902. }
  1903. /* SUPERVARIABLE AMALGAMATION. ROW IS IS IDENTICAL TO ROW JS. */
  1904. /* REGARD ALL VARIABLES IN THE TWO SUPERVARIABLES AS BEING IN IS. SET */
  1905. /* TREE POINTER, FLAG AND NV ENTRIES. */
  1906. L290:
  1907. ipe[js] = -is;
  1908. nv[is] += nv[js];
  1909. nv[js] = 0;
  1910. flag__[js] = -1;
  1911. /* REPLACE JS BY IS IN LINKED LIST. */
  1912. ns = nxt[js];
  1913. ls = lst[js];
  1914. if (ns > 0) {
  1915. lst[ns] = is;
  1916. }
  1917. if (ls > 0) {
  1918. nxt[ls] = is;
  1919. }
  1920. lst[is] = ls;
  1921. nxt[is] = ns;
  1922. lst[js] = 0;
  1923. nxt[js] = 0;
  1924. if (ipd[id] == js) {
  1925. ipd[id] = is;
  1926. }
  1927. goto L310;
  1928. /* Treat IS as full. Merge it into the root node. */
  1929. L295:
  1930. if (nvroot == 0) {
  1931. root = is;
  1932. ipe[is] = 0;
  1933. } else {
  1934. iw[k] = root;
  1935. ipe[is] = -root;
  1936. nv[root] += nv[is];
  1937. nv[is] = 0;
  1938. flag__[is] = -1;
  1939. }
  1940. nvroot = nv[root];
  1941. goto L310;
  1942. /* INSERT IS INTO LINKED LIST OF SUPERVARIABLES OF SAME DEGREE. */
  1943. L300:
  1944. ns = ipd[id];
  1945. if (ns > 0) {
  1946. lst[ns] = is;
  1947. }
  1948. nxt[is] = ns;
  1949. ipd[id] = is;
  1950. lst[is] = -id;
  1951. md = min(md,id);
  1952. L310:
  1953. ;
  1954. }
  1955. /* RESET FLAGS FOR SUPERVARIABLES IN NEWLY CREATED ELEMENT AND */
  1956. /* REMOVE THOSE ABSORBED INTO OTHERS. */
  1957. i__2 = k2;
  1958. for (k = k1; k <= i__2; ++k) {
  1959. is = iw[k];
  1960. if (nv[is] == 0) {
  1961. goto L320;
  1962. }
  1963. flag__[is] = nflg;
  1964. iw[ip] = is;
  1965. ++ip;
  1966. L320:
  1967. ;
  1968. }
  1969. *iwfr = k1;
  1970. flag__[me] = -nflg;
  1971. /* MOVE FIRST ENTRY TO END TO MAKE ROOM FOR LENGTH. */
  1972. iw[ip] = iw[k1];
  1973. iw[k1] = ip - k1;
  1974. /* SET POINTER FOR NEW ELEMENT AND RESET IWFR. */
  1975. ipe[me] = k1;
  1976. *iwfr = ip + 1;
  1977. goto L335;
  1978. L330:
  1979. ipe[me] = 0;
  1980. L335:
  1981. /* L340: */
  1982. ;
  1983. }
  1984. /* Absorb any remaining variables into the root */
  1985. L350:
  1986. i__1 = *n;
  1987. for (is = 1; is <= i__1; ++is) {
  1988. if (nxt[is] != 0 || lst[is] != 0) {
  1989. if (nvroot == 0) {
  1990. root = is;
  1991. ipe[is] = 0;
  1992. } else {
  1993. ipe[is] = -root;
  1994. }
  1995. nvroot += nv[is];
  1996. nv[is] = 0;
  1997. }
  1998. /* L360: */
  1999. }
  2000. /* Link any remaining elements to the root */
  2001. i__1 = *n;
  2002. for (ie = 1; ie <= i__1; ++ie) {
  2003. if (ipe[ie] > 0) {
  2004. ipe[ie] = -root;
  2005. }
  2006. /* L370: */
  2007. }
  2008. if (nvroot > 0) {
  2009. nv[root] = nvroot;
  2010. }
  2011. return 0;
  2012. } /* ma27hd_ */
  2013. /* Subroutine */ int ma27ud_(integer *n, integer *ipe, integer *iw, integer *
  2014. lw, integer *iwfr, integer *ncmpa)
  2015. {
  2016. /* System generated locals */
  2017. integer i__1, i__2;
  2018. /* Local variables */
  2019. static integer i__, k, k1, k2, ir, lwfr;
  2020. /* COMPRESS LISTS HELD BY MA27H/HD AND MA27K/KD IN IW AND ADJUST POINTERS */
  2021. /* IN IPE TO CORRESPOND. */
  2022. /* N IS THE MATRIX ORDER. IT IS NOT ALTERED. */
  2023. /* IPE(I) POINTS TO THE POSITION IN IW OF THE START OF LIST I OR IS */
  2024. /* ZERO IF THERE IS NO LIST I. ON EXIT IT POINTS TO THE NEW POSITION. */
  2025. /* IW HOLDS THE LISTS, EACH HEADED BY ITS LENGTH. ON OUTPUT THE SAME */
  2026. /* LISTS ARE HELD, BUT THEY ARE NOW COMPRESSED TOGETHER. */
  2027. /* LW HOLDS THE LENGTH OF IW. IT IS NOT ALTERED. */
  2028. /* IWFR NEED NOT BE SET ON ENTRY. ON EXIT IT POINTS TO THE FIRST FREE */
  2029. /* LOCATION IN IW. */
  2030. /* ON RETURN IT IS SET TO THE FIRST FREE LOCATION IN IW. */
  2031. /* NCMPA see INFO(11) in MA27A/AD. */
  2032. /* .. Scalar Arguments .. */
  2033. /* .. */
  2034. /* .. Array Arguments .. */
  2035. /* .. */
  2036. /* .. Local Scalars .. */
  2037. /* .. */
  2038. /* .. Executable Statements .. */
  2039. /* Parameter adjustments */
  2040. --ipe;
  2041. --iw;
  2042. /* Function Body */
  2043. ++(*ncmpa);
  2044. /* PREPARE FOR COMPRESSING BY STORING THE LENGTHS OF THE */
  2045. /* LISTS IN IPE AND SETTING THE FIRST ENTRY OF EACH LIST TO */
  2046. /* -(LIST NUMBER). */
  2047. i__1 = *n;
  2048. for (i__ = 1; i__ <= i__1; ++i__) {
  2049. k1 = ipe[i__];
  2050. if (k1 <= 0) {
  2051. goto L10;
  2052. }
  2053. ipe[i__] = iw[k1];
  2054. iw[k1] = -i__;
  2055. L10:
  2056. ;
  2057. }
  2058. /* COMPRESS */
  2059. /* IWFR POINTS JUST BEYOND THE END OF THE COMPRESSED FILE. */
  2060. /* LWFR POINTS JUST BEYOND THE END OF THE UNCOMPRESSED FILE. */
  2061. *iwfr = 1;
  2062. lwfr = *iwfr;
  2063. i__1 = *n;
  2064. for (ir = 1; ir <= i__1; ++ir) {
  2065. if (lwfr > *lw) {
  2066. goto L70;
  2067. }
  2068. /* SEARCH FOR THE NEXT NEGATIVE ENTRY. */
  2069. i__2 = *lw;
  2070. for (k = lwfr; k <= i__2; ++k) {
  2071. if (iw[k] < 0) {
  2072. goto L30;
  2073. }
  2074. /* L20: */
  2075. }
  2076. goto L70;
  2077. /* PICK UP ENTRY NUMBER, STORE LENGTH IN NEW POSITION, SET NEW POINTER */
  2078. /* AND PREPARE TO COPY LIST. */
  2079. L30:
  2080. i__ = -iw[k];
  2081. iw[*iwfr] = ipe[i__];
  2082. ipe[i__] = *iwfr;
  2083. k1 = k + 1;
  2084. k2 = k + iw[*iwfr];
  2085. ++(*iwfr);
  2086. if (k1 > k2) {
  2087. goto L50;
  2088. }
  2089. /* COPY LIST TO NEW POSITION. */
  2090. i__2 = k2;
  2091. for (k = k1; k <= i__2; ++k) {
  2092. iw[*iwfr] = iw[k];
  2093. ++(*iwfr);
  2094. /* L40: */
  2095. }
  2096. L50:
  2097. lwfr = k2 + 1;
  2098. /* L60: */
  2099. }
  2100. L70:
  2101. return 0;
  2102. } /* ma27ud_ */
  2103. /* Subroutine */ int ma27jd_(integer *n, integer *nz, integer *irn, integer *
  2104. icn, integer *perm, integer *iw, integer *lw, integer *ipe, integer *
  2105. iq, integer *flag__, integer *iwfr, integer *icntl, integer *info)
  2106. {
  2107. /* Format strings */
  2108. static char fmt_60[] = "(\002 *** WARNING MESSAGE FROM SUBROUTINE MA27A"
  2109. "D\002,\002 *** INFO(1) =\002,i2)";
  2110. static char fmt_70[] = "(i6,\002TH NON-ZERO (IN ROW\002,i6,\002 AND COLU"
  2111. "MN\002,i6,\002) IGNORED\002)";
  2112. /* System generated locals */
  2113. integer i__1, i__2;
  2114. /* Builtin functions */
  2115. integer s_wsfe(cilist *), do_fio(integer *, char *, ftnlen), e_wsfe(void);
  2116. /* Local variables */
  2117. static integer i__, j, k, l, k1, k2, id, in, len, lbig, jdummy;
  2118. /* Fortran I/O blocks */
  2119. static cilist io___144 = { 0, 0, 0, fmt_60, 0 };
  2120. static cilist io___145 = { 0, 0, 0, fmt_70, 0 };
  2121. /* SORT PRIOR TO CALLING ANALYSIS ROUTINE MA27K/KD. */
  2122. /* GIVEN THE POSITIONS OF THE OFF-DIAGONAL NON-ZEROS OF A SYMMETRIC */
  2123. /* MATRIX AND A PERMUTATION, CONSTRUCT THE SPARSITY PATTERN */
  2124. /* OF THE STRICTLY UPPER TRIANGULAR PART OF THE PERMUTED MATRIX. */
  2125. /* EITHER ONE OF A PAIR (I,J),(J,I) MAY BE USED TO REPRESENT */
  2126. /* THE PAIR. DIAGONAL ELEMENTS ARE IGNORED. NO CHECK IS MADE */
  2127. /* FOR DUPLICATE ELEMENTS UNLESS ANY ROW HAS MORE THAN ICNTL(4) */
  2128. /* NON-ZEROS, IN WHICH CASE DUPLICATES ARE REMOVED. */
  2129. /* N MUST BE SET TO THE MATRIX ORDER. IT IS NOT ALTERED. */
  2130. /* NZ MUST BE SET TO THE NUMBER OF NON-ZEROS INPUT. IT IS NOT */
  2131. /* ALTERED. */
  2132. /* IRN(I),I=1,2,...,NZ MUST BE SET TO THE ROW INDICES OF THE */
  2133. /* NON-ZEROS ON INPUT. IT IS NOT ALTERED UNLESS EQUIVALENCED WITH IW. */
  2134. /* IRN(1) MAY BE EQUIVALENCED WITH IW(1). */
  2135. /* ICN(I),I=1,2,...,NZ MUST BE SET TO THE COLUMN INDICES OF THE */
  2136. /* NON-ZEROS ON INPUT. IT IS NOT ALTERED UNLESS EQUIVALENCED */
  2137. /* WITH IW.ICN(1) MAY BE EQUIVELENCED WITH IW(K),K.GT.NZ. */
  2138. /* PERM(I) MUST BE SET TO HOLD THE POSITION OF VARIABLE I IN THE */
  2139. /* PERMUTED ORDER. IT IS NOT ALTERED. */
  2140. /* IW NEED NOT BE SET ON INPUT. ON OUTPUT IT CONTAINS LISTS OF */
  2141. /* COLUMN NUMBERS, EACH LIST BEING HEADED BY ITS LENGTH. */
  2142. /* LW MUST BE SET TO THE LENGTH OF IW. IT MUST BE AT LEAST */
  2143. /* MAX(NZ,N+(NO. OF OFF-DIAGONAL NON-ZEROS)). IT IS NOT ALTERED. */
  2144. /* IPE NEED NOT BE SET ON INPUT. ON OUTPUT IPE(I) POINTS TO THE START OF */
  2145. /* THE ENTRY IN IW FOR ROW I, OR IS ZERO IF THERE IS NO ENTRY. */
  2146. /* IQ NEED NOT BE SET. ON OUTPUT IQ(I) CONTAINS THE NUMBER OF */
  2147. /* OFF-DIAGONAL NON-ZEROS IN ROW I, INCLUDING DUPLICATES. */
  2148. /* FLAG IS USED FOR WORKSPACE TO HOLD FLAGS TO PERMIT DUPLICATE */
  2149. /* ENTRIES TO BE IDENTIFIED QUICKLY. */
  2150. /* IWFR NEED NOT BE SET ON INPUT. ON OUTPUT IT POINTS TO THE FIRST */
  2151. /* UNUSED LOCATION IN IW. */
  2152. /* ICNTL is an INTEGER array of length 30, see MA27A/AD. */
  2153. /* INFO is an INTEGER array of length 20, see MA27A/AD. */
  2154. /* .. Scalar Arguments .. */
  2155. /* .. */
  2156. /* .. Array Arguments .. */
  2157. /* .. */
  2158. /* .. Local Scalars .. */
  2159. /* .. */
  2160. /* .. Intrinsic Functions .. */
  2161. /* .. */
  2162. /* .. Executable Statements .. */
  2163. /* INITIALIZE INFO(1), INFO(2) AND IQ */
  2164. /* Parameter adjustments */
  2165. --flag__;
  2166. --iq;
  2167. --ipe;
  2168. --perm;
  2169. --irn;
  2170. --icn;
  2171. --iw;
  2172. --icntl;
  2173. --info;
  2174. /* Function Body */
  2175. info[1] = 0;
  2176. info[2] = 0;
  2177. i__1 = *n;
  2178. for (i__ = 1; i__ <= i__1; ++i__) {
  2179. iq[i__] = 0;
  2180. /* L10: */
  2181. }
  2182. /* COUNT THE NUMBERS OF NON-ZEROS IN THE ROWS, PRINT WARNINGS ABOUT */
  2183. /* OUT-OF-RANGE INDICES AND TRANSFER GENUINE ROW NUMBERS */
  2184. /* (NEGATED) INTO IW. */
  2185. if (*nz == 0) {
  2186. goto L110;
  2187. }
  2188. i__1 = *nz;
  2189. for (k = 1; k <= i__1; ++k) {
  2190. i__ = irn[k];
  2191. j = icn[k];
  2192. iw[k] = -i__;
  2193. if (i__ < j) {
  2194. if (i__ >= 1 && j <= *n) {
  2195. goto L80;
  2196. }
  2197. } else if (i__ > j) {
  2198. if (j >= 1 && i__ <= *n) {
  2199. goto L80;
  2200. }
  2201. } else {
  2202. iw[k] = 0;
  2203. if (i__ >= 1 && i__ <= *n) {
  2204. goto L100;
  2205. }
  2206. }
  2207. ++info[2];
  2208. info[1] = 1;
  2209. iw[k] = 0;
  2210. if (info[2] <= 1 && icntl[2] > 0) {
  2211. io___144.ciunit = icntl[2];
  2212. s_wsfe(&io___144);
  2213. do_fio(&c__1, (char *)&info[1], (ftnlen)sizeof(integer));
  2214. e_wsfe();
  2215. }
  2216. if (info[2] <= 10 && icntl[2] > 0) {
  2217. io___145.ciunit = icntl[2];
  2218. s_wsfe(&io___145);
  2219. do_fio(&c__1, (char *)&k, (ftnlen)sizeof(integer));
  2220. do_fio(&c__1, (char *)&i__, (ftnlen)sizeof(integer));
  2221. do_fio(&c__1, (char *)&j, (ftnlen)sizeof(integer));
  2222. e_wsfe();
  2223. }
  2224. goto L100;
  2225. L80:
  2226. if (perm[j] > perm[i__]) {
  2227. goto L90;
  2228. }
  2229. ++iq[j];
  2230. goto L100;
  2231. L90:
  2232. ++iq[i__];
  2233. L100:
  2234. ;
  2235. }
  2236. /* ACCUMULATE ROW COUNTS TO GET POINTERS TO ROW ENDS */
  2237. /* IN IPE. */
  2238. L110:
  2239. *iwfr = 1;
  2240. lbig = 0;
  2241. i__1 = *n;
  2242. for (i__ = 1; i__ <= i__1; ++i__) {
  2243. l = iq[i__];
  2244. lbig = max(l,lbig);
  2245. *iwfr += l;
  2246. ipe[i__] = *iwfr - 1;
  2247. /* L120: */
  2248. }
  2249. /* PERFORM IN-PLACE SORT */
  2250. if (*nz == 0) {
  2251. goto L250;
  2252. }
  2253. i__1 = *nz;
  2254. for (k = 1; k <= i__1; ++k) {
  2255. i__ = -iw[k];
  2256. if (i__ <= 0) {
  2257. goto L160;
  2258. }
  2259. l = k;
  2260. iw[k] = 0;
  2261. i__2 = *nz;
  2262. for (id = 1; id <= i__2; ++id) {
  2263. j = icn[l];
  2264. if (perm[i__] < perm[j]) {
  2265. goto L130;
  2266. }
  2267. l = ipe[j];
  2268. ipe[j] = l - 1;
  2269. in = iw[l];
  2270. iw[l] = i__;
  2271. goto L140;
  2272. L130:
  2273. l = ipe[i__];
  2274. ipe[i__] = l - 1;
  2275. in = iw[l];
  2276. iw[l] = j;
  2277. L140:
  2278. i__ = -in;
  2279. if (i__ <= 0) {
  2280. goto L160;
  2281. }
  2282. /* L150: */
  2283. }
  2284. L160:
  2285. ;
  2286. }
  2287. /* MAKE ROOM IN IW FOR ROW LENGTHS AND INITIALIZE FLAG. */
  2288. k = *iwfr - 1;
  2289. l = k + *n;
  2290. *iwfr = l + 1;
  2291. i__1 = *n;
  2292. for (i__ = 1; i__ <= i__1; ++i__) {
  2293. flag__[i__] = 0;
  2294. j = *n + 1 - i__;
  2295. len = iq[j];
  2296. if (len <= 0) {
  2297. goto L180;
  2298. }
  2299. i__2 = len;
  2300. for (jdummy = 1; jdummy <= i__2; ++jdummy) {
  2301. iw[l] = iw[k];
  2302. --k;
  2303. --l;
  2304. /* L170: */
  2305. }
  2306. L180:
  2307. ipe[j] = l;
  2308. --l;
  2309. /* L190: */
  2310. }
  2311. if (lbig >= icntl[4]) {
  2312. goto L210;
  2313. }
  2314. /* PLACE ROW LENGTHS IN IW */
  2315. i__1 = *n;
  2316. for (i__ = 1; i__ <= i__1; ++i__) {
  2317. k = ipe[i__];
  2318. iw[k] = iq[i__];
  2319. if (iq[i__] == 0) {
  2320. ipe[i__] = 0;
  2321. }
  2322. /* L200: */
  2323. }
  2324. goto L250;
  2325. /* REMOVE DUPLICATE ENTRIES */
  2326. L210:
  2327. *iwfr = 1;
  2328. i__1 = *n;
  2329. for (i__ = 1; i__ <= i__1; ++i__) {
  2330. k1 = ipe[i__] + 1;
  2331. k2 = ipe[i__] + iq[i__];
  2332. if (k1 <= k2) {
  2333. goto L220;
  2334. }
  2335. ipe[i__] = 0;
  2336. goto L240;
  2337. L220:
  2338. ipe[i__] = *iwfr;
  2339. ++(*iwfr);
  2340. i__2 = k2;
  2341. for (k = k1; k <= i__2; ++k) {
  2342. j = iw[k];
  2343. if (flag__[j] == i__) {
  2344. goto L230;
  2345. }
  2346. iw[*iwfr] = j;
  2347. ++(*iwfr);
  2348. flag__[j] = i__;
  2349. L230:
  2350. ;
  2351. }
  2352. k = ipe[i__];
  2353. iw[k] = *iwfr - k - 1;
  2354. L240:
  2355. ;
  2356. }
  2357. L250:
  2358. return 0;
  2359. } /* ma27jd_ */
  2360. /* Subroutine */ int ma27kd_(integer *n, integer *ipe, integer *iw, integer *
  2361. lw, integer *iwfr, integer *ips, integer *ipv, integer *nv, integer *
  2362. flag__, integer *ncmpa)
  2363. {
  2364. /* System generated locals */
  2365. integer i__1, i__2, i__3, i__4, i__5;
  2366. /* Local variables */
  2367. static integer i__, j, ie, je, me, ip, jp, ln, ml, js, ms, jp1, jp2, lwfr;
  2368. extern /* Subroutine */ int ma27ud_(integer *, integer *, integer *,
  2369. integer *, integer *, integer *);
  2370. static integer minjs, kdummy;
  2371. /* USING A GIVEN PIVOTAL SEQUENCE AND A REPRESENTATION OF THE MATRIX THAT */
  2372. /* INCLUDES ONLY NON-ZEROS OF THE STRICTLY UPPER-TRIANGULAR PART */
  2373. /* OF THE PERMUTED MATRIX, CONSTRUCT TREE POINTERS. */
  2374. /* N MUST BE SET TO THE MATRIX ORDER. IT IS NOT ALTERED. */
  2375. /* IPE(I) MUST BE SET TO POINT TO THE POSITION IN IW OF THE */
  2376. /* START OF ROW I OR HAVE THE VALUE ZERO IF ROW I HAS NO OFF- */
  2377. /* DIAGONAL NON-ZEROS. DURING EXECUTION IT IS USED AS FOLLOWS. */
  2378. /* IF VARIABLE I IS ELIMINATED THEN IPE(I) POINTS TO THE LIST */
  2379. /* OF VARIABLES FOR CREATED ELEMENT I. IF ELEMENT I IS */
  2380. /* ABSORBED INTO NEWLY CREATED ELEMENT J THEN IPE(I)=-J. */
  2381. /* IW MUST BE SET ON ENTRY TO HOLD LISTS OF VARIABLES BY */
  2382. /* ROWS, EACH LIST BEING HEADED BY ITS LENGTH. WHEN A VARIABLE */
  2383. /* IS ELIMINATED ITS LIST IS REPLACED BY A LIST OF VARIABLES */
  2384. /* IN THE NEW ELEMENT. */
  2385. /* LW MUST BE SET TO THE LENGTH OF IW. IT IS NOT ALTERED. */
  2386. /* IWFR MUST BE SET TO THE POSITION IN IW OF THE FIRST FREE VARIABLE. */
  2387. /* IT IS REVISED DURING EXECUTION, CONTINUING TO HAVE THIS MEANING. */
  2388. /* IPS(I) MUST BE SET TO THE POSITION OF VARIABLE I IN THE REQUIRED */
  2389. /* ORDERING. IT IS NOT ALTERED. */
  2390. /* IPV NEED NOT BE SET. IPV(K) IS SET TO HOLD THE K TH VARIABLE */
  2391. /* IN PIVOT ORDER. */
  2392. /* NV NEED NOT BE SET. IF VARIABLE J HAS NOT BEEN ELIMINATED THEN */
  2393. /* THE LAST ELEMENT WHOSE LEADING VARIABLE (VARIABLE EARLIEST */
  2394. /* IN THE PIVOT SEQUENCE) IS J IS ELEMENT NV(J). IF ELEMENT J */
  2395. /* EXISTS THEN THE LAST ELEMENT HAVING THE SAME LEADING */
  2396. /* VARIABLE IS NV(J). IN BOTH CASES NV(J)=0 IF THERE IS NO SUCH */
  2397. /* ELEMENT. IF ELEMENT J HAS BEEN MERGED INTO A LATER ELEMENT */
  2398. /* THEN NV(J) IS THE DEGREE AT THE TIME OF ELIMINATION. */
  2399. /* FLAG IS USED AS WORKSPACE FOR VARIABLE FLAGS. */
  2400. /* FLAG(JS)=ME IF JS HAS BEEN INCLUDED IN THE LIST FOR ME. */
  2401. /* NCMPA see INFO(11) in MA27A/AD. */
  2402. /* .. Scalar Arguments .. */
  2403. /* .. */
  2404. /* .. Array Arguments .. */
  2405. /* .. */
  2406. /* .. Local Scalars .. */
  2407. /* .. */
  2408. /* .. External Subroutines .. */
  2409. /* .. */
  2410. /* .. Intrinsic Functions .. */
  2411. /* .. */
  2412. /* .. Executable Statements .. */
  2413. /* INITIALIZATIONS */
  2414. /* Parameter adjustments */
  2415. --flag__;
  2416. --nv;
  2417. --ipv;
  2418. --ips;
  2419. --ipe;
  2420. --iw;
  2421. /* Function Body */
  2422. i__1 = *n;
  2423. for (i__ = 1; i__ <= i__1; ++i__) {
  2424. flag__[i__] = 0;
  2425. nv[i__] = 0;
  2426. j = ips[i__];
  2427. ipv[j] = i__;
  2428. /* L10: */
  2429. }
  2430. *ncmpa = 0;
  2431. /* START OF MAIN LOOP */
  2432. i__1 = *n;
  2433. for (ml = 1; ml <= i__1; ++ml) {
  2434. /* ME=MS IS THE NAME OF THE VARIABLE ELIMINATED AND */
  2435. /* OF THE ELEMENT CREATED IN THE MAIN LOOP. */
  2436. ms = ipv[ml];
  2437. me = ms;
  2438. flag__[ms] = me;
  2439. /* MERGE ROW MS WITH ALL THE ELEMENTS HAVING MS AS LEADING VARIABLE. */
  2440. /* IP POINTS TO THE START OF THE NEW LIST. */
  2441. ip = *iwfr;
  2442. /* MINJS IS SET TO THE POSITION IN THE ORDER OF THE LEADING VARIABLE */
  2443. /* IN THE NEW LIST. */
  2444. minjs = *n;
  2445. ie = me;
  2446. i__2 = *n;
  2447. for (kdummy = 1; kdummy <= i__2; ++kdummy) {
  2448. /* SEARCH VARIABLE LIST OF ELEMENT IE. */
  2449. /* JP POINTS TO THE CURRENT POSITION IN THE LIST BEING SEARCHED. */
  2450. jp = ipe[ie];
  2451. /* LN IS THE LENGTH OF THE LIST BEING SEARCHED. */
  2452. ln = 0;
  2453. if (jp <= 0) {
  2454. goto L60;
  2455. }
  2456. ln = iw[jp];
  2457. /* SEARCH FOR DIFFERENT VARIABLES AND ADD THEM TO LIST, */
  2458. /* COMPRESSING WHEN NECESSARY */
  2459. i__3 = ln;
  2460. for (jp1 = 1; jp1 <= i__3; ++jp1) {
  2461. ++jp;
  2462. /* PLACE NEXT VARIABLE IN JS. */
  2463. js = iw[jp];
  2464. /* JUMP IF VARIABLE HAS ALREADY BEEN INCLUDED. */
  2465. if (flag__[js] == me) {
  2466. goto L50;
  2467. }
  2468. flag__[js] = me;
  2469. if (*iwfr < *lw) {
  2470. goto L40;
  2471. }
  2472. /* PREPARE FOR COMPRESSING IW BY ADJUSTING POINTER TO AND LENGTH OF */
  2473. /* THE LIST FOR IE TO REFER TO THE REMAINING ENTRIES. */
  2474. ipe[ie] = jp;
  2475. iw[jp] = ln - jp1;
  2476. /* COMPRESS IW. */
  2477. i__4 = ip - 1;
  2478. ma27ud_(n, &ipe[1], &iw[1], &i__4, &lwfr, ncmpa);
  2479. /* COPY NEW LIST FORWARD */
  2480. jp2 = *iwfr - 1;
  2481. *iwfr = lwfr;
  2482. if (ip > jp2) {
  2483. goto L30;
  2484. }
  2485. i__4 = jp2;
  2486. for (jp = ip; jp <= i__4; ++jp) {
  2487. iw[*iwfr] = iw[jp];
  2488. ++(*iwfr);
  2489. /* L20: */
  2490. }
  2491. L30:
  2492. ip = lwfr;
  2493. jp = ipe[ie];
  2494. /* ADD VARIABLE JS TO NEW LIST. */
  2495. L40:
  2496. iw[*iwfr] = js;
  2497. /* Computing MIN */
  2498. i__4 = minjs, i__5 = ips[js];
  2499. minjs = min(i__4,i__5);
  2500. ++(*iwfr);
  2501. L50:
  2502. ;
  2503. }
  2504. /* RECORD ABSORPTION OF ELEMENT IE INTO NEW ELEMENT. */
  2505. L60:
  2506. ipe[ie] = -me;
  2507. /* PICK UP NEXT ELEMENT WITH LEADING VARIABLE MS. */
  2508. je = nv[ie];
  2509. /* STORE DEGREE OF IE. */
  2510. nv[ie] = ln + 1;
  2511. ie = je;
  2512. /* LEAVE LOOP IF THERE ARE NO MORE ELEMENTS. */
  2513. if (ie == 0) {
  2514. goto L80;
  2515. }
  2516. /* L70: */
  2517. }
  2518. L80:
  2519. if (*iwfr > ip) {
  2520. goto L90;
  2521. }
  2522. /* DEAL WITH NULL NEW ELEMENT. */
  2523. ipe[me] = 0;
  2524. nv[me] = 1;
  2525. goto L100;
  2526. /* LINK NEW ELEMENT WITH OTHERS HAVING SAME LEADING VARIABLE. */
  2527. L90:
  2528. minjs = ipv[minjs];
  2529. nv[me] = nv[minjs];
  2530. nv[minjs] = me;
  2531. /* MOVE FIRST ENTRY IN NEW LIST TO END TO ALLOW ROOM FOR LENGTH AT */
  2532. /* FRONT. SET POINTER TO FRONT. */
  2533. iw[*iwfr] = iw[ip];
  2534. iw[ip] = *iwfr - ip;
  2535. ipe[me] = ip;
  2536. ++(*iwfr);
  2537. L100:
  2538. ;
  2539. }
  2540. return 0;
  2541. } /* ma27kd_ */
  2542. /* Subroutine */ int ma27ld_(integer *n, integer *ipe, integer *nv, integer *
  2543. ips, integer *ne, integer *na, integer *nd, integer *nsteps, integer *
  2544. nemin)
  2545. {
  2546. /* System generated locals */
  2547. integer i__1, i__2;
  2548. /* Local variables */
  2549. static integer i__, k, l, ib, if__, il, is, nr, ison;
  2550. /* TREE SEARCH */
  2551. /* GIVEN SON TO FATHER TREE POINTERS, PERFORM DEPTH-FIRST */
  2552. /* SEARCH TO FIND PIVOT ORDER AND NUMBER OF ELIMINATIONS */
  2553. /* AND ASSEMBLIES AT EACH STAGE. */
  2554. /* N MUST BE SET TO THE MATRIX ORDER. IT IS NOT ALTERED. */
  2555. /* IPE(I) MUST BE SET EQUAL TO -(FATHER OF NODE I) OR ZERO IF */
  2556. /* NODE IS A ROOT. IT IS ALTERED TO POINT TO ITS NEXT */
  2557. /* YOUNGER BROTHER IF IT HAS ONE, BUT OTHERWISE IS NOT */
  2558. /* CHANGED. */
  2559. /* NV(I) MUST BE SET TO ZERO IF NO VARIABLES ARE ELIMINATED AT NODE */
  2560. /* I AND TO THE DEGREE OTHERWISE. ONLY LEAF NODES CAN HAVE */
  2561. /* ZERO VALUES OF NV(I). NV IS NOT ALTERED. */
  2562. /* IPS(I) NEED NOT BE SET. IT IS USED TEMPORARILY TO HOLD */
  2563. /* -(ELDEST SON OF NODE I) IF IT HAS ONE AND 0 OTHERWISE. IT IS */
  2564. /* EVENTUALLY SET TO HOLD THE POSITION OF NODE I IN THE ORDER. */
  2565. /* NE(IS) NEED NOT BE SET. IT IS SET TO THE NUMBER OF VARIABLES */
  2566. /* ELIMINATED AT STAGE IS OF THE ELIMINATION. */
  2567. /* NA(IS) NEED NOT BE SET. IT IS SET TO THE NUMBER OF ELEMENTS */
  2568. /* ASSEMBLED AT STAGE IS OF THE ELIMINATION. */
  2569. /* ND(IS) NEED NOT BE SET. IT IS SET TO THE DEGREE AT STAGE IS OF */
  2570. /* THE ELIMINATION. */
  2571. /* NSTEPS NEED NOT BE SET. IT IS SET TO THE NUMBER OF ELIMINATION */
  2572. /* STEPS. */
  2573. /* NEMIN see ICNTL(5) in MA27A/AD. */
  2574. /* .. Scalar Arguments .. */
  2575. /* .. */
  2576. /* .. Array Arguments .. */
  2577. /* .. */
  2578. /* .. Local Scalars .. */
  2579. /* .. */
  2580. /* .. Executable Statements .. */
  2581. /* INITIALIZE IPS AND NE. */
  2582. /* Parameter adjustments */
  2583. --nd;
  2584. --na;
  2585. --ne;
  2586. --ips;
  2587. --nv;
  2588. --ipe;
  2589. /* Function Body */
  2590. i__1 = *n;
  2591. for (i__ = 1; i__ <= i__1; ++i__) {
  2592. ips[i__] = 0;
  2593. ne[i__] = 0;
  2594. /* L10: */
  2595. }
  2596. /* SET IPS(I) TO -(ELDEST SON OF NODE I) AND IPE(I) TO NEXT YOUNGER */
  2597. /* BROTHER OF NODE I IF IT HAS ONE. */
  2598. /* FIRST PASS IS FOR NODES WITHOUT ELIMINATIONS. */
  2599. i__1 = *n;
  2600. for (i__ = 1; i__ <= i__1; ++i__) {
  2601. if (nv[i__] > 0) {
  2602. goto L20;
  2603. }
  2604. if__ = -ipe[i__];
  2605. is = -ips[if__];
  2606. if (is > 0) {
  2607. ipe[i__] = is;
  2608. }
  2609. ips[if__] = -i__;
  2610. L20:
  2611. ;
  2612. }
  2613. /* NR IS DECREMENTED FOR EACH ROOT NODE. THESE ARE STORED IN */
  2614. /* NE(I),I=NR,N. */
  2615. nr = *n + 1;
  2616. /* SECOND PASS TO ADD NODES WITH ELIMINATIONS. */
  2617. i__1 = *n;
  2618. for (i__ = 1; i__ <= i__1; ++i__) {
  2619. if (nv[i__] <= 0) {
  2620. goto L50;
  2621. }
  2622. /* NODE IF IS THE FATHER OF NODE I. */
  2623. if__ = -ipe[i__];
  2624. if (if__ == 0) {
  2625. goto L40;
  2626. }
  2627. is = -ips[if__];
  2628. /* JUMP IF NODE IF HAS NO SONS YET. */
  2629. if (is <= 0) {
  2630. goto L30;
  2631. }
  2632. /* SET POINTER TO NEXT BROTHER */
  2633. ipe[i__] = is;
  2634. /* NODE I IS ELDEST SON OF NODE IF. */
  2635. L30:
  2636. ips[if__] = -i__;
  2637. goto L50;
  2638. /* WE HAVE A ROOT */
  2639. L40:
  2640. --nr;
  2641. ne[nr] = i__;
  2642. L50:
  2643. ;
  2644. }
  2645. /* DEPTH-FIRST SEARCH. */
  2646. /* IL HOLDS THE CURRENT TREE LEVEL. ROOTS ARE AT LEVEL N, THEIR SONS */
  2647. /* ARE AT LEVEL N-1, ETC. */
  2648. /* IS HOLDS THE CURRENT ELIMINATION STAGE. WE ACCUMULATE THE NUMBER */
  2649. /* OF ELIMINATIONS AT STAGE IS DIRECTLY IN NE(IS). THE NUMBER OF */
  2650. /* ASSEMBLIES IS ACCUMULATED TEMPORARILY IN NA(IL), FOR TREE */
  2651. /* LEVEL IL, AND IS TRANSFERED TO NA(IS) WHEN WE REACH THE */
  2652. /* APPROPRIATE STAGE IS. */
  2653. is = 1;
  2654. /* I IS THE CURRENT NODE. */
  2655. i__ = 0;
  2656. i__1 = *n;
  2657. for (k = 1; k <= i__1; ++k) {
  2658. if (i__ > 0) {
  2659. goto L60;
  2660. }
  2661. /* PICK UP NEXT ROOT. */
  2662. i__ = ne[nr];
  2663. ne[nr] = 0;
  2664. ++nr;
  2665. il = *n;
  2666. na[*n] = 0;
  2667. /* GO TO SON FOR AS LONG AS POSSIBLE, CLEARING FATHER-SON POINTERS */
  2668. /* IN IPS AS EACH IS USED AND SETTING NA(IL)=0 FOR ALL LEVELS */
  2669. /* REACHED. */
  2670. L60:
  2671. i__2 = *n;
  2672. for (l = 1; l <= i__2; ++l) {
  2673. if (ips[i__] >= 0) {
  2674. goto L80;
  2675. }
  2676. ison = -ips[i__];
  2677. ips[i__] = 0;
  2678. i__ = ison;
  2679. --il;
  2680. na[il] = 0;
  2681. /* L70: */
  2682. }
  2683. /* RECORD POSITION OF NODE I IN THE ORDER. */
  2684. L80:
  2685. ips[i__] = k;
  2686. ++ne[is];
  2687. /* JUMP IF NODE HAS NO ELIMINATIONS. */
  2688. if (nv[i__] <= 0) {
  2689. goto L120;
  2690. }
  2691. if (il < *n) {
  2692. ++na[il + 1];
  2693. }
  2694. na[is] = na[il];
  2695. nd[is] = nv[i__];
  2696. /* CHECK FOR STATIC CONDENSATION */
  2697. if (na[is] != 1) {
  2698. goto L90;
  2699. }
  2700. if (nd[is - 1] - ne[is - 1] == nd[is]) {
  2701. goto L100;
  2702. }
  2703. /* CHECK FOR SMALL NUMBERS OF ELIMINATIONS IN BOTH LAST TWO STEPS. */
  2704. L90:
  2705. if (ne[is] >= *nemin) {
  2706. goto L110;
  2707. }
  2708. if (na[is] == 0) {
  2709. goto L110;
  2710. }
  2711. if (ne[is - 1] >= *nemin) {
  2712. goto L110;
  2713. }
  2714. /* COMBINE THE LAST TWO STEPS */
  2715. L100:
  2716. na[is - 1] = na[is - 1] + na[is] - 1;
  2717. nd[is - 1] = nd[is] + ne[is - 1];
  2718. ne[is - 1] = ne[is] + ne[is - 1];
  2719. ne[is] = 0;
  2720. goto L120;
  2721. L110:
  2722. ++is;
  2723. L120:
  2724. ib = ipe[i__];
  2725. if (ib >= 0) {
  2726. /* NODE I HAS A BROTHER OR IS A ROOT */
  2727. if (ib > 0) {
  2728. na[il] = 0;
  2729. }
  2730. i__ = ib;
  2731. } else {
  2732. /* GO TO FATHER OF NODE I */
  2733. i__ = -ib;
  2734. ++il;
  2735. }
  2736. /* L160: */
  2737. }
  2738. *nsteps = is - 1;
  2739. return 0;
  2740. } /* ma27ld_ */
  2741. /* Subroutine */ int ma27md_(integer *n, integer *nz, integer *irn, integer *
  2742. icn, integer *perm, integer *na, integer *ne, integer *nd, integer *
  2743. nsteps, integer *lstki, integer *lstkr, integer *iw, integer *info,
  2744. doublereal *ops)
  2745. {
  2746. /* System generated locals */
  2747. integer i__1, i__2, i__3;
  2748. /* Local variables */
  2749. static integer i__, k, nz1, nz2, nfr, iold, jold, iorg, jorg, inew, itop,
  2750. lstk, nstk, irow;
  2751. static doublereal delim;
  2752. static integer nelim, itree, istki, nassr, istkr, nirnec, nrlnec, niradu,
  2753. nrladu, numorg, nirtot, nrltot;
  2754. /* STORAGE AND OPERATION COUNT EVALUATION. */
  2755. /* EVALUATE NUMBER OF OPERATIONS AND SPACE REQUIRED BY FACTORIZATION */
  2756. /* USING MA27B/BD. THE VALUES GIVEN ARE EXACT ONLY IF NO NUMERICAL */
  2757. /* PIVOTING IS PERFORMED AND THEN ONLY IF IRN(1) WAS NOT */
  2758. /* EQUIVALENCED TO IW(1) BY THE USER BEFORE CALLING MA27A/AD. IF */
  2759. /* THE EQUIVALENCE HAS BEEN MADE ONLY AN UPPER BOUND FOR NIRNEC */
  2760. /* AND NRLNEC CAN BE CALCULATED ALTHOUGH THE OTHER COUNTS WILL */
  2761. /* STILL BE EXACT. */
  2762. /* N MUST BE SET TO THE MATRIX ORDER. IT IS NOT ALTERED. */
  2763. /* NZ MUST BE SET TO THE NUMBER OF NON-ZEROS INPUT. IT IS NOT ALTERED. */
  2764. /* IRN,ICN. UNLESS IRN(1) HAS BEEN EQUIVALENCED TO IW(1) */
  2765. /* IRN,ICN MUST BE SET TO THE ROW AND COLUMN INDICES OF THE */
  2766. /* NON-ZEROS ON INPUT. THEY ARE NOT ALTERED BY MA27M/MD. */
  2767. /* PERM MUST BE SET TO THE POSITION IN THE PIVOT ORDER OF EACH ROW. */
  2768. /* IT IS NOT ALTERED. */
  2769. /* NA,NE,ND MUST BE SET TO HOLD, FOR EACH TREE NODE, THE NUMBER OF STACK */
  2770. /* ELEMENTS ASSEMBLED, THE NUMBER OF ELIMINATIONS AND THE SIZE OF */
  2771. /* THE ASSEMBLED FRONT MATRIX RESPECTIVELY. THEY ARE NOT ALTERED. */
  2772. /* NSTEPS MUST BE SET TO HOLD THE NUMBER OF TREE NODES. IT IS NOT */
  2773. /* ALTERED. */
  2774. /* LSTKI IS USED AS A WORK ARRAY BY MA27M/MD. */
  2775. /* LSTKR. IF IRN(1) IS EQUIVALENCED TO IW(1) THEN LSTKR(I) */
  2776. /* MUST HOLD THE TOTAL NUMBER OF OFF-DIAGONAL ENTRIES (INCLUDING */
  2777. /* DUPLICATES) IN ROW I (I=1,..,N) OF THE ORIGINAL MATRIX. IT */
  2778. /* IS USED AS WORKSPACE BY MA27M/MD. */
  2779. /* IW IS A WORKSPACE ARRAY USED BY OTHER SUBROUTINES AND PASSED TO THIS */
  2780. /* SUBROUTINE ONLY SO THAT A TEST FOR EQUIVALENCE WITH IRN CAN BE */
  2781. /* MADE. */
  2782. /* COUNTS FOR OPERATIONS AND STORAGE ARE ACCUMULATED IN VARIABLES */
  2783. /* OPS,NRLTOT,NIRTOT,NRLNEC,NIRNEC,NRLADU,NRLNEC,NIRNEC. */
  2784. /* OPS NUMBER OF MULTIPLICATIONS AND ADDITIONS DURING FACTORIZATION. */
  2785. /* NRLADU,NIRADU REAL AND INTEGER STORAGE RESPECTIVELY FOR THE */
  2786. /* MATRIX FACTORS. */
  2787. /* NRLTOT,NIRTOT REAL AND INTEGER STRORAGE RESPECTIVELY REQUIRED */
  2788. /* FOR THE FACTORIZATION IF NO COMPRESSES ARE ALLOWED. */
  2789. /* NRLNEC,NIRNEC REAL AND INTEGER STORAGE RESPECTIVELY REQUIRED FOR */
  2790. /* THE FACTORIZATION IF COMPRESSES ARE ALLOWED. */
  2791. /* INFO is an INTEGER array of length 20, see MA27A/AD. */
  2792. /* OPS ACCUMULATES THE NO. OF MULTIPLY/ADD PAIRS NEEDED TO CREATE THE */
  2793. /* TRIANGULAR FACTORIZATION, IN THE DEFINITE CASE. */
  2794. /* .. Scalar Arguments .. */
  2795. /* .. */
  2796. /* .. Array Arguments .. */
  2797. /* .. */
  2798. /* .. Local Scalars .. */
  2799. /* .. */
  2800. /* .. Intrinsic Functions .. */
  2801. /* .. */
  2802. /* .. Executable Statements .. */
  2803. /* Parameter adjustments */
  2804. --lstkr;
  2805. --lstki;
  2806. --perm;
  2807. --irn;
  2808. --icn;
  2809. --nd;
  2810. --ne;
  2811. --na;
  2812. --iw;
  2813. --info;
  2814. /* Function Body */
  2815. if (*nz == 0) {
  2816. goto L20;
  2817. }
  2818. /* JUMP IF IW AND IRN HAVE NOT BEEN EQUIVALENCED. */
  2819. if (irn[1] != iw[1]) {
  2820. goto L20;
  2821. }
  2822. /* RESET IRN(1). */
  2823. irn[1] = iw[1] - 1;
  2824. /* THE TOTAL NUMBER OF OFF-DIAGONAL ENTRIES IS ACCUMULATED IN NZ2. */
  2825. /* LSTKI IS SET TO HOLD THE TOTAL NUMBER OF ENTRIES (INCUDING */
  2826. /* THE DIAGONAL) IN EACH ROW IN PERMUTED ORDER. */
  2827. nz2 = 0;
  2828. i__1 = *n;
  2829. for (iold = 1; iold <= i__1; ++iold) {
  2830. inew = perm[iold];
  2831. lstki[inew] = lstkr[iold] + 1;
  2832. nz2 += lstkr[iold];
  2833. /* L10: */
  2834. }
  2835. /* NZ1 IS THE NUMBER OF ENTRIES IN ONE TRIANGLE INCLUDING THE DIAGONAL. */
  2836. /* NZ2 IS THE TOTAL NUMBER OF ENTRIES INCLUDING THE DIAGONAL. */
  2837. nz1 = nz2 / 2 + *n;
  2838. nz2 += *n;
  2839. goto L60;
  2840. /* COUNT (IN LSTKI) NON-ZEROS IN ORIGINAL MATRIX BY PERMUTED ROW (UPPER */
  2841. /* TRIANGLE ONLY). INITIALIZE COUNTS. */
  2842. L20:
  2843. i__1 = *n;
  2844. for (i__ = 1; i__ <= i__1; ++i__) {
  2845. lstki[i__] = 1;
  2846. /* L30: */
  2847. }
  2848. /* ACCUMULATE NUMBER OF NON-ZEROS WITH INDICES IN RANGE IN NZ1 */
  2849. /* DUPLICATES ON THE DIAGONAL ARE IGNORED BUT NZ1 INCLUDES ANY */
  2850. /* DIAGONALS NOT PRESENT ON INPUT. */
  2851. /* ACCUMULATE ROW COUNTS IN LSTKI. */
  2852. nz1 = *n;
  2853. if (*nz == 0) {
  2854. goto L50;
  2855. }
  2856. i__1 = *nz;
  2857. for (i__ = 1; i__ <= i__1; ++i__) {
  2858. iold = irn[i__];
  2859. jold = icn[i__];
  2860. /* JUMP IF INDEX IS OUT OF RANGE. */
  2861. if (iold < 1 || iold > *n) {
  2862. goto L40;
  2863. }
  2864. if (jold < 1 || jold > *n) {
  2865. goto L40;
  2866. }
  2867. if (iold == jold) {
  2868. goto L40;
  2869. }
  2870. ++nz1;
  2871. /* Computing MIN */
  2872. i__2 = perm[iold], i__3 = perm[jold];
  2873. irow = min(i__2,i__3);
  2874. ++lstki[irow];
  2875. L40:
  2876. ;
  2877. }
  2878. L50:
  2879. nz2 = nz1;
  2880. /* ISTKR,ISTKI CURRENT NUMBER OF STACK ENTRIES IN */
  2881. /* REAL AND INTEGER STORAGE RESPECTIVELY. */
  2882. /* OPS,NRLADU,NIRADU,NIRTOT,NRLTOT,NIRNEC,NRLNEC,NZ2 ARE DEFINED ABOVE. */
  2883. /* NZ2 CURRENT NUMBER OF ORIGINAL MATRIX ENTRIES NOT YET PROCESSED. */
  2884. /* NUMORG CURRENT TOTAL NUMBER OF ROWS ELIMINATED. */
  2885. /* ITOP CURRENT NUMBER OF ELEMENTS ON THE STACK. */
  2886. L60:
  2887. istki = 0;
  2888. istkr = 0;
  2889. *ops = 0.;
  2890. nrladu = 0;
  2891. /* ONE LOCATION IS NEEDED TO RECORD THE NUMBER OF BLOCKS */
  2892. /* ACTUALLY USED. */
  2893. niradu = 1;
  2894. nirtot = nz1;
  2895. nrltot = nz1;
  2896. nirnec = nz2;
  2897. nrlnec = nz2;
  2898. numorg = 0;
  2899. itop = 0;
  2900. /* EACH PASS THROUGH THIS LOOP PROCESSES A NODE OF THE TREE. */
  2901. i__1 = *nsteps;
  2902. for (itree = 1; itree <= i__1; ++itree) {
  2903. nelim = ne[itree];
  2904. delim = (doublereal) nelim;
  2905. nfr = nd[itree];
  2906. nstk = na[itree];
  2907. /* ADJUST STORAGE COUNTS ON ASSEMBLY OF CURRENT FRONTAL MATRIX. */
  2908. nassr = nfr * (nfr + 1) / 2;
  2909. if (nstk != 0) {
  2910. nassr = nassr - lstkr[itop] + 1;
  2911. }
  2912. /* Computing MAX */
  2913. i__2 = nrltot, i__3 = nrladu + nassr + istkr + nz1;
  2914. nrltot = max(i__2,i__3);
  2915. /* Computing MAX */
  2916. i__2 = nirtot, i__3 = niradu + nfr + 2 + istki + nz1;
  2917. nirtot = max(i__2,i__3);
  2918. /* Computing MAX */
  2919. i__2 = nrlnec, i__3 = nrladu + nassr + istkr + nz2;
  2920. nrlnec = max(i__2,i__3);
  2921. /* Computing MAX */
  2922. i__2 = nirnec, i__3 = niradu + nfr + 2 + istki + nz2;
  2923. nirnec = max(i__2,i__3);
  2924. /* DECREASE NZ2 BY THE NUMBER OF ENTRIES IN ROWS BEING ELIMINATED AT */
  2925. /* THIS STAGE. */
  2926. i__2 = nelim;
  2927. for (iorg = 1; iorg <= i__2; ++iorg) {
  2928. jorg = numorg + iorg;
  2929. nz2 -= lstki[jorg];
  2930. /* L70: */
  2931. }
  2932. numorg += nelim;
  2933. /* JUMP IF THERE ARE NO STACK ASSEMBLIES AT THIS NODE. */
  2934. if (nstk <= 0) {
  2935. goto L90;
  2936. }
  2937. /* REMOVE ELEMENTS FROM THE STACK. THERE ARE ITOP ELEMENTS ON THE */
  2938. /* STACK WITH THE APPROPRIATE ENTRIES IN LSTKR,LSTKI GIVING */
  2939. /* THE REAL AND INTEGER STORAGE RESPECTIVELY FOR EACH STACK */
  2940. /* ELEMENT. */
  2941. i__2 = nstk;
  2942. for (k = 1; k <= i__2; ++k) {
  2943. lstk = lstkr[itop];
  2944. istkr -= lstk;
  2945. lstk = lstki[itop];
  2946. istki -= lstk;
  2947. --itop;
  2948. /* L80: */
  2949. }
  2950. /* ACCUMULATE NON-ZEROS IN FACTORS AND NUMBER OF OPERATIONS. */
  2951. L90:
  2952. nrladu += nelim * ((nfr << 1) - nelim + 1) / 2;
  2953. niradu = niradu + 2 + nfr;
  2954. if (nelim == 1) {
  2955. --niradu;
  2956. }
  2957. *ops += (nfr * delim * (nfr + 1) - ((nfr << 1) + 1) * delim * (delim
  2958. + 1) / 2 + delim * (delim + 1) * (delim * 2 + 1) / 6) / 2;
  2959. if (itree == *nsteps) {
  2960. goto L100;
  2961. }
  2962. /* JUMP IF ALL OF FRONTAL MATRIX HAS BEEN ELIMINATED. */
  2963. if (nfr == nelim) {
  2964. goto L100;
  2965. }
  2966. /* STACK REMAINDER OF ELEMENT. */
  2967. ++itop;
  2968. lstkr[itop] = (nfr - nelim) * (nfr - nelim + 1) / 2;
  2969. lstki[itop] = nfr - nelim + 1;
  2970. istki += lstki[itop];
  2971. istkr += lstkr[itop];
  2972. /* WE DO NOT NEED TO ADJUST THE COUNTS FOR THE REAL STORAGE BECAUSE */
  2973. /* THE REMAINDER OF THE FRONTAL MATRIX IS SIMPLY MOVED IN THE */
  2974. /* STORAGE FROM FACTORS TO STACK AND NO EXTRA STORAGE IS REQUIRED. */
  2975. /* Computing MAX */
  2976. i__2 = nirtot, i__3 = niradu + istki + nz1;
  2977. nirtot = max(i__2,i__3);
  2978. /* Computing MAX */
  2979. i__2 = nirnec, i__3 = niradu + istki + nz2;
  2980. nirnec = max(i__2,i__3);
  2981. L100:
  2982. ;
  2983. }
  2984. /* ADJUST THE STORAGE COUNTS TO ALLOW FOR THE USE OF THE REAL AND */
  2985. /* INTEGER STORAGE FOR PURPOSES OTHER THAN PURELY THE */
  2986. /* FACTORIZATION ITSELF. */
  2987. /* THE SECOND TWO TERMS ARE THE MINUMUM AMOUNT REQUIRED BY MA27N/ND. */
  2988. /* Computing MAX */
  2989. i__1 = nrlnec, i__2 = *n + max(*nz,nz1);
  2990. nrlnec = max(i__1,i__2);
  2991. /* Computing MAX */
  2992. i__1 = nrltot, i__2 = *n + max(*nz,nz1);
  2993. nrltot = max(i__1,i__2);
  2994. nrlnec = min(nrlnec,nrltot);
  2995. nirnec = max(*nz,nirnec);
  2996. nirtot = max(*nz,nirtot);
  2997. nirnec = min(nirnec,nirtot);
  2998. info[3] = nrltot;
  2999. info[4] = nirtot;
  3000. info[5] = nrlnec;
  3001. info[6] = nirnec;
  3002. info[7] = nrladu;
  3003. info[8] = niradu;
  3004. return 0;
  3005. } /* ma27md_ */
  3006. /* Subroutine */ int ma27nd_(integer *n, integer *nz, integer *nz1,
  3007. doublereal *a, integer *la, integer *irn, integer *icn, integer *iw,
  3008. integer *liw, integer *perm, integer *iw2, integer *icntl, integer *
  3009. info)
  3010. {
  3011. /* Format strings */
  3012. static char fmt_40[] = "(\002 *** WARNING MESSAGE FROM SUBROUTINE MA27B"
  3013. "D\002,\002 *** INFO(1) =\002,i2)";
  3014. static char fmt_50[] = "(i6,\002TH NON-ZERO (IN ROW\002,i6,\002 AND COLU"
  3015. "MN\002,i6,\002) IGNORED\002)";
  3016. /* System generated locals */
  3017. integer i__1, i__2;
  3018. /* Builtin functions */
  3019. integer s_wsfe(cilist *), do_fio(integer *, char *, ftnlen), e_wsfe(void);
  3020. /* Local variables */
  3021. static integer i__, k, j1, j2, ia, ii, jj, ich, iiw, iold, jold, inew;
  3022. static doublereal anow;
  3023. static integer jnew, ipos, jpos;
  3024. static doublereal anext;
  3025. /* Fortran I/O blocks */
  3026. static cilist io___212 = { 0, 0, 0, fmt_40, 0 };
  3027. static cilist io___213 = { 0, 0, 0, fmt_50, 0 };
  3028. /* SORT PRIOR TO FACTORIZATION USING MA27O/OD. */
  3029. /* THIS SUBROUTINE REORDERS THE USER'S INPUT SO THAT THE UPPER TRIANGLE */
  3030. /* OF THE PERMUTED MATRIX, INCLUDING THE DIAGONAL, IS */
  3031. /* HELD ORDERED BY ROWS AT THE END OF THE STORAGE FOR A AND IW. */
  3032. /* IT IGNORES ENTRIES WITH ONE OR BOTH INDICES OUT OF RANGE AND */
  3033. /* ACCUMULATES DIAGONAL ENTRIES. */
  3034. /* IT ADDS EXPLICIT ZEROS ON THE DIAGONAL WHERE NECESSARY. */
  3035. /* N - MUST BE SET TO THE ORDER OF THE MATRIX. */
  3036. /* IT IS NOT ALTERED BY MA27N/ND. */
  3037. /* NZ - ON ENTRY NZ MUST BE SET TO THE NUMBER */
  3038. /* OF NON-ZEROS INPUT. NOT ALTERED BY MA27N/ND. */
  3039. /* NZ1 - ON EXIT NZ1 WILL BE EQUAL TO THE NUMBER OF ENTRIES IN THE */
  3040. /* SORTED MATRIX. */
  3041. /* A - ON ENTRY A(I) MUST */
  3042. /* HOLD THE VALUE OF THE ORIGINAL MATRIX ELEMENT IN POSITION */
  3043. /* (IRN(I),ICN(I)),I=1,NZ. ON EXIT A(LA-NZ1+I),I=1,NZ1 HOLDS */
  3044. /* THE UPPER TRIANGLE OF THE PERMUTED MATRIX BY ROWS WITH */
  3045. /* THE DIAGONAL ENTRY FIRST ALTHOUGH THERE IS NO FURTHER */
  3046. /* ORDERING WITHIN THE ROWS THEMSELVES. */
  3047. /* LA - LENGTH OF ARRAY A. MUST BE AT LEAST N+MAX(NZ,NZ1). */
  3048. /* IT IS NOT ALTERED BY MA27N/ND. */
  3049. /* IRN - IRN(I) MUST BE SET TO */
  3050. /* HOLD THE ROW INDEX OF ENTRY A(I),I=1,NZ. IRN WILL BE */
  3051. /* UNALTERED BY MA27N/ND, UNLESS IT IS EQUIVALENCED WITH IW. */
  3052. /* ICN - ICN(I) MUST BE SET TO */
  3053. /* HOLD THE COLUMN INDEX OF ENTRY A(I),I=1,NZ. ICN WILL BE */
  3054. /* UNALTERED BY MA27N/ND, UNLESS IT IS EQUIVALENCED WITH IW. */
  3055. /* IW - USED AS WORKSPACE AND ON */
  3056. /* EXIT, ENTRIES IW(LIW-NZ1+I),I=1,NZ1 HOLD THE COLUMN INDICES */
  3057. /* (THE ORIGINAL UNPERMUTED INDICES) OF THE CORRESPONDING ENTRY */
  3058. /* OF A WITH THE FIRST ENTRY FOR EACH ROW FLAGGED NEGATIVE. */
  3059. /* IRN(1) MAY BE EQUIVALENCED WITH IW(1) AND ICN(1) MAY BE */
  3060. /* EQUIVALENCED WITH IW(K) WHERE K.GT.NZ. */
  3061. /* LIW - LENGTH OF ARRAY IW. MUST BE AT LEAST AS */
  3062. /* GREAT AS THE MAXIMUM OF NZ AND NZ1. */
  3063. /* NOT ALTERED BY MA27N/ND. */
  3064. /* PERM - PERM(I) HOLDS THE */
  3065. /* POSITION IN THE TENTATIVE PIVOT ORDER OF ROW I IN THE */
  3066. /* ORIGINAL MATRIX,I=1,N. NOT ALTERED BY MA27N/ND. */
  3067. /* IW2 - USED AS WORKSPACE. */
  3068. /* SEE COMMENTS IN CODE IMMEDIATELY PRIOR TO */
  3069. /* EACH USE. */
  3070. /* ICNTL is an INTEGER array of length 30, see MA27A/AD. */
  3071. /* INFO is an INTEGER array of length 20, see MA27A/AD. */
  3072. /* INFO(1) - ON EXIT FROM MA27N/ND, A ZERO VALUE OF */
  3073. /* INFO(1) INDICATES THAT NO ERROR HAS BEEN DETECTED. */
  3074. /* POSSIBLE NON-ZERO VALUES ARE .. */
  3075. /* +1 WARNING. INDICES OUT OF RANGE. THESE ARE IGNORED, */
  3076. /* THEIR NUMBER IS RECORDED IN INFO(2) OF MA27E/ED AND */
  3077. /* MESSAGES IDENTIFYING THE FIRST TEN ARE OUTPUT ON UNIT */
  3078. /* ICNTL(2). */
  3079. /* -3 INTEGER ARRAY IW IS TOO SMALL. */
  3080. /* -4 DOUBLE PRECISION ARRAY A IS TOO SMALL. */
  3081. /* .. Parameters .. */
  3082. /* .. */
  3083. /* .. Scalar Arguments .. */
  3084. /* .. */
  3085. /* .. Array Arguments .. */
  3086. /* .. */
  3087. /* .. Local Scalars .. */
  3088. /* .. */
  3089. /* .. Intrinsic Functions .. */
  3090. /* .. */
  3091. /* .. Executable Statements .. */
  3092. /* Parameter adjustments */
  3093. --iw2;
  3094. --perm;
  3095. --a;
  3096. --irn;
  3097. --icn;
  3098. --iw;
  3099. --icntl;
  3100. --info;
  3101. /* Function Body */
  3102. info[1] = 0;
  3103. /* INITIALIZE WORK ARRAY (IW2) IN PREPARATION FOR */
  3104. /* COUNTING NUMBERS OF NON-ZEROS IN THE ROWS AND INITIALIZE */
  3105. /* LAST N ENTRIES IN A WHICH WILL HOLD THE DIAGONAL ENTRIES */
  3106. ia = *la;
  3107. i__1 = *n;
  3108. for (iold = 1; iold <= i__1; ++iold) {
  3109. iw2[iold] = 1;
  3110. a[ia] = 0.;
  3111. --ia;
  3112. /* L10: */
  3113. }
  3114. /* SCAN INPUT COPYING ROW INDICES FROM IRN TO THE FIRST NZ POSITIONS */
  3115. /* IN IW. THE NEGATIVE OF THE INDEX IS HELD TO FLAG ENTRIES FOR */
  3116. /* THE IN-PLACE SORT. ENTRIES IN IW CORRESPONDING TO DIAGONALS AND */
  3117. /* ENTRIES WITH OUT-OF-RANGE INDICES ARE SET TO ZERO. */
  3118. /* FOR DIAGONAL ENTRIES, REALS ARE ACCUMULATED IN THE LAST N */
  3119. /* LOCATIONS OF A. */
  3120. /* THE NUMBER OF ENTRIES IN EACH ROW OF THE PERMUTED MATRIX IS */
  3121. /* ACCUMULATED IN IW2. */
  3122. /* INDICES OUT OF RANGE ARE IGNORED AFTER BEING COUNTED AND */
  3123. /* AFTER APPROPRIATE MESSAGES HAVE BEEN PRINTED. */
  3124. info[2] = 0;
  3125. /* NZ1 IS THE NUMBER OF NON-ZEROS HELD AFTER INDICES OUT OF RANGE HAVE */
  3126. /* BEEN IGNORED AND DIAGONAL ENTRIES ACCUMULATED. */
  3127. *nz1 = *n;
  3128. if (*nz == 0) {
  3129. goto L80;
  3130. }
  3131. i__1 = *nz;
  3132. for (k = 1; k <= i__1; ++k) {
  3133. iold = irn[k];
  3134. if (iold > *n || iold <= 0) {
  3135. goto L30;
  3136. }
  3137. jold = icn[k];
  3138. if (jold > *n || jold <= 0) {
  3139. goto L30;
  3140. }
  3141. inew = perm[iold];
  3142. jnew = perm[jold];
  3143. if (inew != jnew) {
  3144. goto L20;
  3145. }
  3146. ia = *la - *n + iold;
  3147. a[ia] += a[k];
  3148. goto L60;
  3149. L20:
  3150. inew = min(inew,jnew);
  3151. /* INCREMENT NUMBER OF ENTRIES IN ROW INEW. */
  3152. ++iw2[inew];
  3153. iw[k] = -iold;
  3154. ++(*nz1);
  3155. goto L70;
  3156. /* ENTRY OUT OF RANGE. IT WILL BE IGNORED AND A FLAG SET. */
  3157. L30:
  3158. info[1] = 1;
  3159. ++info[2];
  3160. if (info[2] <= 1 && icntl[2] > 0) {
  3161. io___212.ciunit = icntl[2];
  3162. s_wsfe(&io___212);
  3163. do_fio(&c__1, (char *)&info[1], (ftnlen)sizeof(integer));
  3164. e_wsfe();
  3165. }
  3166. if (info[2] <= 10 && icntl[2] > 0) {
  3167. io___213.ciunit = icntl[2];
  3168. s_wsfe(&io___213);
  3169. do_fio(&c__1, (char *)&k, (ftnlen)sizeof(integer));
  3170. do_fio(&c__1, (char *)&irn[k], (ftnlen)sizeof(integer));
  3171. do_fio(&c__1, (char *)&icn[k], (ftnlen)sizeof(integer));
  3172. e_wsfe();
  3173. }
  3174. L60:
  3175. iw[k] = 0;
  3176. L70:
  3177. ;
  3178. }
  3179. /* CALCULATE POINTERS (IN IW2) TO THE POSITION IMMEDIATELY AFTER THE END */
  3180. /* OF EACH ROW. */
  3181. L80:
  3182. if (*nz < *nz1 && *nz1 != *n) {
  3183. goto L100;
  3184. }
  3185. /* ROOM IS INCLUDED FOR THE DIAGONALS. */
  3186. k = 1;
  3187. i__1 = *n;
  3188. for (i__ = 1; i__ <= i__1; ++i__) {
  3189. k += iw2[i__];
  3190. iw2[i__] = k;
  3191. /* L90: */
  3192. }
  3193. goto L120;
  3194. /* ROOM IS NOT INCLUDED FOR THE DIAGONALS. */
  3195. L100:
  3196. k = 1;
  3197. i__1 = *n;
  3198. for (i__ = 1; i__ <= i__1; ++i__) {
  3199. k = k + iw2[i__] - 1;
  3200. iw2[i__] = k;
  3201. /* L110: */
  3202. }
  3203. /* FAIL IF INSUFFICIENT SPACE IN ARRAYS A OR IW. */
  3204. L120:
  3205. if (*nz1 > *liw) {
  3206. goto L210;
  3207. }
  3208. if (*nz1 + *n > *la) {
  3209. goto L220;
  3210. }
  3211. /* NOW RUN THROUGH NON-ZEROS IN ORDER PLACING THEM IN THEIR NEW */
  3212. /* POSITION AND DECREMENTING APPROPRIATE IW2 ENTRY. IF WE ARE */
  3213. /* ABOUT TO OVERWRITE AN ENTRY NOT YET MOVED, WE MUST DEAL WITH */
  3214. /* THIS AT THIS TIME. */
  3215. if (*nz1 == *n) {
  3216. goto L180;
  3217. }
  3218. i__1 = *nz;
  3219. for (k = 1; k <= i__1; ++k) {
  3220. iold = -iw[k];
  3221. if (iold <= 0) {
  3222. goto L140;
  3223. }
  3224. jold = icn[k];
  3225. anow = a[k];
  3226. iw[k] = 0;
  3227. i__2 = *nz;
  3228. for (ich = 1; ich <= i__2; ++ich) {
  3229. inew = perm[iold];
  3230. jnew = perm[jold];
  3231. inew = min(inew,jnew);
  3232. if (inew == perm[jold]) {
  3233. jold = iold;
  3234. }
  3235. jpos = iw2[inew] - 1;
  3236. iold = -iw[jpos];
  3237. anext = a[jpos];
  3238. a[jpos] = anow;
  3239. iw[jpos] = jold;
  3240. iw2[inew] = jpos;
  3241. if (iold == 0) {
  3242. goto L140;
  3243. }
  3244. anow = anext;
  3245. jold = icn[jpos];
  3246. /* L130: */
  3247. }
  3248. L140:
  3249. ;
  3250. }
  3251. if (*nz >= *nz1) {
  3252. goto L180;
  3253. }
  3254. /* MOVE UP ENTRIES TO ALLOW FOR DIAGONALS. */
  3255. ipos = *nz1;
  3256. jpos = *nz1 - *n;
  3257. i__1 = *n;
  3258. for (ii = 1; ii <= i__1; ++ii) {
  3259. i__ = *n - ii + 1;
  3260. j1 = iw2[i__];
  3261. j2 = jpos;
  3262. if (j1 > jpos) {
  3263. goto L160;
  3264. }
  3265. i__2 = j2;
  3266. for (jj = j1; jj <= i__2; ++jj) {
  3267. iw[ipos] = iw[jpos];
  3268. a[ipos] = a[jpos];
  3269. --ipos;
  3270. --jpos;
  3271. /* L150: */
  3272. }
  3273. L160:
  3274. iw2[i__] = ipos + 1;
  3275. --ipos;
  3276. /* L170: */
  3277. }
  3278. /* RUN THROUGH ROWS INSERTING DIAGONAL ENTRIES AND FLAGGING BEGINNING */
  3279. /* OF EACH ROW BY NEGATING FIRST COLUMN INDEX. */
  3280. L180:
  3281. i__1 = *n;
  3282. for (iold = 1; iold <= i__1; ++iold) {
  3283. inew = perm[iold];
  3284. jpos = iw2[inew] - 1;
  3285. ia = *la - *n + iold;
  3286. a[jpos] = a[ia];
  3287. iw[jpos] = -iold;
  3288. /* L190: */
  3289. }
  3290. /* MOVE SORTED MATRIX TO THE END OF THE ARRAYS. */
  3291. ipos = *nz1;
  3292. ia = *la;
  3293. iiw = *liw;
  3294. i__1 = *nz1;
  3295. for (i__ = 1; i__ <= i__1; ++i__) {
  3296. a[ia] = a[ipos];
  3297. iw[iiw] = iw[ipos];
  3298. --ipos;
  3299. --ia;
  3300. --iiw;
  3301. /* L200: */
  3302. }
  3303. goto L230;
  3304. /* **** ERROR RETURN **** */
  3305. L210:
  3306. info[1] = -3;
  3307. info[2] = *nz1;
  3308. goto L230;
  3309. L220:
  3310. info[1] = -4;
  3311. info[2] = *nz1 + *n;
  3312. L230:
  3313. return 0;
  3314. } /* ma27nd_ */
  3315. /* Subroutine */ int ma27od_(integer *n, integer *nz, doublereal *a, integer *
  3316. la, integer *iw, integer *liw, integer *perm, integer *nstk, integer *
  3317. nsteps, integer *maxfrt, integer *nelim, integer *iw2, integer *icntl,
  3318. doublereal *cntl, integer *info)
  3319. {
  3320. /* Format strings */
  3321. static char fmt_310[] = "(\002 *** WARNING MESSAGE FROM SUBROUTINE MA2"
  3322. "7BD\002,\002 *** INFO(1) =\002,i2,/,\002 PIVOT\002,i6,\002 HAS "
  3323. "DIFFERENT SIGN FROM THE PREVIOUS ONE\002)";
  3324. /* System generated locals */
  3325. integer i__1, i__2, i__3, i__4, i__5;
  3326. doublereal d__1, d__2, d__3, d__4;
  3327. /* Builtin functions */
  3328. integer s_wsfe(cilist *), do_fio(integer *, char *, ftnlen), e_wsfe(void);
  3329. /* Local variables */
  3330. static integer i__, j, k, j1, j2, k1, k2, jj, kk, lt;
  3331. static doublereal uu;
  3332. static integer jj1, jjj, ifr, ibeg, iend, neig, iell;
  3333. static doublereal amax;
  3334. static integer jcol, nblk, iass, iorg, apos, astk, jmax, jnew;
  3335. static doublereal rmax;
  3336. static integer ipiv;
  3337. static doublereal tmax;
  3338. static integer ipos, istk, jpiv, jpos, kmax, irow, krow, nass, npiv, ntwo;
  3339. static doublereal swop;
  3340. static integer apos1, apos2, apos3, astk2, istk2, laell;
  3341. extern /* Subroutine */ int ma27pd_(doublereal *, integer *, integer *,
  3342. integer *, integer *, integer *, integer *, integer *);
  3343. static integer iexch, liell, newel, jlast, azero, lnass;
  3344. static doublereal amult;
  3345. static integer ipmnp, jnext, lnpiv, iswop, iwpos, lapos2;
  3346. static doublereal amult1, amult2;
  3347. static integer npivp1, pospv1, pospv2, ncmpbi, posfac, ncmpbr, nirbdu,
  3348. nrlbdu, ioldps;
  3349. static doublereal detpiv, thresh;
  3350. static integer ainput, jfirst, idummy, jdummy, jmxmip, kdummy, iinput,
  3351. isnpiv, nfront, numass, numorg, numstk, pivsiz, ltopst, ntotpv;
  3352. /* Fortran I/O blocks */
  3353. static cilist io___280 = { 0, 0, 0, fmt_310, 0 };
  3354. /* FACTORIZATION SUBROUTINE */
  3355. /* THIS SUBROUTINE OPERATES ON THE INPUT MATRIX ORDERED BY MA27N/ND AND */
  3356. /* PRODUCES THE FACTORS OF U AND D ('A'=UTRANSPOSE*D*U) FOR USE IN */
  3357. /* SUBSEQUENT SOLUTIONS. GAUSSIAN ELIMINATION IS USED WITH PIVOTS */
  3358. /* CHOSEN FROM THE DIAGONAL. TO ENSURE STABILITY, BLOCK PIVOTS OF */
  3359. /* ORDER 2 WILL BE USED IF THE DIAGONAL ENTRY IS NOT LARGE ENOUGH. */
  3360. /* N - MUST BE SET TO THE ORDER OF THE MATRIX. IT IS NOT ALTERED. */
  3361. /* NZ - MUST BE SET TO THE NUMBER OF NON-ZEROS IN UPPER TRIANGLE OF */
  3362. /* PERMUTED MATRIX. NOT ALTERED BY MA27O/OD. */
  3363. /* A - MUST BE SET ON INPUT TO MATRIX HELD BY ROWS REORDERED BY */
  3364. /* PERMUTATION FROM MA27A/AD IN A(LA-NZ+I),I=1,NZ. ON */
  3365. /* EXIT FROM MA27O/OD, THE FACTORS OF U AND D ARE HELD IN */
  3366. /* POSITIONS 1 TO POSFAC-1. */
  3367. /* LA - LENGTH OF ARRAY A. A VALUE FOR LA */
  3368. /* SUFFICIENT FOR DEFINITE SYSTEMS */
  3369. /* WILL HAVE BEEN PROVIDED BY MA27A/AD. NOT ALTERED BY MA27O/OD. */
  3370. /* IW - MUST BE SET SO THAT,ON INPUT, IW(LIW-NZ+I),I=1,NZ */
  3371. /* HOLDS THE COLUMN INDEX OF THE ENTRY IN A(LA-NZ+I). ON EXIT, */
  3372. /* IW HOLDS INTEGER INDEXING INFORMATION ON THE FACTORS. */
  3373. /* THE ABSOLUTE VALUE OF THE FIRST ENTRY IN IW WILL BE SET TO */
  3374. /* THE NUMBER OF BLOCK PIVOTS ACTUALLY USED. THIS MAY BE */
  3375. /* DIFFERENT FROM NSTEPS SINCE NUMERICAL CONSIDERATIONS */
  3376. /* MAY PREVENT US CHOOSING A PIVOT AT EACH STAGE. IF THIS ENTRY */
  3377. /* IN IW IS NEGATIVE, THEN AT LEAST ONE TWO BY TWO */
  3378. /* PIVOT HAS BEEN USED DURING THE DECOMPOSITION. */
  3379. /* INTEGER INFORMATION ON EACH BLOCK PIVOT ROW FOLLOWS. FOR */
  3380. /* EACH BLOCK PIVOT ROW THE COLUMN INDICES ARE PRECEDED BY A */
  3381. /* COUNT OF THE NUMBER OF ROWS AND COLUMNS IN THE BLOCK PIVOT */
  3382. /* WHERE, IF ONLY ONE ROW IS PRESENT, ONLY THE NUMBER OF */
  3383. /* COLUMNS TOGETHER WITH A NEGATIVE FLAG IS HELD. THE FIRST */
  3384. /* COLUMN INDEX FOR A TWO BY TWO PIVOT IS FLAGGED NEGATIVE. */
  3385. /* LIW - LENGTH OF ARRAY IW. A VALUE FOR LIW SUFFICIENT FOR */
  3386. /* DEFINITE SYSTEMS */
  3387. /* WILL HAVE BEEN PROVIDED BY MA27A/AD. NOT ALTERED BY MA27O/OD */
  3388. /* PERM - PERM(I) MUST BE SET TO POSITION OF ROW/COLUMN I IN THE */
  3389. /* TENTATIVE PIVOT ORDER GENERATED BY MA27A/AD. */
  3390. /* IT IS NOT ALTERED BY MA27O/OD. */
  3391. /* NSTK - MUST BE LEFT UNCHANGED SINCE OUTPUT FROM MA27A/AD. NSTK(I) */
  3392. /* GIVES THE NUMBER OF GENERATED STACK ELEMENTS ASSEMBLED AT */
  3393. /* STAGE I. IT IS NOT ALTERED BY MA27O/OD. */
  3394. /* NSTEPS - LENGTH OF ARRAYS NSTK AND NELIM. VALUE IS GIVEN ON OUTPUT */
  3395. /* FROM MA27A/AD (WILL NEVER EXCEED N). IT IS NOT ALTERED BY */
  3396. /* MA27O/OD. */
  3397. /* MAXFRT - NEED NOT BE SET ON INPUT. ON OUTPUT */
  3398. /* MAXFRT WILL BE SET TO THE MAXIMUM FRONT SIZE ENCOUNTERED */
  3399. /* DURING THE DECOMPOSITION. */
  3400. /* NELIM - MUST BE UNCHANGED SINCE OUTPUT FROM MA27A/AD. NELIM(I) */
  3401. /* GIVES THE NUMBER OF ORIGINAL ROWS ASSEMBLED AT STAGE I. */
  3402. /* IT IS NOT ALTERED BY MA27O/OD. */
  3403. /* IW2 - INTEGER ARRAY OF LENGTH N. USED AS WORKSPACE BY MA27O/OD. */
  3404. /* ALTHOUGH WE COULD HAVE USED A SHORT WORD INTEGER IN THE IBM */
  3405. /* VERSION, WE HAVE NOT DONE SO BECAUSE THERE IS A SPARE */
  3406. /* FULL INTEGER ARRAY (USED IN THE SORT BEFORE MA27O/OD) */
  3407. /* AVAILABLE WHEN MA27O/OD IS CALLED FROM MA27B/BD. */
  3408. /* ICNTL is an INTEGER array of length 30, see MA27A/AD. */
  3409. /* CNTL is a DOUBLE PRECISION array of length 5, see MA27A/AD. */
  3410. /* INFO is an INTEGER array of length 20, see MA27A/AD. */
  3411. /* INFO(1) - INTEGER VARIABLE. DIAGNOSTIC FLAG. A ZERO VALUE ON EXIT */
  3412. /* INDICATES SUCCESS. POSSIBLE NEGATIVE VALUES ARE ... */
  3413. /* -3 INSUFFICIENT STORAGE FOR IW. */
  3414. /* -4 INSUFFICIENT STORAGE FOR A. */
  3415. /* -5 ZERO PIVOT FOUND IN FACTORIZATION OF DEFINITE MATRIX. */
  3416. /* .. Parameters .. */
  3417. /* .. */
  3418. /* .. Scalar Arguments .. */
  3419. /* .. */
  3420. /* .. Array Arguments .. */
  3421. /* .. */
  3422. /* .. Local Scalars .. */
  3423. /* .. */
  3424. /* .. External Subroutines .. */
  3425. /* .. */
  3426. /* .. Intrinsic Functions .. */
  3427. /* .. */
  3428. /* .. Statement Functions .. */
  3429. /* .. */
  3430. /* .. Statement Function definitions .. */
  3431. /* THE FOLLOWING ARITHMETIC FUNCTION GIVES THE DISPLACEMENT FROM */
  3432. /* THE START OF THE ASSEMBLED MATRIX(OF ORDER IX) OF THE DIAGONAL */
  3433. /* ENTRY IN ITS ROW IY. */
  3434. /* .. */
  3435. /* .. Executable Statements .. */
  3436. /* INITIALIZATION. */
  3437. /* NBLK IS THE NUMBER OF BLOCK PIVOTS USED. */
  3438. /* Parameter adjustments */
  3439. --iw2;
  3440. --perm;
  3441. --a;
  3442. --iw;
  3443. --nelim;
  3444. --nstk;
  3445. --icntl;
  3446. --cntl;
  3447. --info;
  3448. /* Function Body */
  3449. nblk = 0;
  3450. ntwo = 0;
  3451. neig = 0;
  3452. ncmpbi = 0;
  3453. ncmpbr = 0;
  3454. *maxfrt = 0;
  3455. nrlbdu = 0;
  3456. nirbdu = 0;
  3457. /* A PRIVATE VARIABLE UU IS SET TO CNTL(1), SO THAT CNTL(1) WILL REMAIN */
  3458. /* UNALTERED. */
  3459. uu = min(cntl[1],.5);
  3460. uu = max(uu,-.5);
  3461. i__1 = *n;
  3462. for (i__ = 1; i__ <= i__1; ++i__) {
  3463. iw2[i__] = 0;
  3464. /* L10: */
  3465. }
  3466. /* IWPOS IS POINTER TO FIRST FREE POSITION FOR FACTORS IN IW. */
  3467. /* POSFAC IS POINTER FOR FACTORS IN A. AT EACH PASS THROUGH THE */
  3468. /* MAJOR LOOP POSFAC INITIALLY POINTS TO THE FIRST FREE LOCATION */
  3469. /* IN A AND THEN IS SET TO THE POSITION OF THE CURRENT PIVOT IN A. */
  3470. /* ISTK IS POINTER TO TOP OF STACK IN IW. */
  3471. /* ISTK2 IS POINTER TO BOTTOM OF STACK IN IW (NEEDED BY COMPRESS). */
  3472. /* ASTK IS POINTER TO TOP OF STACK IN A. */
  3473. /* ASTK2 IS POINTER TO BOTTOM OF STACK IN A (NEEDED BY COMPRESS). */
  3474. /* IINPUT IS POINTER TO CURRENT POSITION IN ORIGINAL ROWS IN IW. */
  3475. /* AINPUT IS POINTER TO CURRENT POSITION IN ORIGINAL ROWS IN A. */
  3476. /* AZERO IS POINTER TO LAST POSITION ZEROED IN A. */
  3477. /* NTOTPV IS THE TOTAL NUMBER OF PIVOTS SELECTED. THIS IS USED */
  3478. /* TO DETERMINE WHETHER THE MATRIX IS SINGULAR. */
  3479. iwpos = 2;
  3480. posfac = 1;
  3481. istk = *liw - *nz + 1;
  3482. istk2 = istk - 1;
  3483. astk = *la - *nz + 1;
  3484. astk2 = astk - 1;
  3485. iinput = istk;
  3486. ainput = astk;
  3487. azero = 0;
  3488. ntotpv = 0;
  3489. /* NUMASS IS THE ACCUMULATED NUMBER OF ROWS ASSEMBLED SO FAR. */
  3490. numass = 0;
  3491. /* EACH PASS THROUGH THIS MAIN LOOP PERFORMS ALL THE OPERATIONS */
  3492. /* ASSOCIATED WITH ONE SET OF ASSEMBLY/ELIMINATIONS. */
  3493. i__1 = *nsteps;
  3494. for (iass = 1; iass <= i__1; ++iass) {
  3495. /* NASS WILL BE SET TO THE NUMBER OF FULLY ASSEMBLED VARIABLES IN */
  3496. /* CURRENT NEWLY CREATED ELEMENT. */
  3497. nass = nelim[iass];
  3498. /* NEWEL IS A POINTER INTO IW TO CONTROL OUTPUT OF INTEGER INFORMATION */
  3499. /* FOR NEWLY CREATED ELEMENT. */
  3500. newel = iwpos + 1;
  3501. /* SYMBOLICALLY ASSEMBLE INCOMING ROWS AND GENERATED STACK ELEMENTS */
  3502. /* ORDERING THE RESULTANT ELEMENT ACCORDING TO PERMUTATION PERM. WE */
  3503. /* ASSEMBLE THE STACK ELEMENTS FIRST BECAUSE THESE WILL ALREADY BE */
  3504. /* ORDERED. */
  3505. /* SET HEADER POINTER FOR MERGE OF INDEX LISTS. */
  3506. jfirst = *n + 1;
  3507. /* INITIALIZE NUMBER OF VARIABLES IN CURRENT FRONT. */
  3508. nfront = 0;
  3509. numstk = nstk[iass];
  3510. ltopst = 1;
  3511. lnass = 0;
  3512. /* JUMP IF NO STACK ELEMENTS ARE BEING ASSEMBLED AT THIS STAGE. */
  3513. if (numstk == 0) {
  3514. goto L80;
  3515. }
  3516. j2 = istk - 1;
  3517. lnass = nass;
  3518. ltopst = (iw[istk] + 1) * iw[istk] / 2;
  3519. i__2 = numstk;
  3520. for (iell = 1; iell <= i__2; ++iell) {
  3521. /* ASSEMBLE ELEMENT IELL PLACING */
  3522. /* THE INDICES INTO A LINKED LIST IN IW2 ORDERED */
  3523. /* ACCORDING TO PERM. */
  3524. jnext = jfirst;
  3525. jlast = *n + 1;
  3526. j1 = j2 + 2;
  3527. j2 = j1 - 1 + iw[j1 - 1];
  3528. /* RUN THROUGH INDEX LIST OF STACK ELEMENT IELL. */
  3529. i__3 = j2;
  3530. for (jj = j1; jj <= i__3; ++jj) {
  3531. j = iw[jj];
  3532. /* JUMP IF ALREADY ASSEMBLED */
  3533. if (iw2[j] > 0) {
  3534. goto L60;
  3535. }
  3536. jnew = perm[j];
  3537. /* IF VARIABLE WAS PREVIOUSLY FULLY SUMMED BUT WAS NOT PIVOTED ON */
  3538. /* EARLIER BECAUSE OF NUMERICAL TEST, INCREMENT NUMBER OF FULLY */
  3539. /* SUMMED ROWS/COLUMNS IN FRONT. */
  3540. if (jnew <= numass) {
  3541. ++nass;
  3542. }
  3543. /* FIND POSITION IN LINKED LIST FOR NEW VARIABLE. NOTE THAT WE START */
  3544. /* FROM WHERE WE LEFT OFF AFTER ASSEMBLY OF PREVIOUS VARIABLE. */
  3545. i__4 = *n;
  3546. for (idummy = 1; idummy <= i__4; ++idummy) {
  3547. if (jnext == *n + 1) {
  3548. goto L30;
  3549. }
  3550. if (perm[jnext] > jnew) {
  3551. goto L30;
  3552. }
  3553. jlast = jnext;
  3554. jnext = iw2[jlast];
  3555. /* L20: */
  3556. }
  3557. L30:
  3558. if (jlast != *n + 1) {
  3559. goto L40;
  3560. }
  3561. jfirst = j;
  3562. goto L50;
  3563. L40:
  3564. iw2[jlast] = j;
  3565. L50:
  3566. iw2[j] = jnext;
  3567. jlast = j;
  3568. /* INCREMENT NUMBER OF VARIABLES IN THE FRONT. */
  3569. ++nfront;
  3570. L60:
  3571. ;
  3572. }
  3573. /* L70: */
  3574. }
  3575. lnass = nass - lnass;
  3576. /* NOW INCORPORATE ORIGINAL ROWS. NOTE THAT THE COLUMNS IN THESE ROWS */
  3577. /* NEED NOT BE IN ORDER. WE ALSO PERFORM */
  3578. /* A SWOP SO THAT THE DIAGONAL ENTRY IS THE FIRST IN ITS */
  3579. /* ROW. THIS ALLOWS US TO AVOID STORING THE INVERSE OF ARRAY PERM. */
  3580. L80:
  3581. numorg = nelim[iass];
  3582. j1 = iinput;
  3583. i__2 = numorg;
  3584. for (iorg = 1; iorg <= i__2; ++iorg) {
  3585. j = -iw[j1];
  3586. i__3 = *liw;
  3587. for (idummy = 1; idummy <= i__3; ++idummy) {
  3588. jnew = perm[j];
  3589. /* JUMP IF VARIABLE ALREADY INCLUDED. */
  3590. if (iw2[j] > 0) {
  3591. goto L130;
  3592. }
  3593. /* HERE WE MUST ALWAYS START OUR SEARCH AT THE BEGINNING. */
  3594. jlast = *n + 1;
  3595. jnext = jfirst;
  3596. i__4 = *n;
  3597. for (jdummy = 1; jdummy <= i__4; ++jdummy) {
  3598. if (jnext == *n + 1) {
  3599. goto L100;
  3600. }
  3601. if (perm[jnext] > jnew) {
  3602. goto L100;
  3603. }
  3604. jlast = jnext;
  3605. jnext = iw2[jlast];
  3606. /* L90: */
  3607. }
  3608. L100:
  3609. if (jlast != *n + 1) {
  3610. goto L110;
  3611. }
  3612. jfirst = j;
  3613. goto L120;
  3614. L110:
  3615. iw2[jlast] = j;
  3616. L120:
  3617. iw2[j] = jnext;
  3618. /* INCREMENT NUMBER OF VARIABLES IN FRONT. */
  3619. ++nfront;
  3620. L130:
  3621. ++j1;
  3622. if (j1 > *liw) {
  3623. goto L150;
  3624. }
  3625. j = iw[j1];
  3626. if (j < 0) {
  3627. goto L150;
  3628. }
  3629. /* L140: */
  3630. }
  3631. L150:
  3632. ;
  3633. }
  3634. /* NOW RUN THROUGH LINKED LIST IW2 PUTTING INDICES OF VARIABLES IN NEW */
  3635. /* ELEMENT INTO IW AND SETTING IW2 ENTRY TO POINT TO THE RELATIVE */
  3636. /* POSITION OF THE VARIABLE IN THE NEW ELEMENT. */
  3637. if (newel + nfront < istk) {
  3638. goto L160;
  3639. }
  3640. /* COMPRESS IW. */
  3641. ma27pd_(&a[1], &iw[1], &istk, &istk2, &iinput, &c__2, &ncmpbr, &
  3642. ncmpbi);
  3643. if (newel + nfront < istk) {
  3644. goto L160;
  3645. }
  3646. info[2] = *liw + 1 + newel + nfront - istk;
  3647. goto L770;
  3648. L160:
  3649. j = jfirst;
  3650. i__2 = nfront;
  3651. for (ifr = 1; ifr <= i__2; ++ifr) {
  3652. ++newel;
  3653. iw[newel] = j;
  3654. jnext = iw2[j];
  3655. iw2[j] = newel - (iwpos + 1);
  3656. j = jnext;
  3657. /* L170: */
  3658. }
  3659. /* ASSEMBLE REALS INTO FRONTAL MATRIX. */
  3660. *maxfrt = max(*maxfrt,nfront);
  3661. iw[iwpos] = nfront;
  3662. /* FIRST ZERO OUT FRONTAL MATRIX AS APPROPRIATE FIRST CHECKING TO SEE */
  3663. /* IF THERE IS SUFFICIENT SPACE. */
  3664. laell = (nfront + 1) * nfront / 2;
  3665. apos2 = posfac + laell - 1;
  3666. if (numstk != 0) {
  3667. lnass = lnass * ((nfront << 1) - lnass + 1) / 2;
  3668. }
  3669. if (posfac + lnass - 1 >= astk) {
  3670. goto L180;
  3671. }
  3672. if (apos2 < astk + ltopst - 1) {
  3673. goto L190;
  3674. }
  3675. /* COMPRESS A. */
  3676. L180:
  3677. ma27pd_(&a[1], &iw[1], &astk, &astk2, &ainput, &c__1, &ncmpbr, &
  3678. ncmpbi);
  3679. if (posfac + lnass - 1 >= astk) {
  3680. goto L780;
  3681. }
  3682. if (apos2 >= astk + ltopst - 1) {
  3683. goto L780;
  3684. }
  3685. L190:
  3686. if (apos2 <= azero) {
  3687. goto L220;
  3688. }
  3689. apos = azero + 1;
  3690. /* Computing MIN */
  3691. i__2 = apos2, i__3 = astk - 1;
  3692. lapos2 = min(i__2,i__3);
  3693. if (lapos2 < apos) {
  3694. goto L210;
  3695. }
  3696. i__2 = lapos2;
  3697. for (k = apos; k <= i__2; ++k) {
  3698. a[k] = 0.;
  3699. /* L200: */
  3700. }
  3701. L210:
  3702. azero = apos2;
  3703. /* JUMP IF THERE ARE NO STACK ELEMENTS TO ASSEMBLE. */
  3704. L220:
  3705. if (numstk == 0) {
  3706. goto L260;
  3707. }
  3708. /* PLACE REALS CORRESPONDING TO STACK ELEMENTS IN CORRECT POSITIONS IN A. */
  3709. i__2 = numstk;
  3710. for (iell = 1; iell <= i__2; ++iell) {
  3711. j1 = istk + 1;
  3712. j2 = istk + iw[istk];
  3713. i__3 = j2;
  3714. for (jj = j1; jj <= i__3; ++jj) {
  3715. irow = iw[jj];
  3716. irow = iw2[irow];
  3717. apos = posfac + (irow - 1) * (2 * nfront - irow + 2) / 2;
  3718. i__4 = j2;
  3719. for (jjj = jj; jjj <= i__4; ++jjj) {
  3720. j = iw[jjj];
  3721. apos2 = apos + iw2[j] - irow;
  3722. a[apos2] += a[astk];
  3723. a[astk] = 0.;
  3724. ++astk;
  3725. /* L230: */
  3726. }
  3727. /* L240: */
  3728. }
  3729. /* INCREMENT STACK POINTER. */
  3730. istk = j2 + 1;
  3731. /* L250: */
  3732. }
  3733. /* INCORPORATE REALS FROM ORIGINAL ROWS. */
  3734. L260:
  3735. i__2 = numorg;
  3736. for (iorg = 1; iorg <= i__2; ++iorg) {
  3737. j = -iw[iinput];
  3738. /* WE CAN DO THIS BECAUSE THE DIAGONAL IS NOW THE FIRST ENTRY. */
  3739. irow = iw2[j];
  3740. apos = posfac + (irow - 1) * (2 * nfront - irow + 2) / 2;
  3741. /* THE FOLLOWING LOOP GOES FROM 1 TO NZ BECAUSE THERE MAY BE DUPLICATES. */
  3742. i__3 = *nz;
  3743. for (idummy = 1; idummy <= i__3; ++idummy) {
  3744. apos2 = apos + iw2[j] - irow;
  3745. a[apos2] += a[ainput];
  3746. ++ainput;
  3747. ++iinput;
  3748. if (iinput > *liw) {
  3749. goto L280;
  3750. }
  3751. j = iw[iinput];
  3752. if (j < 0) {
  3753. goto L280;
  3754. }
  3755. /* L270: */
  3756. }
  3757. L280:
  3758. ;
  3759. }
  3760. /* RESET IW2 AND NUMASS. */
  3761. numass += numorg;
  3762. j1 = iwpos + 2;
  3763. j2 = iwpos + nfront + 1;
  3764. i__2 = j2;
  3765. for (k = j1; k <= i__2; ++k) {
  3766. j = iw[k];
  3767. iw2[j] = 0;
  3768. /* L290: */
  3769. }
  3770. /* PERFORM PIVOTING ON ASSEMBLED ELEMENT. */
  3771. /* NPIV IS THE NUMBER OF PIVOTS SO FAR SELECTED. */
  3772. /* LNPIV IS THE NUMBER OF PIVOTS SELECTED AFTER THE LAST PASS THROUGH */
  3773. /* THE THE FOLLOWING LOOP. */
  3774. lnpiv = -1;
  3775. npiv = 0;
  3776. i__2 = nass;
  3777. for (kdummy = 1; kdummy <= i__2; ++kdummy) {
  3778. if (npiv == nass) {
  3779. goto L660;
  3780. }
  3781. if (npiv == lnpiv) {
  3782. goto L660;
  3783. }
  3784. lnpiv = npiv;
  3785. npivp1 = npiv + 1;
  3786. /* JPIV IS USED AS A FLAG TO INDICATE WHEN 2 BY 2 PIVOTING HAS OCCURRED */
  3787. /* SO THAT IPIV IS INCREMENTED CORRECTLY. */
  3788. jpiv = 1;
  3789. /* NASS IS MAXIMUM POSSIBLE NUMBER OF PIVOTS. */
  3790. /* WE EITHER TAKE THE DIAGONAL ENTRY OR THE 2 BY 2 PIVOT WITH THE */
  3791. /* LARGEST OFF-DIAGONAL AT EACH STAGE. */
  3792. /* EACH PASS THROUGH THIS LOOP TRIES TO CHOOSE ONE PIVOT. */
  3793. i__3 = nass;
  3794. for (ipiv = npivp1; ipiv <= i__3; ++ipiv) {
  3795. --jpiv;
  3796. /* JUMP IF WE HAVE JUST PROCESSED A 2 BY 2 PIVOT. */
  3797. if (jpiv == 1) {
  3798. goto L640;
  3799. }
  3800. i__4 = nfront - npiv;
  3801. i__5 = ipiv - npiv;
  3802. apos = posfac + (i__5 - 1) * (2 * i__4 - i__5 + 2) / 2;
  3803. /* IF THE USER HAS INDICATED THAT THE MATRIX IS DEFINITE, WE */
  3804. /* DO NOT NEED TO TEST FOR STABILITY BUT WE DO CHECK TO SEE IF THE */
  3805. /* PIVOT IS NON-ZERO OR HAS CHANGED SIGN. */
  3806. /* IF IT IS ZERO, WE EXIT WITH AN ERROR. IF IT HAS CHANGED SIGN */
  3807. /* AND U WAS SET NEGATIVE, THEN WE AGAIN EXIT IMMEDIATELY. IF THE */
  3808. /* PIVOT CHANGES SIGN AND U WAS ZERO, WE CONTINUE WITH THE */
  3809. /* FACTORIZATION BUT PRINT A WARNING MESSAGE ON UNIT ICNTL(2). */
  3810. /* ISNPIV HOLDS A FLAG FOR THE SIGN OF THE PIVOTS TO DATE SO THAT */
  3811. /* A SIGN CHANGE WHEN DECOMPOSING AN ALLEGEDLY DEFINITE MATRIX CAN */
  3812. /* BE DETECTED. */
  3813. if (uu > 0.) {
  3814. goto L320;
  3815. }
  3816. if ((d__1 = a[apos], abs(d__1)) <= cntl[3]) {
  3817. goto L790;
  3818. }
  3819. /* JUMP IF THIS IS NOT THE FIRST PIVOT TO BE SELECTED. */
  3820. if (ntotpv > 0) {
  3821. goto L300;
  3822. }
  3823. /* SET ISNPIV. */
  3824. if (a[apos] > 0.) {
  3825. isnpiv = 1;
  3826. }
  3827. if (a[apos] < 0.) {
  3828. isnpiv = -1;
  3829. }
  3830. L300:
  3831. if (a[apos] > 0. && isnpiv == 1) {
  3832. goto L560;
  3833. }
  3834. if (a[apos] < 0. && isnpiv == -1) {
  3835. goto L560;
  3836. }
  3837. if (info[1] != 2) {
  3838. info[2] = 0;
  3839. }
  3840. ++info[2];
  3841. info[1] = 2;
  3842. i__ = ntotpv + 1;
  3843. if (icntl[2] > 0 && info[2] <= 10) {
  3844. io___280.ciunit = icntl[2];
  3845. s_wsfe(&io___280);
  3846. do_fio(&c__1, (char *)&info[1], (ftnlen)sizeof(integer));
  3847. do_fio(&c__1, (char *)&i__, (ftnlen)sizeof(integer));
  3848. e_wsfe();
  3849. }
  3850. isnpiv = -isnpiv;
  3851. if (uu == 0.) {
  3852. goto L560;
  3853. }
  3854. goto L800;
  3855. L320:
  3856. amax = 0.;
  3857. tmax = amax;
  3858. /* FIND LARGEST ENTRY TO RIGHT OF DIAGONAL IN ROW OF PROSPECTIVE PIVOT */
  3859. /* IN THE FULLY-SUMMED PART. ALSO RECORD COLUMN OF THIS LARGEST */
  3860. /* ENTRY. */
  3861. j1 = apos + 1;
  3862. j2 = apos + nass - ipiv;
  3863. if (j2 < j1) {
  3864. goto L340;
  3865. }
  3866. i__4 = j2;
  3867. for (jj = j1; jj <= i__4; ++jj) {
  3868. if ((d__1 = a[jj], abs(d__1)) <= amax) {
  3869. goto L330;
  3870. }
  3871. jmax = ipiv + jj - j1 + 1;
  3872. amax = (d__1 = a[jj], abs(d__1));
  3873. L330:
  3874. ;
  3875. }
  3876. /* DO SAME AS ABOVE FOR NON-FULLY-SUMMED PART ONLY HERE WE DO NOT NEED */
  3877. /* TO RECORD COLUMN SO LOOP IS SIMPLER. */
  3878. L340:
  3879. j1 = j2 + 1;
  3880. j2 = apos + nfront - ipiv;
  3881. if (j2 < j1) {
  3882. goto L360;
  3883. }
  3884. i__4 = j2;
  3885. for (jj = j1; jj <= i__4; ++jj) {
  3886. /* Computing MAX */
  3887. d__2 = (d__1 = a[jj], abs(d__1));
  3888. tmax = max(d__2,tmax);
  3889. /* L350: */
  3890. }
  3891. /* NOW CALCULATE LARGEST ENTRY IN OTHER PART OF ROW. */
  3892. L360:
  3893. rmax = max(tmax,amax);
  3894. apos1 = apos;
  3895. kk = nfront - ipiv;
  3896. lt = ipiv - (npiv + 1);
  3897. if (lt == 0) {
  3898. goto L380;
  3899. }
  3900. i__4 = lt;
  3901. for (k = 1; k <= i__4; ++k) {
  3902. ++kk;
  3903. apos1 -= kk;
  3904. /* Computing MAX */
  3905. d__2 = rmax, d__3 = (d__1 = a[apos1], abs(d__1));
  3906. rmax = max(d__2,d__3);
  3907. /* L370: */
  3908. }
  3909. /* JUMP IF STABILITY TEST SATISFIED. */
  3910. L380:
  3911. /* Computing MAX */
  3912. d__2 = cntl[3], d__3 = uu * rmax;
  3913. if ((d__1 = a[apos], abs(d__1)) > max(d__2,d__3)) {
  3914. goto L450;
  3915. }
  3916. /* CHECK BLOCK PIVOT OF ORDER 2 FOR STABILITY. */
  3917. if (abs(amax) <= cntl[3]) {
  3918. goto L640;
  3919. }
  3920. i__4 = nfront - npiv;
  3921. i__5 = jmax - npiv;
  3922. apos2 = posfac + (i__5 - 1) * (2 * i__4 - i__5 + 2) / 2;
  3923. detpiv = a[apos] * a[apos2] - amax * amax;
  3924. thresh = abs(detpiv);
  3925. /* SET THRESH TO U TIMES THE RECIPROCAL OF THE MAX-NORM OF THE INVERSE */
  3926. /* OF THE PROSPECTIVE BLOCK. */
  3927. /* Computing MAX */
  3928. d__3 = (d__1 = a[apos], abs(d__1)) + amax, d__4 = (d__2 = a[
  3929. apos2], abs(d__2)) + amax;
  3930. thresh /= uu * max(d__3,d__4);
  3931. /* CHECK 2 BY 2 PIVOT FOR STABILITY. */
  3932. /* FIRST CHECK AGAINST ROW IPIV. */
  3933. if (thresh <= rmax) {
  3934. goto L640;
  3935. }
  3936. /* FIND LARGEST ENTRY IN ROW JMAX. */
  3937. /* FIND MAXIMUM TO THE RIGHT OF THE DIAGONAL. */
  3938. rmax = 0.;
  3939. j1 = apos2 + 1;
  3940. j2 = apos2 + nfront - jmax;
  3941. if (j2 < j1) {
  3942. goto L400;
  3943. }
  3944. i__4 = j2;
  3945. for (jj = j1; jj <= i__4; ++jj) {
  3946. /* Computing MAX */
  3947. d__2 = rmax, d__3 = (d__1 = a[jj], abs(d__1));
  3948. rmax = max(d__2,d__3);
  3949. /* L390: */
  3950. }
  3951. /* NOW CHECK TO THE LEFT OF THE DIAGONAL. */
  3952. /* WE USE TWO LOOPS TO AVOID TESTING FOR ROW IPIV INSIDE THE LOOP. */
  3953. L400:
  3954. kk = nfront - jmax + 1;
  3955. apos3 = apos2;
  3956. jmxmip = jmax - ipiv - 1;
  3957. if (jmxmip == 0) {
  3958. goto L420;
  3959. }
  3960. i__4 = jmxmip;
  3961. for (k = 1; k <= i__4; ++k) {
  3962. apos2 -= kk;
  3963. ++kk;
  3964. /* Computing MAX */
  3965. d__2 = rmax, d__3 = (d__1 = a[apos2], abs(d__1));
  3966. rmax = max(d__2,d__3);
  3967. /* L410: */
  3968. }
  3969. L420:
  3970. ipmnp = ipiv - npiv - 1;
  3971. if (ipmnp == 0) {
  3972. goto L440;
  3973. }
  3974. apos2 -= kk;
  3975. ++kk;
  3976. i__4 = ipmnp;
  3977. for (k = 1; k <= i__4; ++k) {
  3978. apos2 -= kk;
  3979. ++kk;
  3980. /* Computing MAX */
  3981. d__2 = rmax, d__3 = (d__1 = a[apos2], abs(d__1));
  3982. rmax = max(d__2,d__3);
  3983. /* L430: */
  3984. }
  3985. L440:
  3986. if (thresh <= rmax) {
  3987. goto L640;
  3988. }
  3989. pivsiz = 2;
  3990. goto L460;
  3991. L450:
  3992. pivsiz = 1;
  3993. L460:
  3994. irow = ipiv - npiv;
  3995. /* PIVOT HAS BEEN CHOSEN. IF BLOCK PIVOT OF ORDER 2, PIVSIZ IS EQUAL TO */
  3996. /* TWO OTHERWISE PIVSIZ EQUALS ONE.. */
  3997. /* THE FOLLOWING LOOP MOVES THE PIVOT BLOCK TO THE TOP LEFT HAND CORNER */
  3998. /* OF THE FRONTAL MATRIX. */
  3999. i__4 = pivsiz;
  4000. for (krow = 1; krow <= i__4; ++krow) {
  4001. /* WE JUMP IF SWOP IS NOT NECESSARY. */
  4002. if (irow == 1) {
  4003. goto L530;
  4004. }
  4005. j1 = posfac + irow;
  4006. j2 = posfac + nfront - (npiv + 1);
  4007. if (j2 < j1) {
  4008. goto L480;
  4009. }
  4010. apos2 = apos + 1;
  4011. /* SWOP PORTION OF ROWS WHOSE COLUMN INDICES ARE GREATER THAN LATER ROW. */
  4012. i__5 = j2;
  4013. for (jj = j1; jj <= i__5; ++jj) {
  4014. swop = a[apos2];
  4015. a[apos2] = a[jj];
  4016. a[jj] = swop;
  4017. ++apos2;
  4018. /* L470: */
  4019. }
  4020. L480:
  4021. j1 = posfac + 1;
  4022. j2 = posfac + irow - 2;
  4023. apos2 = apos;
  4024. kk = nfront - (irow + npiv);
  4025. if (j2 < j1) {
  4026. goto L500;
  4027. }
  4028. /* SWOP PORTION OF ROWS/COLUMNS WHOSE INDICES LIE BETWEEN THE TWO ROWS. */
  4029. i__5 = j2;
  4030. for (jjj = j1; jjj <= i__5; ++jjj) {
  4031. jj = j2 - jjj + j1;
  4032. ++kk;
  4033. apos2 -= kk;
  4034. swop = a[apos2];
  4035. a[apos2] = a[jj];
  4036. a[jj] = swop;
  4037. /* L490: */
  4038. }
  4039. L500:
  4040. if (npiv == 0) {
  4041. goto L520;
  4042. }
  4043. apos1 = posfac;
  4044. ++kk;
  4045. apos2 -= kk;
  4046. /* SWOP PORTION OF COLUMNS WHOSE INDICES ARE LESS THAN EARLIER ROW. */
  4047. i__5 = npiv;
  4048. for (jj = 1; jj <= i__5; ++jj) {
  4049. ++kk;
  4050. apos1 -= kk;
  4051. apos2 -= kk;
  4052. swop = a[apos2];
  4053. a[apos2] = a[apos1];
  4054. a[apos1] = swop;
  4055. /* L510: */
  4056. }
  4057. /* SWOP DIAGONALS AND INTEGER INDEXING INFORMATION */
  4058. L520:
  4059. swop = a[apos];
  4060. a[apos] = a[posfac];
  4061. a[posfac] = swop;
  4062. ipos = iwpos + npiv + 2;
  4063. iexch = iwpos + irow + npiv + 1;
  4064. iswop = iw[ipos];
  4065. iw[ipos] = iw[iexch];
  4066. iw[iexch] = iswop;
  4067. L530:
  4068. if (pivsiz == 1) {
  4069. goto L550;
  4070. }
  4071. /* SET VARIABLES FOR THE SWOP OF SECOND ROW OF BLOCK PIVOT. */
  4072. if (krow == 2) {
  4073. goto L540;
  4074. }
  4075. irow = jmax - (npiv + 1);
  4076. jpos = posfac;
  4077. posfac = posfac + nfront - npiv;
  4078. ++npiv;
  4079. apos = apos3;
  4080. goto L550;
  4081. /* RESET VARIABLES PREVIOUSLY SET FOR SECOND PASS. */
  4082. L540:
  4083. --npiv;
  4084. posfac = jpos;
  4085. L550:
  4086. ;
  4087. }
  4088. if (pivsiz == 2) {
  4089. goto L600;
  4090. }
  4091. /* PERFORM THE ELIMINATION USING ENTRY (IPIV,IPIV) AS PIVOT. */
  4092. /* WE STORE U AND DINVERSE. */
  4093. L560:
  4094. a[posfac] = 1. / a[posfac];
  4095. if (a[posfac] < 0.) {
  4096. ++neig;
  4097. }
  4098. j1 = posfac + 1;
  4099. j2 = posfac + nfront - (npiv + 1);
  4100. if (j2 < j1) {
  4101. goto L590;
  4102. }
  4103. ibeg = j2 + 1;
  4104. i__4 = j2;
  4105. for (jj = j1; jj <= i__4; ++jj) {
  4106. amult = -a[jj] * a[posfac];
  4107. iend = ibeg + nfront - (npiv + jj - j1 + 2);
  4108. /* THE FOLLOWING SPECIAL COMMENT FORCES VECTORIZATION ON THE CRAY-1. */
  4109. /* DIR$ IVDEP */
  4110. i__5 = iend;
  4111. for (irow = ibeg; irow <= i__5; ++irow) {
  4112. jcol = jj + irow - ibeg;
  4113. a[irow] += amult * a[jcol];
  4114. /* L570: */
  4115. }
  4116. ibeg = iend + 1;
  4117. a[jj] = amult;
  4118. /* L580: */
  4119. }
  4120. L590:
  4121. ++npiv;
  4122. ++ntotpv;
  4123. jpiv = 1;
  4124. posfac = posfac + nfront - npiv + 1;
  4125. goto L640;
  4126. /* PERFORM ELIMINATION USING BLOCK PIVOT OF ORDER TWO. */
  4127. /* REPLACE BLOCK PIVOT BY ITS INVERSE. */
  4128. /* SET FLAG TO INDICATE USE OF 2 BY 2 PIVOT IN IW. */
  4129. L600:
  4130. ipos = iwpos + npiv + 2;
  4131. ++ntwo;
  4132. iw[ipos] = -iw[ipos];
  4133. pospv1 = posfac;
  4134. pospv2 = posfac + nfront - npiv;
  4135. swop = a[pospv2];
  4136. if (detpiv < 0.) {
  4137. ++neig;
  4138. }
  4139. if (detpiv > 0. && swop < 0.) {
  4140. neig += 2;
  4141. }
  4142. a[pospv2] = a[pospv1] / detpiv;
  4143. a[pospv1] = swop / detpiv;
  4144. a[pospv1 + 1] = -a[pospv1 + 1] / detpiv;
  4145. j1 = pospv1 + 2;
  4146. j2 = pospv1 + nfront - (npiv + 1);
  4147. if (j2 < j1) {
  4148. goto L630;
  4149. }
  4150. jj1 = pospv2;
  4151. ibeg = pospv2 + nfront - (npiv + 1);
  4152. i__4 = j2;
  4153. for (jj = j1; jj <= i__4; ++jj) {
  4154. ++jj1;
  4155. amult1 = -(a[pospv1] * a[jj] + a[pospv1 + 1] * a[jj1]);
  4156. amult2 = -(a[pospv1 + 1] * a[jj] + a[pospv2] * a[jj1]);
  4157. iend = ibeg + nfront - (npiv + jj - j1 + 3);
  4158. /* THE FOLLOWING SPECIAL COMMENT FORCES VECTORIZATION ON THE CRAY-1. */
  4159. /* DIR$ IVDEP */
  4160. i__5 = iend;
  4161. for (irow = ibeg; irow <= i__5; ++irow) {
  4162. k1 = jj + irow - ibeg;
  4163. k2 = jj1 + irow - ibeg;
  4164. a[irow] = a[irow] + amult1 * a[k1] + amult2 * a[k2];
  4165. /* L610: */
  4166. }
  4167. ibeg = iend + 1;
  4168. a[jj] = amult1;
  4169. a[jj1] = amult2;
  4170. /* L620: */
  4171. }
  4172. L630:
  4173. npiv += 2;
  4174. ntotpv += 2;
  4175. jpiv = 2;
  4176. posfac = pospv2 + nfront - npiv + 1;
  4177. L640:
  4178. ;
  4179. }
  4180. /* L650: */
  4181. }
  4182. /* END OF MAIN ELIMINATION LOOP. */
  4183. L660:
  4184. if (npiv != 0) {
  4185. ++nblk;
  4186. }
  4187. ioldps = iwpos;
  4188. iwpos = iwpos + nfront + 2;
  4189. if (npiv == 0) {
  4190. goto L690;
  4191. }
  4192. if (npiv > 1) {
  4193. goto L680;
  4194. }
  4195. iw[ioldps] = -iw[ioldps];
  4196. i__2 = nfront;
  4197. for (k = 1; k <= i__2; ++k) {
  4198. j1 = ioldps + k;
  4199. iw[j1] = iw[j1 + 1];
  4200. /* L670: */
  4201. }
  4202. --iwpos;
  4203. goto L690;
  4204. L680:
  4205. iw[ioldps + 1] = npiv;
  4206. /* COPY REMAINDER OF ELEMENT TO TOP OF STACK */
  4207. L690:
  4208. liell = nfront - npiv;
  4209. if (liell == 0 || iass == *nsteps) {
  4210. goto L750;
  4211. }
  4212. if (iwpos + liell < istk) {
  4213. goto L700;
  4214. }
  4215. ma27pd_(&a[1], &iw[1], &istk, &istk2, &iinput, &c__2, &ncmpbr, &
  4216. ncmpbi);
  4217. L700:
  4218. istk = istk - liell - 1;
  4219. iw[istk] = liell;
  4220. j1 = istk;
  4221. kk = iwpos - liell - 1;
  4222. /* THE FOLLOWING SPECIAL COMMENT FORCES VECTORIZATION ON THE CRAY-1. */
  4223. /* DIR$ IVDEP */
  4224. i__2 = liell;
  4225. for (k = 1; k <= i__2; ++k) {
  4226. ++j1;
  4227. ++kk;
  4228. iw[j1] = iw[kk];
  4229. /* L710: */
  4230. }
  4231. /* WE COPY IN REVERSE DIRECTION TO AVOID OVERWRITE PROBLEMS. */
  4232. laell = (liell + 1) * liell / 2;
  4233. kk = posfac + laell;
  4234. if (kk != astk) {
  4235. goto L720;
  4236. }
  4237. astk -= laell;
  4238. goto L740;
  4239. /* THE MOVE AND ZEROING OF ARRAY A IS PERFORMED WITH TWO LOOPS SO */
  4240. /* THAT THE CRAY-1 WILL VECTORIZE THEM SAFELY. */
  4241. L720:
  4242. kmax = kk - 1;
  4243. /* THE FOLLOWING SPECIAL COMMENT FORCES VECTORIZATION ON THE CRAY-1. */
  4244. /* DIR$ IVDEP */
  4245. i__2 = laell;
  4246. for (k = 1; k <= i__2; ++k) {
  4247. --kk;
  4248. --astk;
  4249. a[astk] = a[kk];
  4250. /* L730: */
  4251. }
  4252. /* Computing MIN */
  4253. i__2 = kmax, i__3 = astk - 1;
  4254. kmax = min(i__2,i__3);
  4255. i__2 = kmax;
  4256. for (k = kk; k <= i__2; ++k) {
  4257. a[k] = 0.;
  4258. /* L735: */
  4259. }
  4260. L740:
  4261. /* Computing MIN */
  4262. i__2 = azero, i__3 = astk - 1;
  4263. azero = min(i__2,i__3);
  4264. L750:
  4265. if (npiv == 0) {
  4266. iwpos = ioldps;
  4267. }
  4268. /* L760: */
  4269. }
  4270. /* END OF LOOP ON TREE NODES. */
  4271. iw[1] = nblk;
  4272. if (ntwo > 0) {
  4273. iw[1] = -nblk;
  4274. }
  4275. nrlbdu = posfac - 1;
  4276. nirbdu = iwpos - 1;
  4277. if (ntotpv == *n) {
  4278. goto L810;
  4279. }
  4280. info[1] = 3;
  4281. info[2] = ntotpv;
  4282. goto L810;
  4283. /* **** ERROR RETURNS **** */
  4284. L770:
  4285. info[1] = -3;
  4286. goto L810;
  4287. L780:
  4288. info[1] = -4;
  4289. /* Computing MAX */
  4290. i__1 = posfac + lnass, i__2 = apos2 - ltopst + 2;
  4291. info[2] = *la + max(i__1,i__2) - astk;
  4292. goto L810;
  4293. L790:
  4294. info[1] = -5;
  4295. info[2] = ntotpv + 1;
  4296. goto L810;
  4297. L800:
  4298. info[1] = -6;
  4299. info[2] = ntotpv + 1;
  4300. L810:
  4301. info[9] = nrlbdu;
  4302. info[10] = nirbdu;
  4303. info[12] = ncmpbr;
  4304. info[13] = ncmpbi;
  4305. info[14] = ntwo;
  4306. info[15] = neig;
  4307. return 0;
  4308. } /* ma27od_ */
  4309. /* Subroutine */ int ma27pd_(doublereal *a, integer *iw, integer *j1, integer
  4310. *j2, integer *itop, integer *ireal, integer *ncmpbr, integer *ncmpbi)
  4311. {
  4312. /* System generated locals */
  4313. integer i__1;
  4314. /* Local variables */
  4315. static integer jj, jjj, ipos;
  4316. /* THIS SUBROUTINE PERFORMS A VERY SIMPLE COMPRESS (BLOCK MOVE). */
  4317. /* ENTRIES J1 TO J2 (INCL.) IN A OR IW AS APPROPRIATE ARE MOVED TO */
  4318. /* OCCUPY THE POSITIONS IMMEDIATELY PRIOR TO POSITION ITOP. */
  4319. /* A/IW HOLD THE ARRAY BEING COMPRESSED. */
  4320. /* J1/J2 DEFINE THE ENTRIES BEING MOVED. */
  4321. /* ITOP DEFINES THE POSITION IMMEDIATELY AFTER THE POSITIONS TO WHICH */
  4322. /* J1 TO J2 ARE MOVED. */
  4323. /* IREAL MUST BE SET BY THE USER TO 2 IF THE MOVE IS ON ARRAY IW, */
  4324. /* ANY OTHER VALUE WILL PERFORM THE MOVE ON A. */
  4325. /* NCMPBR and NCMPBI, see INFO(12) and INFO(13) in MA27A/AD (ACCUMULATE */
  4326. /* THE NUMBER OF COMPRESSES OF THE REALS AND INTEGERS PERFORMED BY */
  4327. /* MA27B/BD. */
  4328. /* .. Scalar Arguments .. */
  4329. /* .. */
  4330. /* .. Array Arguments .. */
  4331. /* .. */
  4332. /* .. Local Scalars .. */
  4333. /* .. */
  4334. /* .. Executable Statements .. */
  4335. /* Parameter adjustments */
  4336. --iw;
  4337. --a;
  4338. /* Function Body */
  4339. ipos = *itop - 1;
  4340. if (*j2 == ipos) {
  4341. goto L50;
  4342. }
  4343. if (*ireal == 2) {
  4344. goto L20;
  4345. }
  4346. ++(*ncmpbr);
  4347. if (*j1 > *j2) {
  4348. goto L40;
  4349. }
  4350. i__1 = *j2;
  4351. for (jjj = *j1; jjj <= i__1; ++jjj) {
  4352. jj = *j2 - jjj + *j1;
  4353. a[ipos] = a[jj];
  4354. --ipos;
  4355. /* L10: */
  4356. }
  4357. goto L40;
  4358. L20:
  4359. ++(*ncmpbi);
  4360. if (*j1 > *j2) {
  4361. goto L40;
  4362. }
  4363. i__1 = *j2;
  4364. for (jjj = *j1; jjj <= i__1; ++jjj) {
  4365. jj = *j2 - jjj + *j1;
  4366. iw[ipos] = iw[jj];
  4367. --ipos;
  4368. /* L30: */
  4369. }
  4370. L40:
  4371. *j2 = *itop - 1;
  4372. *j1 = ipos + 1;
  4373. L50:
  4374. return 0;
  4375. } /* ma27pd_ */
  4376. /* Subroutine */ int ma27qd_(integer *n, doublereal *a, integer *la, integer *
  4377. iw, integer *liw, doublereal *w, integer *maxfnt, doublereal *rhs,
  4378. integer *iw2, integer *nblk, integer *latop, integer *icntl)
  4379. {
  4380. /* System generated locals */
  4381. integer i__1, i__2, i__3;
  4382. /* Local variables */
  4383. static integer j, k, j1, j2, j3, k1, k2, k3;
  4384. static doublereal w1, w2;
  4385. static integer jj, ifr, ist, iblk, apos, irhs, ilvl, ipiv, jpiv, ipos,
  4386. npiv, irow, liell;
  4387. /* THIS SUBROUTINE PERFORMS FORWARD ELIMINATION */
  4388. /* USING THE FACTOR U TRANSPOSE STORED IN A/IA AFTER MA27B/BD. */
  4389. /* N - MUST BE SET TO THE ORDER OF THE MATRIX. NOT ALTERED */
  4390. /* BY MA27Q/QD. */
  4391. /* A - MUST BE SET TO HOLD THE REAL VALUES */
  4392. /* CORRESPONDING TO THE FACTORS OF DINVERSE AND U. THIS MUST BE */
  4393. /* UNCHANGED SINCE THE PRECEDING CALL TO MA27B/BD. NOT ALTERED */
  4394. /* BY MA27Q/QD. */
  4395. /* LA - LENGTH OF ARRAY A. NOT ALTERED BY MA27Q/QD. */
  4396. /* IW - HOLDS THE INTEGER INDEXING */
  4397. /* INFORMATION FOR THE MATRIX FACTORS IN A. THIS MUST BE */
  4398. /* UNCHANGED SINCE THE PRECEDING CALL TO MA27B/BD. NOT ALTERED */
  4399. /* BY MA27Q/QD. */
  4400. /* LIW - LENGTH OF ARRAY IW. NOT ALTERED BY MA27Q/QD. */
  4401. /* W - USED */
  4402. /* AS WORKSPACE BY MA27Q/QD TO HOLD THE COMPONENTS OF THE RIGHT */
  4403. /* HAND SIDES CORRESPONDING TO CURRENT BLOCK PIVOTAL ROWS. */
  4404. /* MAXFNT - MUST BE SET TO THE LARGEST NUMBER OF */
  4405. /* VARIABLES IN ANY BLOCK PIVOT ROW. THIS VALUE WILL HAVE */
  4406. /* BEEN OUTPUT BY MA27B/BD. NOT ALTERED BY MA27Q/QD. */
  4407. /* RHS - ON INPUT, */
  4408. /* MUST BE SET TO HOLD THE RIGHT HAND SIDES FOR THE EQUATIONS */
  4409. /* WHICH THE USER DESIRES TO SOLVE. ON OUTPUT, RHS WILL HOLD */
  4410. /* THE MODIFIED VECTORS CORRESPONDING TO PERFORMING FORWARD */
  4411. /* ELIMINATION ON THE RIGHT HAND SIDES. */
  4412. /* IW2 - NEED NOT BE SET ON ENTRY. ON EXIT IW2(I) (I = 1,NBLK) */
  4413. /* WILL HOLD POINTERS TO THE */
  4414. /* BEGINNING OF EACH BLOCK PIVOT IN ARRAY IW. */
  4415. /* NBLK - NUMBER OF BLOCK PIVOT ROWS. NOT ALTERED BY MA27Q/QD. */
  4416. /* LATOP - NEED NOT BE SET ON ENTRY. ON EXIT, IT IS THE POSITION IN */
  4417. /* A OF THE LAST ENTRY IN THE FACTORS. IT MUST BE PASSED */
  4418. /* UNCHANGED TO MA27R/RD. */
  4419. /* ICNTL is an INTEGER array of length 30, see MA27A/AD. */
  4420. /* ICNTL(IFRLVL+I) I=1,20 IS USED TO CONTROL WHETHER DIRECT OR INDIRECT */
  4421. /* ACCESS IS USED BY MA27C/CD. INDIRECT ACCESS IS EMPLOYED */
  4422. /* IN FORWARD AND BACK SUBSTITUTION RESPECTIVELY IF THE SIZE OF */
  4423. /* A BLOCK IS LESS THAN ICNTL(IFRLVL+MIN(10,NPIV)) AND */
  4424. /* ICNTL(IFRLVL+10+MIN(10,NPIV)) RESPECTIVELY, WHERE NPIV IS THE */
  4425. /* NUMBER OF PIVOTS IN THE BLOCK. */
  4426. /* .. Scalar Arguments .. */
  4427. /* .. */
  4428. /* .. Array Arguments .. */
  4429. /* .. */
  4430. /* .. Local Scalars .. */
  4431. /* .. */
  4432. /* .. Intrinsic Functions .. */
  4433. /* .. */
  4434. /* .. Executable Statements .. */
  4435. /* APOS. RUNNING POINTER TO CURRENT PIVOT POSITION IN ARRAY A. */
  4436. /* IPOS. RUNNING POINTER TO BEGINNING OF BLOCK PIVOT ROW IN IW. */
  4437. /* Parameter adjustments */
  4438. --rhs;
  4439. --a;
  4440. --iw;
  4441. --w;
  4442. --iw2;
  4443. --icntl;
  4444. /* Function Body */
  4445. apos = 1;
  4446. ipos = 1;
  4447. j2 = 0;
  4448. iblk = 0;
  4449. npiv = 0;
  4450. i__1 = *n;
  4451. for (irow = 1; irow <= i__1; ++irow) {
  4452. if (npiv > 0) {
  4453. goto L90;
  4454. }
  4455. ++iblk;
  4456. if (iblk > *nblk) {
  4457. goto L150;
  4458. }
  4459. ipos = j2 + 1;
  4460. /* SET UP POINTER IN PREPARATION FOR BACK SUBSTITUTION. */
  4461. iw2[iblk] = ipos;
  4462. /* ABS(LIELL) IS NUMBER OF VARIABLES (COLUMNS) IN BLOCK PIVOT ROW. */
  4463. liell = -iw[ipos];
  4464. /* NPIV IS NUMBER OF PIVOTS (ROWS) IN BLOCK PIVOT. */
  4465. npiv = 1;
  4466. if (liell > 0) {
  4467. goto L10;
  4468. }
  4469. liell = -liell;
  4470. ++ipos;
  4471. npiv = iw[ipos];
  4472. L10:
  4473. j1 = ipos + 1;
  4474. j2 = ipos + liell;
  4475. ilvl = min(npiv,10);
  4476. if (liell < icntl[ilvl + 5]) {
  4477. goto L90;
  4478. }
  4479. /* PERFORM OPERATIONS USING DIRECT ADDRESSING. */
  4480. /* LOAD APPROPRIATE COMPONENTS OF RIGHT HAND SIDES INTO ARRAY W. */
  4481. ifr = 0;
  4482. i__2 = j2;
  4483. for (jj = j1; jj <= i__2; ++jj) {
  4484. j = (i__3 = iw[jj], abs(i__3));
  4485. ++ifr;
  4486. w[ifr] = rhs[j];
  4487. /* L20: */
  4488. }
  4489. /* JPIV IS USED AS A FLAG SO THAT IPIV IS INCREMENTED CORRECTLY AFTER */
  4490. /* THE USE OF A 2 BY 2 PIVOT. */
  4491. jpiv = 1;
  4492. j3 = j1;
  4493. /* PERFORM OPERATIONS. */
  4494. i__2 = npiv;
  4495. for (ipiv = 1; ipiv <= i__2; ++ipiv) {
  4496. --jpiv;
  4497. if (jpiv == 1) {
  4498. goto L70;
  4499. }
  4500. /* JUMP IF WE HAVE A 2 BY 2 PIVOT. */
  4501. if (iw[j3] < 0) {
  4502. goto L40;
  4503. }
  4504. /* PERFORM FORWARD SUBSTITUTION USING 1 BY 1 PIVOT. */
  4505. jpiv = 1;
  4506. ++j3;
  4507. ++apos;
  4508. ist = ipiv + 1;
  4509. if (liell < ist) {
  4510. goto L70;
  4511. }
  4512. w1 = w[ipiv];
  4513. k = apos;
  4514. i__3 = liell;
  4515. for (j = ist; j <= i__3; ++j) {
  4516. w[j] += a[k] * w1;
  4517. ++k;
  4518. /* L30: */
  4519. }
  4520. apos = apos + liell - ist + 1;
  4521. goto L70;
  4522. /* PERFORM OPERATIONS WITH 2 BY 2 PIVOT. */
  4523. L40:
  4524. jpiv = 2;
  4525. j3 += 2;
  4526. apos += 2;
  4527. ist = ipiv + 2;
  4528. if (liell < ist) {
  4529. goto L60;
  4530. }
  4531. w1 = w[ipiv];
  4532. w2 = w[ipiv + 1];
  4533. k1 = apos;
  4534. k2 = apos + liell - ipiv;
  4535. i__3 = liell;
  4536. for (j = ist; j <= i__3; ++j) {
  4537. w[j] = w[j] + w1 * a[k1] + w2 * a[k2];
  4538. ++k1;
  4539. ++k2;
  4540. /* L50: */
  4541. }
  4542. L60:
  4543. apos = apos + (liell - ist + 1 << 1) + 1;
  4544. L70:
  4545. ;
  4546. }
  4547. /* RELOAD W BACK INTO RHS. */
  4548. ifr = 0;
  4549. i__2 = j2;
  4550. for (jj = j1; jj <= i__2; ++jj) {
  4551. j = (i__3 = iw[jj], abs(i__3));
  4552. ++ifr;
  4553. rhs[j] = w[ifr];
  4554. /* L80: */
  4555. }
  4556. npiv = 0;
  4557. goto L140;
  4558. /* PERFORM OPERATIONS USING INDIRECT ADDRESSING. */
  4559. /* JUMP IF WE HAVE A 2 BY 2 PIVOT. */
  4560. L90:
  4561. if (iw[j1] < 0) {
  4562. goto L110;
  4563. }
  4564. /* PERFORM FORWARD SUBSTITUTION USING 1 BY 1 PIVOT. */
  4565. --npiv;
  4566. ++apos;
  4567. ++j1;
  4568. if (j1 > j2) {
  4569. goto L140;
  4570. }
  4571. irhs = iw[j1 - 1];
  4572. w1 = rhs[irhs];
  4573. k = apos;
  4574. i__2 = j2;
  4575. for (j = j1; j <= i__2; ++j) {
  4576. irhs = (i__3 = iw[j], abs(i__3));
  4577. rhs[irhs] += a[k] * w1;
  4578. ++k;
  4579. /* L100: */
  4580. }
  4581. apos = apos + j2 - j1 + 1;
  4582. goto L140;
  4583. /* PERFORM OPERATIONS WITH 2 BY 2 PIVOT */
  4584. L110:
  4585. npiv += -2;
  4586. j1 += 2;
  4587. apos += 2;
  4588. if (j1 > j2) {
  4589. goto L130;
  4590. }
  4591. irhs = -iw[j1 - 2];
  4592. w1 = rhs[irhs];
  4593. irhs = iw[j1 - 1];
  4594. w2 = rhs[irhs];
  4595. k1 = apos;
  4596. k3 = apos + j2 - j1 + 2;
  4597. i__2 = j2;
  4598. for (j = j1; j <= i__2; ++j) {
  4599. irhs = (i__3 = iw[j], abs(i__3));
  4600. rhs[irhs] = rhs[irhs] + w1 * a[k1] + w2 * a[k3];
  4601. ++k1;
  4602. ++k3;
  4603. /* L120: */
  4604. }
  4605. L130:
  4606. apos = apos + (j2 - j1 + 1 << 1) + 1;
  4607. L140:
  4608. ;
  4609. }
  4610. L150:
  4611. *latop = apos - 1;
  4612. return 0;
  4613. } /* ma27qd_ */
  4614. /* Subroutine */ int ma27rd_(integer *n, doublereal *a, integer *la, integer *
  4615. iw, integer *liw, doublereal *w, integer *maxfnt, doublereal *rhs,
  4616. integer *iw2, integer *nblk, integer *latop, integer *icntl)
  4617. {
  4618. /* System generated locals */
  4619. integer i__1, i__2, i__3;
  4620. /* Local variables */
  4621. static integer j, k, j1, j2;
  4622. static doublereal w1, w2;
  4623. static integer jj, jj1, jj2, ifr, ist, iblk, apos, irhs, ilvl, ipiv, jpiv,
  4624. loop, ipos, jpos, npiv, apos2, i1rhs, i2rhs, liell, iirhs, iipiv;
  4625. /* THIS SUBROUTINE PERFORMS BACKWARD ELIMINATION OPERATIONS */
  4626. /* USING THE FACTORS DINVERSE AND U */
  4627. /* STORED IN A/IW AFTER MA27B/BD. */
  4628. /* N - MUST BE SET TO THE ORDER OF THE MATRIX. NOT ALTERED */
  4629. /* BY MA27R/RD. */
  4630. /* A - MUST BE SET TO HOLD THE REAL VALUES CORRESPONDING */
  4631. /* TO THE FACTORS OF DINVERSE AND U. THIS MUST BE */
  4632. /* UNCHANGED SINCE THE PRECEDING CALL TO MA27B/BD. NOT ALTERED */
  4633. /* BY MA27R/RD. */
  4634. /* LA - LENGTH OF ARRAY A. NOT ALTERED BY MA27R/RD. */
  4635. /* IW - HOLDS THE INTEGER INDEXING */
  4636. /* INFORMATION FOR THE MATRIX FACTORS IN A. THIS MUST BE */
  4637. /* UNCHANGED SINCE THE PRECEDING CALL TO MA27B/BD. NOT ALTERED */
  4638. /* BY MA27R/RD. */
  4639. /* LIW - LENGTH OF ARRAY IW. NOT ALTERED BY MA27R/RD. */
  4640. /* W - USED */
  4641. /* AS WORKSPACE BY MA27R/RD TO HOLD THE COMPONENTS OF THE RIGHT */
  4642. /* HAND SIDES CORRESPONDING TO CURRENT BLOCK PIVOTAL ROWS. */
  4643. /* MAXFNT - INTEGER VARIABLE. MUST BE SET TO THE LARGEST NUMBER OF */
  4644. /* VARIABLES IN ANY BLOCK PIVOT ROW. THIS VALUE WAS GIVEN */
  4645. /* ON OUTPUT FROM MA27B/BD. NOT ALTERED BY MA27R/RD. */
  4646. /* RHS - ON INPUT, */
  4647. /* MUST BE SET TO HOLD THE RIGHT HAND SIDE MODIFIED BY THE */
  4648. /* FORWARD SUBSTITUTION OPERATIONS. ON OUTPUT, RHS WILL HOLD */
  4649. /* THE SOLUTION VECTOR. */
  4650. /* IW2 - ON ENTRY IW2(I) (I = 1,NBLK) */
  4651. /* MUST HOLD POINTERS TO THE */
  4652. /* BEGINNING OF EACH BLOCK PIVOT IN ARRAY IW, AS SET BY */
  4653. /* MA27Q/QD. */
  4654. /* NBLK - NUMBER OF BLOCK PIVOT ROWS. NOT ALTERED BY MA27R/RD. */
  4655. /* LATOP - IT IS THE POSITION IN */
  4656. /* A OF THE LAST ENTRY IN THE FACTORS. IT MUST BE UNCHANGED */
  4657. /* SINCE THE CALL TO MA27Q/QD. IT IS NOT ALTERED BY MA27R/RD. */
  4658. /* ICNTL is an INTEGER array of length 30, see MA27A/AD. */
  4659. /* ICNTL(IFRLVL+I) I=1,20 IS USED TO CONTROL WHETHER DIRECT OR INDIRECT */
  4660. /* ACCESS IS USED BY MA27C/CD. INDIRECT ACCESS IS EMPLOYED */
  4661. /* IN FORWARD AND BACK SUBSTITUTION RESPECTIVELY IF THE SIZE OF */
  4662. /* A BLOCK IS LESS THAN ICNTL(IFRLVL+MIN(10,NPIV)) AND */
  4663. /* ICNTL(IFRLVL+10+MIN(10,NPIV)) RESPECTIVELY, WHERE NPIV IS THE */
  4664. /* NUMBER OF PIVOTS IN THE BLOCK. */
  4665. /* .. Scalar Arguments .. */
  4666. /* .. */
  4667. /* .. Array Arguments .. */
  4668. /* .. */
  4669. /* .. Local Scalars .. */
  4670. /* .. */
  4671. /* .. Intrinsic Functions .. */
  4672. /* .. */
  4673. /* .. Executable Statements .. */
  4674. /* APOS. RUNNING POINTER TO CURRENT PIVOT POSITION IN ARRAY A. */
  4675. /* IPOS. RUNNING POINTER TO BEGINNING OF CURRENT BLOCK PIVOT ROW. */
  4676. /* Parameter adjustments */
  4677. --rhs;
  4678. --a;
  4679. --iw;
  4680. --w;
  4681. --iw2;
  4682. --icntl;
  4683. /* Function Body */
  4684. apos = *latop + 1;
  4685. npiv = 0;
  4686. iblk = *nblk + 1;
  4687. /* RUN THROUGH BLOCK PIVOT ROWS IN THE REVERSE ORDER. */
  4688. i__1 = *n;
  4689. for (loop = 1; loop <= i__1; ++loop) {
  4690. if (npiv > 0) {
  4691. goto L110;
  4692. }
  4693. --iblk;
  4694. if (iblk < 1) {
  4695. goto L190;
  4696. }
  4697. ipos = iw2[iblk];
  4698. /* ABS(LIELL) IS NUMBER OF VARIABLES (COLUMNS) IN BLOCK PIVOT ROW. */
  4699. liell = -iw[ipos];
  4700. /* NPIV IS NUMBER OF PIVOTS (ROWS) IN BLOCK PIVOT. */
  4701. npiv = 1;
  4702. if (liell > 0) {
  4703. goto L10;
  4704. }
  4705. liell = -liell;
  4706. ++ipos;
  4707. npiv = iw[ipos];
  4708. L10:
  4709. jpos = ipos + npiv;
  4710. j2 = ipos + liell;
  4711. ilvl = min(10,npiv) + 10;
  4712. if (liell < icntl[ilvl + 5]) {
  4713. goto L110;
  4714. }
  4715. /* PERFORM OPERATIONS USING DIRECT ADDRESSING. */
  4716. j1 = ipos + 1;
  4717. /* LOAD APPROPRIATE COMPONENTS OF RHS INTO W. */
  4718. ifr = 0;
  4719. i__2 = j2;
  4720. for (jj = j1; jj <= i__2; ++jj) {
  4721. j = (i__3 = iw[jj], abs(i__3));
  4722. ++ifr;
  4723. w[ifr] = rhs[j];
  4724. /* L20: */
  4725. }
  4726. /* JPIV IS USED AS A FLAG SO THAT IPIV IS INCREMENTED CORRECTLY AFTER */
  4727. /* THE USE OF A 2 BY 2 PIVOT. */
  4728. jpiv = 1;
  4729. /* PERFORM ELIMINATIONS. */
  4730. i__2 = npiv;
  4731. for (iipiv = 1; iipiv <= i__2; ++iipiv) {
  4732. --jpiv;
  4733. if (jpiv == 1) {
  4734. goto L90;
  4735. }
  4736. ipiv = npiv - iipiv + 1;
  4737. if (ipiv == 1) {
  4738. goto L30;
  4739. }
  4740. /* JUMP IF WE HAVE A 2 BY 2 PIVOT. */
  4741. if (iw[jpos - 1] < 0) {
  4742. goto L60;
  4743. }
  4744. /* PERFORM BACK-SUBSTITUTION USING 1 BY 1 PIVOT. */
  4745. L30:
  4746. jpiv = 1;
  4747. apos -= liell + 1 - ipiv;
  4748. ist = ipiv + 1;
  4749. w1 = w[ipiv] * a[apos];
  4750. if (liell < ist) {
  4751. goto L50;
  4752. }
  4753. jj1 = apos + 1;
  4754. i__3 = liell;
  4755. for (j = ist; j <= i__3; ++j) {
  4756. w1 += a[jj1] * w[j];
  4757. ++jj1;
  4758. /* L40: */
  4759. }
  4760. L50:
  4761. w[ipiv] = w1;
  4762. --jpos;
  4763. goto L90;
  4764. /* PERFORM BACK-SUBSTITUTION OPERATIONS WITH 2 BY 2 PIVOT */
  4765. L60:
  4766. jpiv = 2;
  4767. apos2 = apos - (liell + 1 - ipiv);
  4768. apos = apos2 - (liell + 2 - ipiv);
  4769. ist = ipiv + 1;
  4770. w1 = w[ipiv - 1] * a[apos] + w[ipiv] * a[apos + 1];
  4771. w2 = w[ipiv - 1] * a[apos + 1] + w[ipiv] * a[apos2];
  4772. if (liell < ist) {
  4773. goto L80;
  4774. }
  4775. jj1 = apos + 2;
  4776. jj2 = apos2 + 1;
  4777. i__3 = liell;
  4778. for (j = ist; j <= i__3; ++j) {
  4779. w1 += w[j] * a[jj1];
  4780. w2 += w[j] * a[jj2];
  4781. ++jj1;
  4782. ++jj2;
  4783. /* L70: */
  4784. }
  4785. L80:
  4786. w[ipiv - 1] = w1;
  4787. w[ipiv] = w2;
  4788. jpos += -2;
  4789. L90:
  4790. ;
  4791. }
  4792. /* RELOAD WORKING VECTOR INTO SOLUTION VECTOR. */
  4793. ifr = 0;
  4794. i__2 = j2;
  4795. for (jj = j1; jj <= i__2; ++jj) {
  4796. j = (i__3 = iw[jj], abs(i__3));
  4797. ++ifr;
  4798. rhs[j] = w[ifr];
  4799. /* L100: */
  4800. }
  4801. npiv = 0;
  4802. goto L180;
  4803. /* PERFORM OPERATIONS USING INDIRECT ADDRESSING. */
  4804. L110:
  4805. if (npiv == 1) {
  4806. goto L120;
  4807. }
  4808. /* JUMP IF WE HAVE A 2 BY 2 PIVOT. */
  4809. if (iw[jpos - 1] < 0) {
  4810. goto L150;
  4811. }
  4812. /* PERFORM BACK-SUBSTITUTION USING 1 BY 1 PIVOT. */
  4813. L120:
  4814. --npiv;
  4815. apos -= j2 - jpos + 1;
  4816. iirhs = iw[jpos];
  4817. w1 = rhs[iirhs] * a[apos];
  4818. j1 = jpos + 1;
  4819. if (j1 > j2) {
  4820. goto L140;
  4821. }
  4822. k = apos + 1;
  4823. i__2 = j2;
  4824. for (j = j1; j <= i__2; ++j) {
  4825. irhs = (i__3 = iw[j], abs(i__3));
  4826. w1 += a[k] * rhs[irhs];
  4827. ++k;
  4828. /* L130: */
  4829. }
  4830. L140:
  4831. rhs[iirhs] = w1;
  4832. --jpos;
  4833. goto L180;
  4834. /* PERFORM OPERATIONS WITH 2 BY 2 PIVOT */
  4835. L150:
  4836. npiv += -2;
  4837. apos2 = apos - (j2 - jpos + 1);
  4838. apos = apos2 - (j2 - jpos + 2);
  4839. i1rhs = -iw[jpos - 1];
  4840. i2rhs = iw[jpos];
  4841. w1 = rhs[i1rhs] * a[apos] + rhs[i2rhs] * a[apos + 1];
  4842. w2 = rhs[i1rhs] * a[apos + 1] + rhs[i2rhs] * a[apos2];
  4843. j1 = jpos + 1;
  4844. if (j1 > j2) {
  4845. goto L170;
  4846. }
  4847. jj1 = apos + 2;
  4848. jj2 = apos2 + 1;
  4849. i__2 = j2;
  4850. for (j = j1; j <= i__2; ++j) {
  4851. irhs = (i__3 = iw[j], abs(i__3));
  4852. w1 += rhs[irhs] * a[jj1];
  4853. w2 += rhs[irhs] * a[jj2];
  4854. ++jj1;
  4855. ++jj2;
  4856. /* L160: */
  4857. }
  4858. L170:
  4859. rhs[i1rhs] = w1;
  4860. rhs[i2rhs] = w2;
  4861. jpos += -2;
  4862. L180:
  4863. ;
  4864. }
  4865. L190:
  4866. return 0;
  4867. } /* ma27rd_ */