-
Notifications
You must be signed in to change notification settings - Fork 1
/
mimosa_base.f90
6886 lines (5855 loc) · 180 KB
/
mimosa_base.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 MIMOSA_BASE3_MODULE
!*************************************
INTERFACE
SUBROUTINE ReplaceElement(GrpPtr,ElemPtr,StrucName,&
OutElemFile,OutName,clearFlag,Status)
!-----------------------------------------------------
IMPLICIT NONE
!INPUT/OUTPUT VARIABLES
INTEGER :: GrpPtr,ElemPtr
CHARACTER(len=*) :: StrucName,OutElemFile,OutName
INTEGER :: Status
LOGICAL :: clearFlag
END SUBROUTINE ReplaceElement
SUBROUTINE ReplaceIdx(GrpPtr,ElemPtr,StrucName,StrucNameInt,&
OutElemFile,OutName,clearflag,Status)
!-----------------------------------------------------------
IMPLICIT NONE
!INPUT/OUTPUT VARIABLES
INTEGER :: GrpPtr,ElemPtr
CHARACTER(len=*) :: StrucName,StrucNameInt,OutElemFile,OutName
LOGICAL :: clearFlag
INTEGER :: Status
END SUBROUTINE ReplaceIdx
SUBROUTINE EnergyBandInfo(GrpPtr,EBins,CHans,Status)
!----------------------------------------------------
IMPLICIT NONE
!INPUT/OUTPUT VARIABLES
REAL(kind=4),dimension(:,:),pointer :: EBins
INTEGER,dimension(:,:),pointer :: Chans
INTEGER :: GrpPtr,Status
END SUBROUTINE EnergyBandInfo
SUBROUTINE FixSouPosInCat(Status)
!-----------------------------------
IMPLICIT NONE
!INPUT/OUTPUT VARIABLES
INTEGER :: Status
END SUBROUTINE FixSouPosInCat
SUBROUTINE ReadAttributesAndAtti(imos,GrpPtr,RaX,DecX,RaZ,DecZ,posAngle,&
incr,Status)
!---------------------------------------
IMPLICIT NONE
!INPUT/OUTPUT VARIABLES
INTEGER :: imos,GrpPtr
! pointer to output source catalogue
REAL(kind=8), dimension(:), pointer :: RaX,DecX,RaZ,DecZ,posAngle
REAL(kind=8) ::incr
INTEGER :: Status
END SUBROUTINE ReadAttributesAndAtti
SUBROUTINE WriteRecallInfo(MosaNumber,RaX,DecX,RaZ,DecZ,posAngle)
!------------------------------------------------------
IMPLICIT NONE
!INPUT/OUTPUT VARIABLES
INTEGER :: MosaNumber
REAL(kind=8), dimension(:), pointer :: RaX,DecX,RaZ,DecZ,posAngle
END SUBROUTINE WriteRecallInfo
SUBROUTINE ReadRecallInfo(MosaNumber,RaX,DecX,RaZ,DecZ,posAngle)
!----------------------------------------------------------------
IMPLICIT NONE
!INPUT/OUTPUT VARIABLES
INTEGER :: MosaNumber
REAL(kind=8), dimension(:), pointer :: RaX,DecX,RaZ,DecZ,posAngle
END SUBROUTINE ReadRecallInfo
END INTERFACE
!*************************************
END MODULE MIMOSA_BASE3_MODULE
!*************************************
!*************************************
MODULE MIMOSA_BASE2_MODULE
!*************************************
INTERFACE
SUBROUTINE WriteAttiHeader(imatype,num,nx,ny,ImaPtr,Status)
!..........................................................
IMPLICIT NONE
!INPUT VARIABLES
INTEGER :: imatype ! 0 - scw, 1 - map
INTEGER :: num !pointing number
INTEGER :: nx,ny ! image dimensions
INTEGER :: ImaPtr !image pointer
!OUTPUT VARIABLES
INTEGER :: Status
END SUBROUTINE WriteAttiHeader
SUBROUTINE WriteAttributes(ObjPtr,MemberPtr,scw,OutBand,&
ImaFlag,ImaType,ImaTypeVal,&
Status)
!------------------------------------------------------
IMPLICIT NONE
!INPUT VARIABLES
INTEGER :: ObjPtr,MemberPtr,scw ! pointer to index member
INTEGER :: OutBand ! out energy band number
INTEGER :: ImaFlag
! 0 - groupped shd
! 1 - image
! 2 - carte
character(len=*) :: imaType,imaTypeVal
!OUTPUT VARIABLES
INTEGER :: Status
END SUBROUTINE WriteAttributes
SUBROUTINE VerifBins(nrows,tab1,tab2,tabind,bins,bnum,str,Status)
!---------------------------------------------------------
IMPLICIT NONE
!INPUT/OUTPUT VARIABLES
INTEGER :: nrows,bnum,iok
CHARACTER(len = *) :: str
REAL(kind=4),dimension(:),pointer :: tab1,tab2,tabind
REAL(kind=4),dimension(:,:),pointer ::bins
INTEGER :: Status
END SUBROUTINE VerifBins
END INTERFACE
!*************************************
END MODULE MIMOSA_BASE2_MODULE
!*************************************
!*********************************
MODULE MIMOSA_BASE1_MODULE
!*********************************
INTERFACE
SUBROUTINE DECO(scwcleaimage)
!_____________________________________________
IMPLICIT NONE
!INPUT VARIABLES
REAL(kind=4),dimension(:,:),pointer :: scwcleaimage
END SUBROUTINE deco
subroutine RealSize(scwcleaimage,imin,imax,jmin,jmax)
!------------------------------------------------------
IMPLICIT NONE
!INPUT VARIABLES
REAL,dimension(:,:),pointer :: scwcleaimage
integer ::imin,imax,jmin,jmax
END SUBROUTINE RealSize
subroutine PutCol(Ptr,nsou,tab,colname,colnr,&
SourceList,Status)
!........................................................
IMPLICIT NONE
!INPUT VARIABLES
INTEGER :: Ptr,nsou,colnr
REAL(kind=4),dimension(:),pointer :: tab
REAL(kind=4),dimension(:,:),pointer :: SourceList
CHARACTER(len=*) :: colname
!OUTPUT VARIABLES
INTEGER :: Status
end subroutine PutCol
subroutine UpdateOutCat(type,Scw,OutBand,nsou,SourceList,&
alpha,delta,flux,fluxerr,snr,locerr, Status)
!........................................
IMPLICIT NONE
!INPUT VARIABLES
INTEGER ::type,Scw,OutBand, nsou
REAL(kind=4),dimension(:,:),pointer :: SourceList
REAL(kind=4),dimension(:),pointer:: alpha,delta,flux,fluxerr,snr,locerr
!OUTPUT VARIABLES
INTEGER :: Status
end subroutine UpdateOutCat
SUBROUTINE NewIndexMember&
(IdxPtr,OutBand,StrucName,MemberPtr,Status)
!........................................................
IMPLICIT NONE
!INPUT VARIABLES
INTEGER :: IdxPtr,OutBand
CHARACTER(len=*) :: StrucName
!OUTPUT VARIABLES
INTEGER :: MemberPtr
INTEGER :: Status
END SUBROUTINE NewIndexMember
SUBROUTINE AddIndexMemberArray(ObjPtr,IdxPtr,scw,OutBand,ImaFlag,&
ArrName,ArrType,ArrTypeVal,Arr,MemberPtr,Status)
!........................................................
IMPLICIT NONE
!INPUT VARIABLES
INTEGER :: ObjPtr,IdxPtr,scw,OutBand
!OutBand - number of output energy band
INTEGER :: ImaFlag
! if yes then write attitude info into the header
! and some additional keywords
CHARACTER(len=*) :: ArrName,ArrType,ArrTypeVal
REAL(kind=4),dimension(:,:),pointer :: Arr
!OUTPUT VARIABLES
INTEGER :: MemberPtr
INTEGER :: Status
END SUBROUTINE AddIndexMemberArray
SUBROUTINE CreateClear(ParentPtr,ElemType,ClearFlag,&
StrucNameExt,StrucNameInt,FitsName,ElemPtr,&
Status)
!........................................................
IMPLICIT NONE
!INPUT VARIABLES
INTEGER ,Intent(in) :: ParentPtr
INTEGER ,Intent(in) :: ElemType
! if ElemType == 0 then element else index
INTEGER ,Intent(in) :: ClearFlag
! 0 - no clearing of existing element ( or index)
! 1 - clears rows(members) of element(index) if exist
character(len=*),Intent(in) :: StrucNameExt
! for ordinary element its structure name
! for index its index structure name
character(len=*),Intent(in) :: StrucNameInt
! for ordinary element not used
! for index its member structure name
character(len=*),Intent(in) :: FitsName
! name of fits file of the element
!OUTPUT VARIABLES
INTEGER ,Intent(out) :: ElemPtr
INTEGER :: Status
END SUBROUTINE CreateClear
SUBROUTINE GetClearElement(ParentPtr,StrucName,ElemPtr,&
Status)
!........................................................
IMPLICIT NONE
!INPUT VARIABLES
INTEGER ,Intent(in) :: ParentPtr
character(len=*),Intent(in) :: StrucName
!OUTPUT VARIABLES
INTEGER ,Intent(out) :: ElemPtr
INTEGER :: Status
END SUBROUTINE GetClearElement
SUBROUTINE ClearDetachElement(ParentPtr,StrucName,ElemPtr,&
Status)
!........................................................
IMPLICIT NONE
!INPUT VARIABLES
INTEGER ,Intent(in) :: ParentPtr
character(len=*),Intent(in) :: StrucName
!OUTPUT VARIABLES
INTEGER ,Intent(out) :: ElemPtr
INTEGER :: Status
END SUBROUTINE ClearDetachElement
SUBROUTINE CreateClearIndex(ParentPtr,StrucNameExt,StrucNameInt,&
FitsName,ElemPtr,Status)
!........................................................
IMPLICIT NONE
!INPUT VARIABLES
INTEGER ,Intent(in) :: ParentPtr
character(len=*),Intent(in) :: StrucNameExt
! for ordinary element its structure name
! for index its index structure name
character(len=*),Intent(in) :: StrucNameInt
! for ordinary element not used
! for index its member structure name
character(len=*),Intent(in) :: FitsName
! name of fits file of the element
!OUTPUT VARIABLES
INTEGER ,Intent(out) :: ElemPtr
INTEGER :: Status
END SUBROUTINE CreateClearIndex
SUBROUTINE GetClearIndex(ParentPtr,StrucNameExt,StrucNameInt,ElemPtr,Status)
!........................................................
IMPLICIT NONE
!INPUT VARIABLES
INTEGER ,Intent(in) :: ParentPtr
character(len=*),Intent(in) :: StrucNameExt
! index structure name
character(len=*),Intent(in) :: StrucNameInt
! index member structure name
!OUTPUT VARIABLES
INTEGER ,Intent(out) :: ElemPtr
INTEGER :: Status
END SUBROUTINE GetClearIndex
SUBROUTINE OpenIndexMember(IdxPtr,&
MemberName,MemberNum,MemberPtr,&
nFound,Status)
!...........................................
IMPLICIT NONE
!INPUT VARIABLES
INTEGER :: IdxPtr ! pointer to index
CHARACTER(len=*) :: MemberName ! MEMBER NAME
INTEGER :: MemberNum ! member row number
!OUTPUT VARIABLES
INTEGER :: MemberPtr !pointer to member
INTEGER :: nFound
INTEGER :: Status
END SUBROUTINE OpenIndexMember
SUBROUTINE ReadArray(ArrPtr,iDim,jDim,Arr,Status)
!................................................
IMPLICIT NONE
!INPUT VARIABLES
INTEGER,Intent(in) :: ArrPtr,iDim,jDim
!OUTPUT VARIABLES
REAL(kind=4),dimension(:,:),pointer :: Arr
INTEGER :: Status
END SUBROUTINE ReadArray
SUBROUTINE ReadUnknownArray(ArrPtr,iDim,jDim,Arr,Status)
!................................................
IMPLICIT NONE
!INPUT VARIABLES
INTEGER :: ArrPtr,iDim,jDim
!OUTPUT VARIABLES
REAL(kind=4),dimension(:,:),pointer :: Arr
INTEGER :: Status
END SUBROUTINE ReadUnknownArray
SUBROUTINE ReadShdAttributes(MemberNum,MemberPtr,eMinVal,&
eMaxVal,Status)
!-------------------------------------------------------
IMPLICIT NONE
!INPUT VARIABLES
INTEGER :: MemberNum,MemberPtr !index member no, pointer to
!OUTPUT VARIABLES
REAL(kind=4) :: eMinVal,EMaxVal
INTEGER :: Status
END SUBROUTINE ReadShdAttributes
SUBROUTINE ReadImaAttributes(MemberPtr,eMinVal,&
eMaxVal,Status)
!------------------------------------------------------------
IMPLICIT NONE
!INPUT VARIABLES
INTEGER ::MemberPtr ! pointer to index member
!OUTPUT VARIABLES
REAL(kind=4) :: eMinVal,EMaxVal
INTEGER :: Status
END SUBROUTINE ReadImaAttributes
SUBROUTINE ReadScwAttributes(ScwPtr,Status)
!------------------------------------------
IMPLICIT NONE
!INPUT VARIABLES
INTEGER :: ScwPtr ! pointer to scw
INTEGER :: Status
END SUBROUTINE ReadScwAttributes
SUBROUTINE ReadIndexInfo(ShdIdxPtr,EBins,Chans,Status)
!----------------------------------------------------------
IMPLICIT NONE
!INPUT/OUTPUT VARIABLES
INTEGER :: ShdIdxPtr
REAL(kind=4),dimension(:,:),pointer :: EBins
INTEGER ,dimension(:,:),pointer :: Chans
INTEGER :: Status
END SUBROUTINE ReadIndexInfo
SUBROUTINE CreateElem(OutElemFile,StrucName,ElemPtr,Status)
!---------------------------------------------------------
IMPLICIT NONE
!INPUT/OUTPUT VARIABLES
INTEGER :: ElemPtr
CHARACTER(len=*) :: StrucName,OutElemFile
INTEGER :: Status
END SUBROUTINE CreateElem
END INTERFACE
!*************************************
END MODULE MIMOSA_BASE1_MODULE
!*************************************
!*************************************
MODULE MIMOSA_BASE4_MODULE
!*************************************
INTERFACE
SUBROUTINE Read1Mosa(MosaNumber,EBins,Chans,Status)
!---------------------------------------------------
IMPLICIT NONE
!input/output variables
INTEGER :: MosaNumber,Status
REAL(kind=4),dimension(:,:),pointer :: EBins
INTEGER,dimension(:,:),pointer :: Chans
END SUBROUTINE Read1Mosa
SUBROUTINE Read1ReCallMosa(MosaNumber,EBins,Chans,Status)
!----------------------------------------------------------
IMPLICIT NONE
!input/output variables
INTEGER :: MosaNumber,Status
REAL(kind=4),dimension(:,:),pointer :: EBins
INTEGER,dimension(:,:),pointer :: Chans
END SUBROUTINE Read1ReCallMosa
SUBROUTINE Read2Mosa(MosaNumber,RaX,DecX,RaZ,DecZ,posAngle,incr,Status)
!-------------------------------------------------------------------
IMPLICIT NONE
!input/output variables
INTEGER :: MosaNumber,Status
REAL(kind=8), dimension(:), pointer :: RaX,DecX,RaZ,DecZ,posAngle
REAL(kind=8) ::incr
END SUBROUTINE Read2Mosa
END INTERFACE
!*********************************
END MODULE MIMOSA_BASE4_MODULE
!*********************************
!*********************************
MODULE MIMOSA_BASE_MODULE
!*********************************
INTERFACE
SUBROUTINE OgOpen(MosaNumber,MosaImaIdxPtr,MosaSouIdxPtr,&
OutCatPtr,RaX,DecX,RaZ,DecZ,posAngle,Status)
!------------------------------------------------------
IMPLICIT NONE
INTEGER :: MosaNumber
!OUTPUT VARIABLES
! pointer to OG
INTEGER,Intent(out) :: MosaImaIdxPtr
! pointer to mosaicked image list
INTEGER,Intent(out) :: MosaSouIdxPtr
! pointer to mosaicked image source list
INTEGER,Intent(out) :: OutCatPtr
! pointer to output source catalogue
REAL(kind=8), dimension(:), pointer ::RaX,DecX,RaZ,DecZ,posAngle
INTEGER,Intent(out) ::Status
END SUBROUTINE OgOpen
SUBROUTINE WriteImages(type,scw,OutBand,ObjPtr,IdxPtr,CleanImage,&
VarImage,ResidImage,SignifImage,&
Status)
!-------------------------------
IMPLICIT NONE
!INPUT VARIABLES
INTEGER,Intent(in) :: type
! 0 - Scw images
! 1 - Map images
INTEGER,Intent(in) :: scw
!pointing number
INTEGER,Intent(in) :: OutBand
!out energy band number
INTEGER ::ObjPtr,IdxPtr
!pointer to the host object and index of Scw image index
REAL(kind=4),dimension(:,:),pointer ::CleanImage, VarImage,&
ResidImage,SignifImage
!OUTPUT VARIABLES
INTEGER :: Status
END SUBROUTINE WriteImages
SUBROUTINE ReadMosaBandImage(mosa,outBand,iDim,jDim,&
MosaImage,MosaVar, MosaExpo,Status)
!----------------------------------------------------------
IMPLICIT NONE
!INPUT/OUTPUT VARIABLES
INTEGER ,Intent(in) :: mosa,OutBand,iDim,jDim
REAL(kind=4),dimension(:,:),pointer :: MosaImage,MosaVar,MosaExpo
INTEGER :: Status
END SUBROUTINE ReadMosaBandImage
SUBROUTINE WriteSourceList(type,Scw,SouNumber,ObjPtr,IdxPtr,OutBand,&
InpSourceList,Status)
!-------------------------------------
IMPLICIT NONE
!INPUT VARIABLES
INTEGER :: type,Scw,SouNumber,ObjPtr,IdxPtr,OutBand
REAL(kind=4),dimension(:,:),pointer :: InpSourceList
!OUTPUT VARIABLES
INTEGER :: Status
END SUBROUTINE WriteSourceList
SUBROUTINE UpdateIdx(IdxPtr,Status)
!----------------------------------------------------
IMPLICIT NONE
!INPUT VARIABLES
INTEGER :: IdxPtr
!OUTPUT VARIABLES
INTEGER :: Status
END SUBROUTINE UpdateIdx
SUBROUTINE WriteOutCat(OutCatPtr,Status)
!--------------------------------------
IMPLICIT NONE
!INPUT VARIABLES
INTEGER :: OutCatPtr
!OUTPUT VARIABLES
INTEGER :: Status
END SUBROUTINE WriteOutCat
END INTERFACE
!*********************************
END MODULE MIMOSA_BASE_MODULE
!*********************************
!*************************************
MODULE MIMOSA_CAT_MODULE
!*************************************
CONTAINS
!............................................
SUBROUTINE CopyCatalogue(InCatPtr,OutCatPtr,&
Status)
!...........................................
USE ISDC
USE MIMOSA_CONTROL_MODULE
USE MIMOSA_GLOBVAR_MODULE
USE MIMOSA_USE_MODULE
IMPLICIT NONE
!INPUT VARIABLES
INTEGER ,INTENT(IN) :: InCatPtr,OutCatPtr
!OUTPUT VARIABLES
INTEGER::Status
!LOCAL VARIABLES
INTEGER :: iok,sou,k,col,ien,i,isn
INTEGER :: startbin,endbin,numvalues
REAL(kind=4),dimension(:),pointer :: tab
REAL(kind=4)::ene1,ene2
REAL(kind=4),dimension(:,:),pointer :: fluxTab,e1Tab,e2Tab
REAL(kind=8),dimension(:),pointer ::tabd
REAL(kind=4),dimension(:,:),pointer ::tab8f,tab32f
LOGICAL ::jest
CHARACTER(len=20) :: colName
CHARACTER(len=16),dimension(:),pointer :: tab16char
CHARACTER(len=32),dimension(:),pointer :: tab32char
CHARACTER(len=64),dimension(:),pointer :: tab64char
CHARACTER(len=100),dimension(:),pointer :: tab100char
CHARACTER(len=128),dimension(:),pointer :: tab128char
INTEGER(kind=2),dimension(:),pointer :: tabi
CHARACTER(len=20) :: procName
Status = ISDC_OK
procName = 'CopyCatalogue'
if(DebugMode.eq.3)&
call Message(procName,' begin ',ZeroError,Status)
allocate(tab(SourceNumber),&
tab16char(SourceNumber),&
tab32char(SourceNumber),&
tab64char(SourceNumber),&
tab100char(SourceNumber),&
tab128char(SourceNumber),&
tab8f(8,SourceNumber),tab32f(32,SourceNumber),&
tabd(SourceNumber),fluxTab(256,1),e1Tab(256,1),e2Tab(256,1),&
tabi(SourceNumber),stat=iok)
if(iok.ne.0)then
call MESSAGE(procName,'allocation problem',&
AllocError,Status)
return
endif
tab(:)=0.
tab16char(:)=''
tab32char(:)=''
tab64char(:)=''
tab100char(:)=''
tab128char(:)=''
tab8f(:,:)=0.
tab32f(:,:)=0.
tabd(:)=0.
fluxTab(:,:)=0.
e1Tab(:,:)=0.
e2Tab(:,:)=0.
tabi(:)=0
! ADDING TO THE OUTPUT CATALOQUE INPUT SOURCES ROWS
Status = dal_table_add_rows(OutCatPtr,0,SourceNumber,Status)
if(Status.ne.ISDC_OK) then
call MESSAGE(procName,'cannot add rows to output cat.',&
OutCatError,Status)
return
endif
Status = dal_table_get_num_rows(OutCatPtr,k,Status)
if(Status.ne.ISDC_OK) then
IsdcExitStatus=Status
call MESSAGE(procName,'dal_table_get_num_rows problem.',&
IsdcExitStatus,Status)
return
endif
if(k.ne.SourceNumber)then
call MESSAGE(procName,'incorrect row number in output cat.',&
OutCatError,Status)
return
endif
! RIGHT ASCENSION EXTRACTING AND COPYING
call CopyColFloat(InCatPtr,OutCatPtr,&
'RA_OBJ',InCatAlpha,Status)
if(Status.ne.ISDC_OK)then
call WAR_MESSAGE(procName,&
' Cannot copy RA_OBJ column into output cat',0,Status)
CopyCatStat =CopyCatStat +1
endif
!DECLINATION EXTRACTING AND COPYING
call CopyColFloat(InCatPtr,OutCatPtr,&
'DEC_OBJ',InCatDelta,Status)
if(Status.ne.ISDC_OK)then
call WAR_MESSAGE(procName,&
'Cannot copy DEC_OBJ column into output cat',0,Status)
CopyCatStat =CopyCatStat +1
endif
!FLUX EXTRACTING AND COPYING
InCatFlux = 0.0
startBin = 1
endBin = 256
numValues= 256
!loop on input sources
do sou=1,SourceNumber
!E_MIN
call CopyColBinFloat(InCatPtr,OutCatPtr,&
'E_MIN',sou,sou,e1tab,Status)
if(Status.ne.ISDC_OK)then
call WAR_MESSAGE(procName,&
'Cannot copy E_MIN column into output cat',0,Status)
CopyCatStat =CopyCatStat +1
endif
!E_MAX
call CopyColBinFloat(InCatPtr,OutCatPtr,&
'E_MAX',sou,sou,e2tab,Status)
if(Status.ne.ISDC_OK)then
call WAR_MESSAGE(procName,&
'Cannot copy E_MAX column into output cat',0,Status)
CopyCatStat =CopyCatStat +1
endif
!FLUX
call CopyColBinFloat(InCatPtr,OutCatPtr,&
'FLUX',sou,sou,fluxtab,Status)
if(Status.ne.ISDC_OK)then
call WAR_MESSAGE(procName,&
'Cannot copy FLUX column into output cat',0,Status)
CopyCatStat =CopyCatStat +1
endif
do ien = 1,OutEnergyNumber
! calculating of flux in each output energy band
ene1 =OutEnergyBands(ien,1)
ene2 = OutEnergyBands(ien,2)
i=1
jest = .false.
do while((i .le.256).and.(.not. jest))
if(e1tab(i,1).ge.ene1)then
if(e2tab(i,1).le.ene2) then
InCatFlux(sou,ien) = InCatFlux(sou,ien)+fluxTab(i,1)
else
jest = .true.
endif
endif
i=i+1
enddo
enddo
!FLUX_ERR
call CopyColBinFloat(InCatPtr,OutCatPtr,&
'FLUX_ERR',sou,sou,fluxtab,Status)
if(Status.ne.ISDC_OK)then
call WAR_MESSAGE(procName,&
'Cannot copy float bin column into output cat',0,Status)
CopyCatStat =CopyCatStat +1
endif
enddo !sources loop
! COPYING OF DAY_ID
Status = DAL_TABLE_GET_COL(InCatPtr,&
'DAY_ID',1,DAL_DOUBLE,SourceNumber,addrof(tabd(1)),Status)
if(Status.ne.ISDC_OK)then
call WAR_MESSAGE(procName,&
'Cannot get DAY_ID column',0,Status)
CopyCatStat =CopyCatStat +1
endif
Status = DAL_TABLE_PUT_COL(OutCatPtr,&
'DAY_ID',1,DAL_DOUBLE,SourceNumber,addrof(tabd(1)),Status)
if(Status.ne.ISDC_OK)then
call WAR_MESSAGE(procName,&
'Cannot copy DAY_ID into output cat',0,Status)
CopyCatStat =CopyCatStat +1
endif
! COLUMNS OF TYPE FLOAT with several bins inside
!SPA_PARS
call CopyColBinFloat(InCatPtr,OutCatPtr,&
'SPA_PARS',1,SourceNumber,tab8f,Status)
if(Status.ne.ISDC_OK)then
call WAR_MESSAGE(procName,&
'Cannot copy SPA_PARS into output cat',0,Status)
CopyCatStat =CopyCatStat +1
endif
!SPE_PARS
call CopyColBinFloat(InCatPtr,OutCatPtr,&
'SPE_PARS',1,SourceNumber,tab32f,Status)
if(Status.ne.ISDC_OK)then
call WAR_MESSAGE(procName,&
'Cannot copy SPE_PARS into output cat',0,Status)
CopyCatStat =CopyCatStat +1
endif
!VAR_PARS
call CopyColBinFloat(InCatPtr,OutCatPtr,&
'VAR_PARS',1,SourceNumber,tab8f,Status)
if(Status.ne.ISDC_OK)then
call WAR_MESSAGE(procName,&
'Cannot copy VAR_PARS into output cat',0,Status)
CopyCatStat =CopyCatStat +1
endif
! COLUMNS OF TYPE FLOAT COPYING
! ERR_RAD
do col=1,9
select case(col)
case(1)
colName = 'ERR_RAD'
case(2)
colName = 'SPI_FLUX_1'
case(3)
colName = 'SPI_FLUX_2'
case(4)
colName = 'ISGR_FLUX_1'
case(5)
colName = 'ISGR_FLUX_2'
case(6)
colName = 'PICS_FLUX_1'
case(7)
colName = 'PICS_FLUX_2'
case(8)
colName = 'JEMX_FLUX_1'
case(9)
colName = 'JEMX_FLUX_2'
end select
call CopyColFloat(InCatPtr,OutCatPtr,&
colname,tab,Status)
if(Status.ne.ISDC_OK)then
call WAR_MESSAGE(procName,&
'Cannot copy float column into output cat',0,Status)
CopyCatStat =CopyCatStat +1
endif
enddo
! COLUMNS OF TYPE CHAR
! SOURCE_ID
call CopyColChar(InCatPtr,OutCatPtr,&
'SOURCE_ID',tab16char,Status)
if(Status.ne.ISDC_OK)then
call WAR_MESSAGE(procName,&
'Cannot copy SOURCE_ID into output cat',0,Status)
CopyCatStat =CopyCatStat +1
endif
InCatId = tab16char
! NAME
call CopyColChar(InCatPtr,OutCatPtr,&
'NAME',tab100char,Status)
if(Status.ne.ISDC_OK)then
call WAR_MESSAGE(procName,&
'Cannot copy NAME into output cat',0,Status)
CopyCatStat =CopyCatStat +1
endif
InCatName = tab100char
! SPA_MODL
call CopyColChar(InCatPtr,OutCatPtr,&
'SPA_MODL',tab32char,Status)
if(Status.ne.ISDC_OK)then
call WAR_MESSAGE(procName,&
'Cannot copy SPa_MODL into output cat',0,Status)
CopyCatStat =CopyCatStat +1
endif
! SPE_MODL
call CopyColChar(InCatPtr,OutCatPtr,&
'SPE_MODL',tab128char,Status)
if(Status.ne.ISDC_OK)then
call WAR_MESSAGE(procName,&
'Cannot copy SPE_MODL into output cat',0,Status)
CopyCatStat =CopyCatStat +1
endif
! VAR_MODL
call CopyColChar(InCatPtr,OutCatPtr,&
'VAR_MODL',tab128char,Status)
if(Status.ne.ISDC_OK)then
call WAR_MESSAGE(procName,&
'Cannot copy VAR_MODL into output cat',0,Status)
CopyCatStat =CopyCatStat +1
endif
! COMMENTS
call CopyColChar(InCatPtr,OutCatPtr,&
'COMMENTS',tab128char,Status)
if(Status.ne.ISDC_OK)then
call WAR_MESSAGE(procName,&
'Cannot copy COMMENTS into output cat',0,Status)
CopyCatStat =CopyCatStat +1
endif
!COLUMNS of type 1U
do col=1,5
select case(col)
case(1)
colName = 'CLASS'
case(2)
colName = 'SPA_NPAR'
case(3)
colName = 'SPE_NPAR'
case(4)
colName = 'VAR_NPAR'
case(5)
colName = 'SEL_FLAG'
end select
call CopyCol1U(InCatPtr,OutCatPtr,&
colname,tabi,Status)
if(Status.ne.ISDC_OK)then
call WAR_MESSAGE(procName,&
'Cannot copy 1U column into output cat',0,Status)
CopyCatStat =CopyCatStat +1
endif
enddo
! 27.01.05 SCREW 1609
colName = 'ISGRI_FLAG'
call GetCol1U(InCatPtr,OutCatPtr,&
colname,tabi,Status)
if(Status.ne.ISDC_OK)then
call MESSAGE(procName,&
'above error is not FATAL : Column ISGRI_FLAG not found in the input catalog ',0,Status)
call MESSAGE(procName,&
' no fixing position of individual sources will be done',0,Status)
CopyCatStat =CopyCatStat +1
else
call PutCol1U(InCatPtr,OutCatPtr,&
colname,tabi,Status)
if(Status.ne.ISDC_OK)then
call MESSAGE(procName,&
'Column ISGRI_FLAG cannot be copied into output catalog ',0,Status)
CopyCatStat =CopyCatStat +1
endif
! creating InCatFixedList if not defined in hidden file
! otherwise ignore
if(.not.associated(InCatFixedList))then
isn = 0.
do i=1,SourceNumber
if(tabi(i)==2)then
isn = isn+1
endif
enddo
if(isn >0)then
allocate(InCatFixedList(isn),stat=iok)
if(iok .ne.0)then
call war_message(procname,&
' cannot allocate InCatFixedList, sources positions will not be fixed',&
0,status)
else
isn = 0.
do i=1,SourceNumber
if(tabi(i)==2)then
isn = isn+1
InCatFixedList(isn) = i
endif
enddo
endif!InCatFixedList allocated
endif ! some sources positions will be fixed
endif
endif
deallocate(tabi)
deallocate(tab)
deallocate(tabd)
deallocate(tab8f)
deallocate(tab32f)
deallocate(tab16char)
deallocate(tab32char)
deallocate(tab64char)
deallocate(tab100char)
deallocate(tab128char)
deallocate(e1tab)
deallocate(e2tab)
deallocate(fluxtab)
if(DebugMode.eq.3)&
call Message(procName,'end ',ZeroError,Status)
!............................
END SUBROUTINE CopyCatalogue
!............................
!...........................................
SUBROUTINE CopyColBinFloat(InCatPtr,OutCatPtr,&
ColName,StartBin,EndBin,Tab,Status)
!...........................................
USE ISDC
USE MIMOSA_CONTROL_MODULE
USE MIMOSA_GLOBVAR_MODULE
USE MIMOSA_USE_MODULE
IMPLICIT NONE
!INPUT VARIABLES
INTEGER ,INTENT(IN) :: InCatPtr,OutCatPtr
INTEGER ,INTENT(IN) :: StartBin,EndBin
CHARACTER(len=* ) :: ColName
REAL(kind=4),dimension(:,:),pointer:: Tab
!OUTPUT VARIABLES
INTEGER :: Status
!LOCAL VARIABLES
INTEGER::NumValues
CHARACTER(len=20) :: procName
Status = ISDC_OK
procName = 'CopyColBinFloat'
if(DebugMode.eq.3)&
call Message(procName,' begin',ZeroError,Status)
Status = DAL_TABLE_GET_COL_BINS(inCatPtr,&
ColName,1,DAL_FLOAT,StartBin,EndBin,NumValues,&
addrof(Tab(1,1)),Status)
if(Status.ne.ISDC_OK)then
if(WorkMode==1)then
call MESSAGE(procName,&
'Cannot get'//colName//' from input cat.',&