-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdiaproc.f90
executable file
·1510 lines (1389 loc) · 49.2 KB
/
diaproc.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
module diaproc
use msfwina
use spinc
use dataman
use matrix
integer*4 jfromdialog, hDlgModeless
contains
!/****************************************************************************
!
! FUNCTION: Config(HWND, unsigned, WORD, LONG)
!
! PURPOSE: Processes messages for "Config" dialog box
!
! MESSAGES:
!
! WM_INITDIALOG - initialize dialog box
! WM_COMMAND - Input received
!
!****************************************************************************/
integer*4 function Config( hDlg, message, wParam, lParam )
!MS$ ATTRIBUTES STDCALL, ALIAS : '_Config@16' :: Config
integer*4 hDlg, message, wParam, lParam
logical(4) bret
integer*4 iedeft,iet,nelect
call CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER))
LPARAM = LPARAM
select case (message)
case (WM_INITDIALOG)
iedeft=iedef;iet=ie;nelect=nelec;
bret=CheckRadioButton(hDlg,ID_D1,ID_F13,iedeft)
Config = 1; return
case (WM_COMMAND)
select case(INT4(LoWord(wparam)))
case(ID_D1);iet=2;nelect=1;iedeft=ID_D1; case(ID_D2);iet=2;nelect=2;iedeft=ID_D2
case(ID_D3);iet=2;nelect=3;iedeft=ID_D3; case(ID_D4);iet=2;nelect=4;iedeft=ID_D4
case(ID_D5);iet=2;nelect=5;iedeft=ID_D5; case(ID_D6);iet=2;nelect=6;iedeft=ID_D6
case(ID_D7);iet=2;nelect=7;iedeft=ID_D7; case(ID_D8);iet=2;nelect=8;iedeft=ID_D8
case(ID_D9);iet=2;nelect=9;iedeft=ID_D9;
case(ID_F1);iet=3;nelect=1;iedeft=ID_F1; case(ID_F2);iet=3;nelect=2;iedeft=ID_F2
case(ID_F3);iet=3;nelect=3;iedeft=ID_F3; case(ID_F4);iet=3;nelect=4;iedeft=ID_F4
case(ID_F5);iet=3;nelect=5;iedeft=ID_F5; case(ID_F6);iet=3;nelect=6;iedeft=ID_F6
case(ID_F7);iet=3;nelect=7;iedeft=ID_F7; case(ID_F8);iet=3;nelect=8;iedeft=ID_F8
case(ID_F9);iet=3;nelect=9;iedeft=ID_F9; case(ID_F10);iet=3;nelect=10;iedeft=ID_F10
case(ID_F11);iet=3;nelect=11;iedeft=ID_F11;case(ID_F12);iet=3;nelect=12;iedeft=ID_F12
case(ID_F13);iet=3;nelect=13;iedeft=ID_F13
case(IDOK)
iedef=iedeft;ie=iet;nelec=nelect
bret=EndDialog(hDlg,TRUE)
Config=1
return
case(IDCANCEL)
bret=EndDialog(hDlg,FALSE)
Config=1
return
end select
end select
Config = 0;return
end function Config
!/****************************************************************************
!
! FUNCTION: Reduced(HWND, unsigned, WORD, LONG)
!
! PURPOSE: Processes messages for "Reduced" dialog box
!
! MESSAGES:
!
! WM_INITDIALOG - initialize dialog box
! WM_COMMAND - Input received
!
!****************************************************************************/
integer*4 function Reduced( hDlg, message, wParam, lParam )
!MS$ ATTRIBUTES STDCALL, ALIAS : '_Reduced@16' :: Reduced
integer*4 hDlg, message, wParam, lParam
type (T_MSG) mesg
integer(4) bret
integer i,nt,ne,iflag,iindex,idi,nr
character(3), allocatable :: cht(:)
character(3) cht1,cht2
!character*8 dbfilestr
character*25 szbuf
character*70 buf
real xtem
LPARAM = LPARAM;iindex=0
!call CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER))
select case (message)
case (WM_INITDIALOG)
i=1;nt=1;ne=nelec;iflag=0
select case(ie)
case(2)
!dbfilestr=dbfilecr(1)
if(ne.gt.5) then;iflag=1;ne=10-ne;end if;nt=dcon(ne)%con%nst
case(3)
!dbfilestr=dbfilecr(2)
if(ne.gt.7) then;iflag=1;ne=14-ne;end if;nt=fcon(ne)%con%nst
end select
do i=ID_MTEXT1,ID_MTEXT3
bret=SetDlgItemText(hDlg,i,' '//char(0))
end do
do i=ID_MRESULT1,ID_MRESULT3
bret=SetDlgItemText(hDlg,i,' '//char(0))
end do
!***********filling information boxes for selected configuration********************
allocate(cht(nt))
do i=1,nt
if(ie.eq.3) then;cht(i)=fcon(ne)%iLS(3*(i-1)+1:3*i);else
cht(i)=dcon(ne)%iLS(3*(i-1)+1:3*i)
end if
bret=SendDlgItemMessage(hDlg,ID_MLIST1,LB_ADDSTRING,0,LOC(cht(i)//CHAR(0)))
bret=SendDlgItemMessage(hDlg,ID_MLIST2,LB_ADDSTRING,0,LOC(cht(i)//CHAR(0)))
end do
do i=1,numinter
bret=SendDlgItemMessage(hDlg,ID_MLIST3,LB_ADDSTRING,0,LOC(inter(i)//CHAR(0)))
end do
deallocate(cht)
bret=SendDlgItemMessage(hDlg,ID_MLIST1,LB_SETCURSEL,iindex,0)
bret=SendDlgItemMessage(hDlg,ID_MLIST2,LB_SETCURSEL,iindex,0)
bret=SendDlgItemMessage(hDlg,ID_MLIST3,LB_SETCURSEL,iindex,0)
buf='Make selection and press Query button'//char(0)
bret=SetDlgItemText(hDlg,ID_MATRIXVALUE,buf)
Reduced = 1
return
!***************dialog boxes initialized**************************************
case (WM_COMMAND)
iindex=SendDlgItemMessage(hDlg,ID_MLIST1,LB_GETCURSEL,0,0)
bret=SendDlgItemMessage(hDlg,ID_MLIST1,LB_GETTEXT,iindex,LOC(szbuf))
cht1=szbuf(1:3)
! cht1=ToLowCase(cht1)
iindex=SendDlgItemMessage(hDlg,ID_MLIST2,LB_GETCURSEL,0,0)
bret=SendDlgItemMessage(hDlg,ID_MLIST2,LB_GETTEXT,iindex,LOC(szbuf))
cht2=szbuf(1:3)
! cht2=ToLowCase(cht2)
iindex=SendDlgItemMessage(hDlg,ID_MLIST3,LB_GETCURSEL,0,0)
idi=iindex+1
bret=SendDlgItemMessage(hDlg,ID_MLIST3,LB_GETTEXT,iindex,LOC(szbuf))
buf='You selected '//cht1//'-'//cht2//' matrix element for '//szbuf
bret=SetDlgItemText(hDlg,ID_MATRIXVALUE,buf)
select case(INT4(LoWord(wparam)))
case(IDOK)
bret = EndDialog(hDlg, TRUE)
!deallocate(relb) ! rcrb,respinb,relb
Reduced = 1;return
case(ID_MQUERY)
! write(szbuf,'(2i3)') idi,ne
! bret=SetDlgItemText(hDlg,ID_MATRIXVALUE,szbuf)
bret=SetDlgItemText(hDlg,ID_MTEXT1," "//char(0)); bret=SetDlgItemText(hDlg,ID_MTEXT2," "//char(0));bret=SetDlgItemText(hDlg,ID_MTEXT3," "//char(0))
bret=SetDlgItemText(hDlg,ID_MRESULT1," 0 "//char(0)); bret=SetDlgItemText(hDlg,ID_MRESULT2," 0 "//char(0));bret=SetDlgItemText(hDlg,ID_MRESULT3," 0 "//char(0))
select case(idi)
case(1)
bret=SetDlgItemText(hDlg,ID_MTEXT1,"F2"//char(0)); bret=SetDlgItemText(hDlg,ID_MTEXT2,"F4"//char(0));bret=SetDlgItemText(hDlg,ID_MTEXT3,"F6"//char(0))
do iel=ID_MRESULT1,ID_MRESULT3
nr=0;call numel(iel-ID_MRESULT1+1,cht1,cht2,nr,iflag)
if(nr.NE.0) then;rel=relb(nr);xtem=rel.fk;write(buf,'(f13.8)') xtem;bret=SetDlgItemText(hDlg,iel,buf)
else; bret=SetDlgItemText(hDlg,iel,"0");end if
end do
case(2)
bret=SetDlgItemText(hDlg,ID_MTEXT1,"alpha"//char(0)); bret=SetDlgItemText(hDlg,ID_MTEXT2,"beta"//char(0));bret=SetDlgItemText(hDlg,ID_MTEXT3,"gamma"//char(0))
do iel=ID_MRESULT1,ID_MRESULT3
nr=0;call numel(iel-ID_MRESULT1+4,cht1,cht2,nr,iflag)
if(nr.NE.0) then;rel=relb(nr); xtem=rel.fk;write(buf,'(f13.8)') xtem;bret=SetDlgItemText(hDlg,iel,buf)
else;bret=SetDlgItemText(hDlg,iel,"0"); end if
end do
case(3)
bret=SetDlgItemText(hDlg,ID_MTEXT1,"t2"//char(0)); bret=SetDlgItemText(hDlg,ID_MTEXT2,"t3"//char(0));bret=SetDlgItemText(hDlg,ID_MTEXT3,"t4"//char(0))
do iel=ID_MRESULT1,ID_MRESULT3
nr=0;call numel(iel-ID_MRESULT1+7,cht1,cht2,nr,iflag)
if(nr.NE.0) then;rel=relb(nr); xtem=rel.fk;write(buf,'(f13.8)') xtem;bret=SetDlgItemText(hDlg,iel,buf)
else; bret=SetDlgItemText(hDlg,iel,"0"); end if
end do
case(4)
bret=SetDlgItemText(hDlg,ID_MTEXT1,"t6"//char(0)); bret=SetDlgItemText(hDlg,ID_MTEXT2,"t7"//char(0));bret=SetDlgItemText(hDlg,ID_MTEXT3,"t8"//char(0))
do iel=ID_MRESULT1,ID_MRESULT3
nr=0;call numel(iel-ID_MRESULT1+10,cht1,cht2,nr,iflag)
if(nr.NE.0) then;rel=relb(nr); xtem=rel.fk;write(buf,'(f13.8)') xtem;bret=SetDlgItemText(hDlg,iel,buf)
else;bret=SetDlgItemText(hDlg,iel,"0");end if
end do
case(5)
bret=SetDlgItemText(hDlg,ID_MTEXT1,"dzeta"//char(0)); bret=SetDlgItemText(hDlg,ID_MTEXT2,""//char(0));bret=SetDlgItemText(hDlg,ID_MTEXT3,""//char(0))
bret=SetDlgItemText(hDlg,ID_MRESULT1," 0 "//char(0)); bret=SetDlgItemText(hDlg,ID_MRESULT2,""//char(0));bret=SetDlgItemText(hDlg,ID_MRESULT3,""//char(0))
hDlgModeless=CreateDialog(hInst,LOC("J-VALUE"C),hDlg,LOC(jval))
do while (GetMessage(mesg, NULL, 0, 0).and.(hDlgModeless.ne.0))
if(IsDialogMessage(hDlgModeless,mesg)) then
nr=0;call numspin(jfromdialog,1,cht1,cht2,nr,iflag)
if(nr.NE.0) then;rsp=respinb(nr); xtem=rsp.fk;write(buf,'(f13.8)') xtem;bret=SetDlgItemText(hDlg,ID_MRESULT1,buf)
else;bret=SetDlgItemText(hDlg,ID_MRESULT1,"0"); end if
write(buf,'(i4)') jfromdialog
bret=SetDlgItemText(hDlg,ID_MATRIXVALUE,"The value of J for this query is "//buf//char(0))
end if
end do
case(6)
bret=SetDlgItemText(hDlg,ID_MTEXT1,"M0"//char(0)); bret=SetDlgItemText(hDlg,ID_MTEXT2,"M2"//char(0));bret=SetDlgItemText(hDlg,ID_MTEXT3,"M4"//char(0))
bret=SetDlgItemText(hDlg,ID_MRESULT1," 0 "//char(0)); bret=SetDlgItemText(hDlg,ID_MRESULT2," 0 "//char(0));bret=SetDlgItemText(hDlg,ID_MRESULT3," 0 "//char(0))
hDlgModeless=CreateDialog(hInst,LOC("J-VALUE"C),hDlg,LOC(jval))
do while (GetMessage(mesg, NULL, 0, 0).and.(hDlgModeless.ne.0))
if(IsDialogMessage(hDlgModeless,mesg)) then
do iel=ID_MRESULT1,ID_MRESULT3
nr=0;call numspin(jfromdialog,iel-ID_MRESULT1+2,cht1,cht2,nr,iflag)
if(nr.NE.0) then;rsp=respinb(nr); xtem=rsp.fk;write(buf,'(f13.8)') xtem;bret=SetDlgItemText(hDlg,iel,buf)
else; bret=SetDlgItemText(hDlg,iel,"0");end if
end do
write(buf,'(i4)') jfromdialog
bret=SetDlgItemText(hDlg,ID_MATRIXVALUE,"The value of J for this query is "//buf//char(0))
end if
end do
case(7)
bret=SetDlgItemText(hDlg,ID_MTEXT1,"P2"//char(0)); bret=SetDlgItemText(hDlg,ID_MTEXT2,"P4"//char(0));bret=SetDlgItemText(hDlg,ID_MTEXT3,"P6"//char(0))
bret=SetDlgItemText(hDlg,ID_MRESULT1," 0 "//char(0)); bret=SetDlgItemText(hDlg,ID_MRESULT2," 0 "//char(0));bret=SetDlgItemText(hDlg,ID_MRESULT3," 0 "//char(0))
hDlgModeless=CreateDialog(hInst,LOC("J-VALUE"C),hDlg,LOC(jval))
do while (GetMessage(mesg, NULL, 0, 0).and.(hDlgModeless.ne.0))
if(IsDialogMessage(hDlgModeless,mesg)) then
do iel=ID_MRESULT1,ID_MRESULT3
nr=0;call numspin(jfromdialog,iel-ID_MRESULT1+5,cht1,cht2,nr,iflag)
if(nr.NE.0) then;rsp=respinb(nr); xtem=rsp.fk;write(buf,'(f13.8)') xtem;bret=SetDlgItemText(hDlg,iel,buf)
else; bret=SetDlgItemText(hDlg,iel,"0");end if
end do
write(buf,'(i4)') jfromdialog
bret=SetDlgItemText(hDlg,ID_MATRIXVALUE,"The value of J for this query is "//buf//char(0))
end if
end do
case(8)
bret=SetDlgItemText(hDlg,ID_MTEXT1,"U2"//char(0)); bret=SetDlgItemText(hDlg,ID_MTEXT2,"U4"//char(0));bret=SetDlgItemText(hDlg,ID_MTEXT3,"U6"//char(0))
bret=SetDlgItemText(hDlg,ID_MRESULT1," 0 "//char(0)); bret=SetDlgItemText(hDlg,ID_MRESULT2," 0 "//char(0));bret=SetDlgItemText(hDlg,ID_MRESULT3," 0 "//char(0))
nr=0;call numcr(cht1,cht2,nr,iflag)
if(nr.NE.0) then;rcr=rcrb(nr)
if(iflag.eq.1) then; buf='lower diagonal case! multiply by (-1)**(L-L)'//char(0);bret=SetDlgItemText(hDlg,ID_MATRIXVALUE,buf);end if
do iel=ID_MRESULT1,ID_MRESULT3
xtem=rcr.uk(iel-ID_MRESULT1+1)
write(buf,'(f13.8)') xtem;bret=SetDlgItemText(hDlg,iel,buf)
end do
else
do iel=ID_MRESULT1,ID_MRESULT3
bret=SetDlgItemText(hDlg,iel,"0")
end do
end if
case default
buf='No data for this query - could be zero'C
bret=SetDlgItemText(hDlg,ID_MATRIXVALUE,buf)
end select
! case(ID_MUPDATE)
! bret=update()
end select
end select
Reduced = 0
return
end function Reduced
character*3 function ToLowCase(cht)
character*3 cht
character c1,c2,c3
c1=cht(1:1);c2=cht(2:2);c3=cht(3:3)
SELECT CASE (c2)
CASE ( "A":"Z" )
c2 = CHAR( ICHAR(c2) + ICHAR("a") - ICHAR("A") )
END SELECT
ToLowCase=c1//c2//c3;return
end function ToLowCase
integer*4 function jval(hDlg, message, wParam, lParam )
!MS$ ATTRIBUTES STDCALL, ALIAS : '_jval@16' :: jval
integer*4 bret
integer*4 hDlg, message, wParam, lParam
integer*4 inelec
integer*4 il,iindex
character*2 buf
character*3 szbuf
lParam=lParam
select case (message)
case (WM_INITDIALOG)
inelec=nelec
select case(ie)
case(2)
if(inelec.gt.5) then;inelec=10-inelec;end if
case(3)
if(inelec.gt.7) then;inelec=14-inelec;end if
end select
il=jlistfl(inelec)
do while(il.le.jlistfu(inelec))
write(buf,'(i2)') il
bret=SendDlgItemMessage(hDlg,ID_MJLIST,LB_ADDSTRING,0,LOC(buf))
il=il+2
end do
case (WM_COMMAND)
iindex=SendDlgItemMessage(hDlg,ID_MJLIST,LB_GETCURSEL,0,0)
bret=SendDlgItemMessage(hDlg,ID_MJLIST,LB_GETTEXT,iindex,LOC(szbuf))
buf=szbuf(1:2)
read(buf,'(i2)') jfromdialog
select case(INT4(LoWord(wparam)))
case(IDOK)
bret=DestroyWindow(hDlg)
hDlgModeless=0
jval=0
end select
end select
jval=0
end function jval
!/****************************************************************************
!
! FUNCTION: calc()
!
! PURPOSE: Calculates matrix and finds eigensystem
!
! MESSAGES:
!****************************************************************************/
integer function calc( )
use pardia
use matrix
integer*4 hWndc,ret
integer*4 hcur
!character*800 cbuf
!character*1 cad
!character*3 cht
hWndc=hMWindow
open(21,file='debug.txt')
!call FreeIon()
!call crfpar()
if(mansel.eq.1) then
ret=DialogBox(hInst, LOC("TERMS"C), hWndc, LOC(terms))
if(ret.eq.0) then
calc=1;return
end if
else
ret=info()
end if
idatagl=1
!hdc=GetDC(hcmd);ret=TextOut(hdc,30,30,"Building LSJ matrix..."C,22);bret=ReleaseDC(hcmd,hdc)
hcur=hcur !LoadCursor( NULL, IDC_WAIT)
!hcur=SetCursor(hcur)
ret=matj()
write(21,*) "matj passed"
!hdc=GetDC(hcmd);ret=TextOut(hdc,30,30,"Building final matrix..."C,24);bret=ReleaseDC(hcmd,hdc)
if(ioptima.eq.1) then
ret=matls()
write(21,*) "matls passed"
end if
open(1,file='temp.txt')
write(21,*) "file temp opened"
read(1,'(i4)') ic
do i=1,ic
read(1,'(i2,i2,a1,a3,f9.1)') i1,i2,cad,cht,u
write(21,'(i2,i2,a1,a3,f9.1)') i1,i2,cad,cht,u
!i1=4*(i-1); cbuf(i1+1:i1+3)=cht; cbuf(i1+4:i1+4)=' '
end do
close(1) !;close(2)
ret=FreeMem()
idatagl=1
ret=matj()
write(21,*) "matj passed"
!hdc=GetDC(hcmd);ret=TextOut(hdc,30,30,"Building final matrix..."C,24);bret=ReleaseDC(hcmd,hdc)
ifl=0
do i=1,3
do j=1,7
if(AIMAG(Bpk(i,j)).ne.0) ifl=1
end do
end do
if(ifl.eq.0) then
ret=finmatre()
else
ret=finmat()
endif
write(21,*) "finmat passed"
hcur=hcur ! LoadCursor( NULL, IDC_ARROW)
!hcur=SetCursor(hcur)
ret=FreeMem()
write(21,*) "memory deallocated"
ret=DialogBox(hInst, LOC("RESULTS"C), hWndc, LOC(results))
write(21,*) "results are shown"
close(21)
!hdc=GetDC(hcmd); ret=TextOut(hdc,30,30,"New task? "C,35);bret=ReleaseDC(hcmd,hdc);ret=UpdateWindow(hWnd)
!ret=SendMessage(hWndc,WM_SIZE, SIZE_RESTORED,0)
idatagl=1
calc=1
return
end function calc
!/****************************************************************************
!
! FUNCTION: terms( hDlg, message, wParam, lParam )
!
! PURPOSE: Manual terms selection for building of natrix to diagonalize
!
! MESSAGES:
!****************************************************************************
integer*4 function terms( hDlg, message, wParam, lParam )
!MS$ ATTRIBUTES STDCALL, ALIAS : '_terms@16' :: terms
integer*4 hDlg, message, wParam, lParam
integer*4 ret
integer i,j,nt,ne
character*3,allocatable :: cht(:)
character*4 szbuf,szbuf1
integer isel,icount,idel,iStart
LPARAM = LPARAM
!call CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER))
select case (message)
case (WM_INITDIALOG); i=1;nt=1;ne=nelec
select case(ie)
case(2)
if(ne.gt.5) then;iflag=1;ne=10-ne;end if;nt=dcon(ne)%con%nst
case(3)
if(ne.gt.7) then;iflag=1;ne=14-ne;end if;nt=fcon(ne)%con%nst
end select
allocate(cht(nt))
do i=1,nt
if(ie.eq.3) then;cht(i)=fcon(ne)%iLS(3*(i-1)+1:3*i);else
cht(i)=dcon(ne)%iLS(3*(i-1)+1:3*i)
end if
ret=SendDlgItemMessage(hDlg,ID_CTERMSALL,LB_ADDSTRING,0,LOC(cht(i)//CHAR(0)))
end do
deallocate(cht)
case (WM_COMMAND)
select case(INT4(LoWord(wparam)))
case(ID_CADD)
icount=SendDlgItemMessage(hDlg,ID_CTERMSINCLUDED,LB_GETCOUNT,0,0)
if(icount.gt.47) then
iStart=47
else
iStart=nt
end if
do i=1,iStart
isel=SendDlgItemMessage(hDlg,ID_CTERMSALL,LB_GETSEL,i-1,0)
if(isel.ne.0) then
ret=SendDlgItemMessage(hDlg,ID_CTERMSALL,LB_GETTEXT,i-1,LOC(szbuf))
icount=SendDlgItemMessage(hDlg,ID_CTERMSINCLUDED,LB_GETCOUNT,0,0)
idel=0
do j=1,MAX(1,icount)
ret=SendDlgItemMessage(hDlg,ID_CTERMSINCLUDED,LB_GETTEXT,j-1,LOC(szbuf1))
if(szbuf.eq.szbuf1) idel=1
end do
if(idel.eq.0) then
ret=SendDlgItemMessage(hDlg,ID_CTERMSINCLUDED,LB_ADDSTRING,icount,LOC(szbuf))
end if
end if
end do
case(ID_CADDALL)
ret=SendDlgItemMessage(hDlg,ID_CTERMSINCLUDED,LB_RESETCONTENT,0,0)
iStart=nt !MIN(nt,22)
do i=1,iStart
ret=SendDlgItemMessage(hDlg,ID_CTERMSALL,LB_GETTEXT,i-1,LOC(szbuf))
ret=SendDlgItemMessage(hDlg,ID_CTERMSINCLUDED,LB_ADDSTRING,0,LOC(szbuf))
end do
case(ID_CREMOVE)
icount=SendDlgItemMessage(hDlg,ID_CTERMSINCLUDED,LB_GETCOUNT,0,0)
do i=1,MAX(1,icount)
isel=SendDlgItemMessage(hDlg,ID_CTERMSINCLUDED,LB_GETSEL,i-1,0)
if(isel.ne.0) then
ret=SendDlgItemMessage(hDlg,ID_CTERMSINCLUDED,LB_DELETESTRING,i-1,0)
end if
end do
case(ID_CREMOVEALL)
ret=SendDlgItemMessage(hDlg,ID_CTERMSINCLUDED,LB_RESETCONTENT,0,0)
case(IDOK)
icount=SendDlgItemMessage(hDlg,ID_CTERMSINCLUDED,LB_GETCOUNT,0,0)
if(icount.ne.0) then
allocate(cht(icount))
do i=1, icount
ret=SendDlgItemMessage(hDlg,ID_CTERMSINCLUDED,LB_GETTEXT,i-1,LOC(szbuf))
cht(i)=szbuf(1:3)
end do
ret=infow(icount,cht)
ret=EndDialog(hDlg,TRUE);deallocate(cht);terms=1;return
end if
case(IDCANCEL)
ret=EndDialog(hDlg,FALSE);terms=1;return
end select
end select
terms=0;return
end function terms
!/****************************************************************************
!
! FUNCTION: results( hDlg, message, wParam, lParam )
!
! PURPOSE: Output of eigensystem
!
! MESSAGES:
!****************************************************************************/
integer*4 function results( hDlg, message, wParam, lParam )
!MS$ ATTRIBUTES STDCALL, ALIAS : '_results@16' :: results
use openfort
use zeeman
integer*4 hDlg, message, wParam, lParam
integer*4 ret,hmenu
integer i,i1,ivect,j
character*810 buf
character*20 buft
character*20, save, allocatable :: vect(:)
character*810, save, allocatable :: bufar(:)
character*17 szbuf
character*1 vID;logical IsThere;integer FileStatus
character*40 tasknameo
integer, save :: iRecords
LPARAM = LPARAM
iRecords=0
!call CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER))
select case (message)
case (WM_INITDIALOG)
ret=SetDlgItemText(hDlg,ID_CSTATICNAME,taskname)
hmenu=GetMenu(hDlg)
INQUIRE (FILE = 'out.txt', EXIST = IsThere)
IF (IsThere) THEN
FileStatus=0
tasknameo=taskname
open(1,file='out.txt',access='direct',form='formatted',recl=810)
else
ret=Initoflev()
IF (ret.eq.1) THEN
FileStatus=1
open(1,file=ofbuffer,access='direct',form='formatted',recl=810)
i=lstrlen(CurrentLev)
i1=lstrlen(ofbuffer)
tasknameo=taskname
taskname=ofbuffer(i+2:i1-4)
ret=SetDlgItemText(hDlg,ID_CSTATICNAME,taskname//char(0))
ret=EnableMenuItem(hmenu,ID_CALCULATE_SAVE, MF_GRAYED)
else
!ret=MessageBox(NULL," File was not found"C,"Error"C,MB_OK)
ret=EndDialog(hDlg,FALSE)
return
end if
end if
ioutpos=1
open(999,file="outdump.txt")
do while (.NOT. EOF(1))
read(1,'(A810)',rec=ioutpos) buf
write(999,'(A810)') buf
ioutpos=ioutpos+1
buft=buf(3:10)
write(999,'(a8)') buft
ret=SendDlgItemMessage(&
hDlg,ID_CALCULATE_RESULTS,LB_ADDSTRING,0,LOC(buft//CHAR(0)))
iRecords=iRecords+1
end do
close(999)
allocate(bufar(iRecords))
! rewind(1)
do i=1,iRecords
read(1,'(a810)',rec=i) bufar(i)
end do
if(FileStatus.eq.0) then
close(1,status='delete')
else
close(1)
end if
ret=SendDlgItemMessage(hDlg,ID_CALCULATE_RESULTS,LB_SETCURSEL,0,0)
case (WM_COMMAND)
i=SendDlgItemMessage(hDlg,ID_CALCULATE_RESULTS,LB_GETCURSEL,0,0)
buf=bufar(i+1)
buft=buf(1:2)
read(buft,'(i2)') ivect
allocate(vect(ivect))
ret=SendDlgItemMessage(&
hDlg,ID_CALCULATE_VECTORSN,LB_RESETCONTENT,0,0)
ret=SendDlgItemMessage(&
hDlg,ID_CALCULATE_VECTORS,LB_RESETCONTENT,0,0)
ret=SendDlgItemMessage(&
hDlg,ID_CALCULATE_VECTORS2,LB_RESETCONTENT,0,0)
do i=1,ivect
vect(i)=buf(11+(i-1)*(20):10+i*20)
end do
do i=1,ivect
buft=vect(i)
szbuf=buft(2:3)
read(szbuf,*) j
vID=ToUpCase(toL(j/2))
szbuf=buft(1:1)//vid//' '//buft(4:5)//char(47)//'2 '//buft(6:8)//'(2Jm)'//char(0)
ret=SendDlgItemMessage(&
hDlg,ID_CALCULATE_VECTORSN,LB_ADDSTRING,0,LOC(szbuf))
szbuf=buft(9:14)//char(0)
ret=SendDlgItemMessage(&
hDlg,ID_CALCULATE_VECTORS,LB_ADDSTRING,0,LOC(szbuf))
szbuf=buft(15:20)//char(0)
ret=SendDlgItemMessage(&
hDlg,ID_CALCULATE_VECTORS2,LB_ADDSTRING,0,LOC(szbuf))
end do
deallocate(vect)
select case(INT4(LoWord(wparam)))
case(ID_ZEEMAN_G)
iRecords=SIZE(bufar)
ret=gfactor(iRecords, bufar)
case(ID_CALCULATE_SAVE)
!!!!!!!!!!!!!!!!!!!!!insert code here!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ret=lstrcpy(buf,taskname(1:lstrlen(taskname))//".lev"C)
open(1,file=buf,access='direct',form='formatted',recl=810)
iRecords=SIZE(bufar)
do i=1,iRecords
write(1,'(A810)',rec=i) bufar(i)
end do
close(1)
ret=EnableMenuItem(hmenu,ID_CALCULATE_SAVE, MF_GRAYED)
case(IDOK)
taskname=tasknameo
ret=EnableMenuItem(hmenu,ID_CALCULATE_SAVE, MF_ENABLED)
deallocate(bufar)
ret=EndDialog(hDlg,TRUE)
results=1;return
case(IDCANCEL)
ret=EnableMenuItem(hmenu,ID_CALCULATE_SAVE, MF_ENABLED)
deallocate(bufar)
ret=EndDialog(hDlg,FALSE)
results=1; return
end select
end select
results=0
return
end function results
!/****************************************************************************
!
! FUNCTION: resultsfit( hDlg, message, wParam, lParam )
!
! PURPOSE: Output of eigensystem
!
! MESSAGES:
!****************************************************************************/
integer*4 function resultsfit( hDlg, message, wParam, lParam )
!MS$ ATTRIBUTES STDCALL, ALIAS : '_resultsfit@16' :: resultsfit
use openfort
use zeeman
integer*4 hDlg, message, wParam, lParam
integer*4 ret,hmenu
integer iRecords,i,i1,ivect,j
character*810 buf
character*20 buft
character*20, save, allocatable :: vect(:)
character*810,save, allocatable :: bufar(:)
character*17 szbuf
character*1 vID;logical IsThere;integer FileStatus
character*40 tasknameo
character*10 expbuf
LPARAM = LPARAM;iRecords=0
!call CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER))
select case (message)
case (WM_INITDIALOG)
ret=SetDlgItemText(hDlg,ID_CSTATICNAME,taskname)
ret=SetDlgItemText(hDlg,ID_FIT_ACCURACY,bave//char(0))
hmenu=GetMenu(hDlg)
do i=1,numlevtofit
write(expbuf,'(f8.1)') tf(i)
ret=SendDlgItemMessage(&
hDlg,ID_CALCULATE_RESULTSE,LB_ADDSTRING,0,LOC(expbuf//CHAR(0)))
end do
INQUIRE (FILE = 'out.txt', EXIST = IsThere)
IF (IsThere) THEN
FileStatus=0
tasknameo=taskname
open(1,file='out.txt',access='direct',form='formatted',recl=810)
else
ret=Initoflev()
IF (ret.eq.1) THEN
FileStatus=1
open(1,file=ofbuffer,access='direct',form='formatted',recl=810)
i=lstrlen(CurrentLev)
i1=lstrlen(ofbuffer)
tasknameo=taskname
taskname=ofbuffer(i+2:i1-4)
ret=SetDlgItemText(hDlg,ID_CSTATICNAME,taskname//char(0))
ret=EnableMenuItem(hmenu,ID_CALCULATE_SAVE, MF_GRAYED)
else
!ret=MessageBox(NULL," File was not found"C,"Error"C,MB_OK)
ret=EndDialog(hDlg,FALSE)
return
end if
end if
do while (.NOT. EOF(1))
read(1,'(A10)',rec=iRecords+1) buf
buft=buf(3:10)
ret=SendDlgItemMessage(&
hDlg,ID_CALCULATE_RESULTS,LB_ADDSTRING,0,LOC(buft//CHAR(0)))
iRecords=iRecords+1
end do
allocate(bufar(iRecords))
! rewind(1)
do i=1,iRecords
read(1,'(A810)',rec=i) bufar(i)
end do
if(FileStatus.eq.0) then
close(1,status='delete')
else
close(1)
end if
ret=SendDlgItemMessage(hDlg,ID_CALCULATE_RESULTS,LB_SETCURSEL,0,0)
case (WM_COMMAND)
i=SendDlgItemMessage(hDlg,ID_CALCULATE_RESULTS,LB_GETCURSEL,0,0)
buf=bufar(i+1)
buft=buf(1:2)
read(buft,*) ivect
allocate(vect(ivect))
ret=SendDlgItemMessage(&
hDlg,ID_CALCULATE_VECTORSN,LB_RESETCONTENT,0,0)
ret=SendDlgItemMessage(&
hDlg,ID_CALCULATE_VECTORS,LB_RESETCONTENT,0,0)
ret=SendDlgItemMessage(&
hDlg,ID_CALCULATE_VECTORS2,LB_RESETCONTENT,0,0)
do i=1,ivect
vect(i)=buf(11+(i-1)*(20):10+i*20)
end do
do i=1,ivect
buft=vect(i)
szbuf=buft(2:3)
read(szbuf,*) j
vID=ToUpCase(toL(j/2))
szbuf=buft(1:1)//vid//' '//buft(4:5)//char(47)//'2 '//buft(6:8)//'(2Jm)'//char(0)
ret=SendDlgItemMessage(&
hDlg,ID_CALCULATE_VECTORSN,LB_ADDSTRING,0,LOC(szbuf))
szbuf=buft(9:14)//char(0)
ret=SendDlgItemMessage(&
hDlg,ID_CALCULATE_VECTORS,LB_ADDSTRING,0,LOC(szbuf))
szbuf=buft(15:20)//char(0)
ret=SendDlgItemMessage(&
hDlg,ID_CALCULATE_VECTORS2,LB_ADDSTRING,0,LOC(szbuf))
end do
deallocate(vect)
select case(INT4(LoWord(wparam)))
case(ID_ZEEMAN_G)
iRecords=SIZE(bufar)
ret=gfactor(iRecords, bufar)
case(ID_CALCULATE_SAVE)
!!!!!!!!!!!!!!!!!!!!!insert code here!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ret=lstrcpy(buf,taskname(1:lstrlen(taskname))//".lev"C)
open(1,file=buf,access='direct',form='formatted',recl=810)
iRecords=SIZE(bufar)
do i=1,iRecords
write(1,'(A810)',rec=i) bufar(i)
end do
close(1)
ret=EnableMenuItem(hmenu,ID_CALCULATE_SAVE, MF_GRAYED)
case(IDOK)
taskname=tasknameo
ret=EnableMenuItem(hmenu,ID_CALCULATE_SAVE, MF_ENABLED)
deallocate(bufar)
ret=EndDialog(hDlg,TRUE)
resultsfit=1;return
case(IDCANCEL)
ret=EnableMenuItem(hmenu,ID_CALCULATE_SAVE, MF_ENABLED)
deallocate(bufar)
ret=EndDialog(hDlg,FALSE)
resultsfit=1; return
end select
end select
resultsfit=0
return
end function resultsfit
character*1 function ToUpCase(cht)
character*1 cht
SELECT CASE (cht)
CASE ( "a":"z" )
cht = CHAR( ICHAR(cht) + ICHAR("A") - ICHAR("a") )
END SELECT
ToUpCase=cht;return
end function ToUpCase
!/****************************************************************************
!
! FUNCTION: CenterWindow (HWND, HWND)
!
! PURPOSE: Center one window over another
!
! COMMENTS:
!
! Centering the dialog over a particular window usually results in a better position.
!
!****************************************************************************/
subroutine CenterWindow (hwndChild, hwndParent)
use msfwina
use spinc
integer hwndChild, hwndParent
type (T_RECT) rChild, rParent
integer wChild, hChild, wParent, hParent
integer wScreen, hScreen, xNew, yNew
integer hdc
integer*4 retval
! Get the Height and Width of the child window
retval = GetWindowRect (hwndChild, rChild)
wChild = rChild.right - rChild.left
hChild = rChild.bottom - rChild.top
! Get the Height and Width of the parent window
retval = GetWindowRect (hwndParent, rParent)
wParent = rParent.right - rParent.left
hParent = rParent.bottom - rParent.top
! Get the display limits
hdc = GetDC (hwndChild)
wScreen = GetDeviceCaps (hdc, HORZRES)
hScreen = GetDeviceCaps (hdc, VERTRES)
retval = ReleaseDC (hwndChild, hdc)
! Calculate new X position, then adjust for screen
xNew = rParent.left + ((wParent - wChild) /2)
if (xNew .LT. 0) then
xNew = 0
else if ((xNew+wChild) .GT. wScreen) then
xNew = wScreen - wChild
end if
! Calculate new Y position, then adjust for screen
yNew = rParent.top + ((hParent - hChild) /2)
if (yNew .LT. 0) then
yNew = 0
else if ((yNew+hChild) .GT. hScreen) then
yNew = hScreen - hChild
end if
! Set it, and return
ret = SetWindowPos(hwndChild, NULL, xNew, yNew, 0, 0, &
IOR(SWP_NOSIZE ,SWP_NOZORDER))
end subroutine CenterWindow
!/****************************************************************************
!
! FUNCTION: Options( hDlg, message, wParam, lParam )
!
! PURPOSE: Allows users to have additional control over the program
!
! MESSAGES:
!****************************************************************************/
integer*4 function Options( hDlg, message, wParam, lParam )
!MS$ ATTRIBUTES STDCALL, ALIAS : '_options@16' :: options
integer*4 hDlg, message, wParam, lParam
integer*4 ret
LPARAM = LPARAM
!call CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER))
select case (message)
case (WM_INITDIALOG)
ret=CheckDlgButton(hDlg,ID_OTERMSSEL,mansel)
ret=CheckDlgButton(hDlg,ID_ONORMW,1)
ret=SetDlgItemText(hDlg,ID_ONAME,taskname(1:lstrlen(taskname)))
ret=SetDlgItemInt(hDlg,ID_OVECT,INT(wavefix*100),.FALSE.)
ret=SetDlgItemInt(hDlg,ID_OVECTNUMB,numfix,.FALSE.)
ret=SetDlgItemInt(hDlg,ID_OENERGY,efix,.FALSE.)
ret=SetDlgItemInt(hDlg,ID_FITTING_ACCURACY,genmax,.FALSE.)
case (WM_COMMAND)
select case(INT4(LoWord(wparam)))
case(ID_OTERMSSEL)
mansel=IsDlgButtonChecked(hDlg,ID_OTERMSSEL)
case(IDOK)
ret=GetDlgItemInt(hDlg,ID_OVECT, NULL,.FALSE.)
wavefix=ret/100.
ret=GetDlgItemInt(hDlg,ID_OVECTNUMB, NULL,.FALSE.)
numfix=ret
ret=GetDlgItemInt(hDlg,ID_FITTING_ACCURACY, NULL,.FALSE.)
genmax=ret
if(genmax.le.0.or.genmax.gt.25) genmax=8
ret=GetDlgItemInt(hDlg,ID_OENERGY, NULL,.FALSE.)
efix=ret
if(efix.gt.70000) then
ret=MessageBox(NULL," That's too much! Energy maximum is set to 70000"C,"Error in input"C,MB_ICONSTOP)
efix=70000
end if
ret=GetDlgItemText(hDlg,ID_ONAME,taskname,40)
ret=EndDialog(hDlg,TRUE)
Options=1;return
end select
end select
Options=0;return
end function Options
!/****************************************************************************
!
! FUNCTION: Paramf( hDlg, message, wParam, lParam )
!
! PURPOSE: Perform dialog to input free-ion parameters
!
! MESSAGES:
!****************************************************************************/
integer*4 function Paramf( hDlg, message, wParam, lParam )
!MS$ ATTRIBUTES STDCALL, ALIAS : '_paramf@16' :: paramf
use pardia
integer*4 hDlg, message, wParam, lParam
integer*4 ret
integer i,idzeta
integer,dimension(3) :: ipf
LPARAM = LPARAM
!call CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER))
select case (message)
case (WM_INITDIALOG)
ret=SetDlgItemText(hDlg,ID_PFSTATICNAME,taskname)
ipf(1)=INT(electro(1));ipf(2)=INT(electro(2));ipf(3)=INT(electro(3))
idzeta=INT(magnetic(1))
do i=ID_PF2,ID_PF6
ret=SetDlgItemInt(hDlg,i, ipf(i-ID_PF2+1),.FALSE.)
end do
ret=SetDlgItemInt(hDlg,ID_PFDZETA, idzeta,.FALSE.)
case (WM_COMMAND)
select case(INT4(LoWord(wparam)))
case(IDYES)
do i=ID_PF2,ID_PF6
ipf(i-ID_PF2+1)=GetDlgItemInt(hDlg,i, NULL,.FALSE.)
end do
idzeta=GetDlgItemInt(hDlg,ID_PFDZETA, NULL,.FALSE.)
do ixe=1,3;electro(ixe)=ipf(ixe);end do
magnetic(1)=idzeta
case(IDRETRY)
ret=SendMessage(hDlg,WM_INITDIALOG,0,0)
case(IDCANCEL)
ret=EndDialog(hDlg,FALSE)
case(IDOK)
do i=ID_PF2,ID_PF6
ipf(i-ID_PF2+1)=GetDlgItemInt(hDlg,i, NULL,.FALSE.)
end do
idzeta=GetDlgItemInt(hDlg,ID_PFDZETA, NULL,.FALSE.)
do ixe=1,3;electro(ixe)=ipf(ixe);end do
magnetic(1)=idzeta
ret=EndDialog(hDlg,TRUE)
Paramf=1;return
end select
end select
Paramf=0;return
end function Paramf
subroutine pfreeopen(hWnd)
use pardia
integer*4 hWnd,ret
call FreeIon()
ret=DialogBox(hInst,LOC("PARAMF"C),hWnd,LOC(Paramf))
end subroutine pfreeopen
subroutine paradopen(hWnd)
use pardia
integer*4 hWnd,ret
call FreeIon()
ret=DialogBox(hInst,LOC("PARAD"C),hWnd,LOC(Parad))
end subroutine paradopen
!/****************************************************************************
!
! FUNCTION: Parad( hDlg, message, wParam, lParam )
!
! PURPOSE: Perform dialog to input advanced free-ion parameters
!
! MESSAGES:
!****************************************************************************/
integer*4 function Parad( hDlg, message, wParam, lParam )
!MS$ ATTRIBUTES STDCALL, ALIAS : '_parad@16' :: parad
use pardia
integer*4 hDlg, message, wParam, lParam
integer*4 ret