ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/JSOC/proj/example/apps/f_ingest_gong_mrv.f
Revision: 1.1
Committed: Tue Oct 16 22:48:16 2007 UTC (15 years, 11 months ago) by arta
Branch: MAIN
CVS Tags: Ver_6-0, Ver_6-1, Ver_6-2, Ver_6-3, Ver_6-4, Ver_5-6, Ver_LATEST, NetDRMS_Ver_8-12, NewTree01_cp05_JSOC, Ver_9-41, Ver_DRMSLATEST, NetDRMS_Ver_2-0b, NetDRMS_Ver_2-0a, Ver_9-5, Ver_9-4, Ver_9-3, Ver_9-2, Ver_9-1, Ver_9-0, NetDRMS_Ver_1-1, NetDRMS_Ver_1-0, NetDRMS_Ver_2-2, NetDRMS_Ver_2-3, NetDRMS_Ver_2-0, NetDRMS_Ver_2-1, NetDRMS_Ver_2-6, NetDRMS_Ver_2-7, NetDRMS_Ver_2-4, NetDRMS_Ver_2-5, NetDRMS_Ver_LATEST, NetDRMS_Ver_8-8, NetDRMS_Ver_8-10, NetDRMS_Ver_8-11, NetDRMS_Ver_8-4, NetDRMS_Ver_8-5, NetDRMS_Ver_8-6, NetDRMS_Ver_8-7, NetDRMS_Ver_8-0, NetDRMS_Ver_8-1, NetDRMS_Ver_8-2, NetDRMS_Ver_8-3, NewTree01_cp08_JSOC, Ver_4-6, Ver_4-7, Ver_4-4, Ver_4-5, Ver_4-2, Ver_4-3, Ver_4-0, Ver_4-1, Ver_8-8, NetDRMS_Ver_2-0b1, Ver_8-2, Ver_8-3, Ver_8-0, Ver_8-1, Ver_8-6, Ver_8-7, Ver_8-4, Ver_8-5, Ver_5-3, Ver_5-2, Ver_5-1, Ver_5-0, Ver_5-7, Ver_7-0, Ver_5-5, Ver_5-9, Ver_5-8, Ver_8-10, Ver_8-11, Ver_8-12, NetDRMS_Ver_6-4, NetDRMS_Ver_0-7, NetDRMS_Ver_6-2, NetDRMS_Ver_6-3, NetDRMS_Ver_6-0, NetDRMS_Ver_6-1, NetDRMS_Ver_0-8, NetDRMS_Ver_0-9, Ver_5-14, Ver_5-13, Ver_5-12, Ver_5-11, Ver_5-10, NetDRMS_Ver_2-0a2, NetDRMS_Ver_2-0a1, NewTree01_cp07_JSOC, NetDRMS_Ver_9-9, NetDRMS_Ver_9-41, NetDRMS_Ver_9-1, NetDRMS_Ver_9-0, NetDRMS_Ver_9-3, NetDRMS_Ver_9-2, NetDRMS_Ver_9-5, NetDRMS_Ver_9-4, NewTree01_cp06_JSOC, Ver_7-1, NewTree01_cp09_JSOC, NetDRMS_Ver_7-1, NetDRMS_Ver_7-0, HEAD
Log Message:
Move JSOC/src/base to JSOC/base and JSOC/src/proj to JSOC/proj.  86 JSOC/src.

File Contents

# Content
1 C *************************************************************************
2
3 C The following string literals have a 'C' suffix.
4 C This causes the strings to be null-terminated.
5
6 BLOCK DATA NAMENOTNEEDED
7
8 C Module name
9 CHARACTER*127 mname
10 COMMON / mname / mname
11 DATA mname / 'DRMS_FORT_eg1' /
12
13 CC List of module arguments. These are provided as a long
14 CC string, which is then parsed by jsoc_main.c Each argument
15 CC is contained within 928 bytes, which accounts for the
16 CC following fields:
17 CC CHARACTER*32 type
18 CC CHARACTER*128 name
19 CC CHARACTER*128 value
20 CC CHARACTER*512 description
21 CC CHARACTER*128 range
22
23 CHARACTER*927 margs(128)
24 COMMON / margs / margs
25 DATA margs(1) / 'string,filename,/home/igor/data/examples/mrvzi
26 2051025t2111.fits, FITS File Name,na'/
27 DATA margs(2) / 'end' /
28 END BLOCK DATA NAMENOTNEEDED
29
30
31 INTEGER FUNCTION DOIT()
32 USE FDRMS
33
34 INTEGER cpHandl
35 character*256 recordsetHdl, recordHdl, envHdl, arrayHdl, segHdl
36 character*256 seriesname, segmentname, filename
37 character*256 path
38 CHARACTER(len=7000), ALLOCATABLE :: header(:)
39 C CHARACTER*7000 header
40
41 integer status
42 integer nOfRec, lifetime, rec_size, headlen, readraw, autoscale
43
44 seriesname = 'nso_igor.gong_mrv_ex1'
45 segmentname= 'short_image'
46 nOfRec = 1
47 lifetime = DRMS_PERMANENT
48
49 CC get parameters handle
50 call cpgethandle(cpHandl)
51
52 print 81, 'cpHandl', cpHandl
53 CC get filename argument value
54 call cpgetstr(cpHandl,'filename',filename,status)
55 IF (status.EQ.0) THEN
56 PRINT *, 'filename::', filename
57 END IF
58
59 CC Get the DRMS environment handle
60 envHdl = f_drms_env_handle()
61 print 80, 'drms_env', envHdl
62
63 CC Create a set of records for the given seriesname
64 recordsetHdl = f_drms_create_records(envHdl, nOfRec,
65 2 seriesname, lifetime, status)
66
67 CC Check if handle is null
68 if (f_isnull(recordsetHdl)) stop "Failed reading fits file ...
69 2exiting ..."
70 print 80, 'recordsetHdl', recordsetHdl
71
72 CC Get the first record from the record set
73 recordHdl = f_get_rs_record(recordsetHdl,0);
74 print 80, 'recordHdl', recordHdl
75
76 CC Check the path where SUMS will put your data
77 call f_drms_record_directory(recordHdl,path,0)
78 print 100, path
79
80 CC Check the size of your record
81 rec_size = f_drms_record_size(recordHdl)
82 print 110, rec_size
83
84 write(*,'(1x,A)') 'Try opening the fits file: '
85
86 readraw = 1
87 CC *************
88 CC NOTE:
89 CC when using f_drms_readfits there are two posibilities:
90 CC 1.- f_drms_readfits will allocate the header in C so
91 CC do NOT double allocate in fortran. The "header" variable
92 CC has to be of type allocatable in fortran though.
93 CC 2.- f_drms_readfits2 will not allocate in C. You'll need
94 CC to pass a local variable of enough size
95 CC *************
96 CC Go and read a fits file using the drms_readfits function
97 C arrayHdl = f_drms_readfits2(filename, readraw, headlen,
98 C 2 header, status)
99 CC Allocatable version
100 C
101 C XXX For Art to complete
102 C drms_readfits() is not a an external API. Use drms_segment_read().
103 C
104 C -- Art Amezcua 8/14/2007
105 C
106 C arrayHdl = f_drms_readfits(filename, readraw, headlen,
107 C 2 header, status)
108
109
110 CC Check for nulls
111 if (f_isnull(arrayHdl)) stop "Failed reading fits file ...
112 2exiting ..."
113
114 print 80, 'arrayHdl', arrayHdl
115 print 95, status
116 print 95, headlen
117 C print 90, header(0:80)
118 CC now that we loaded the fits file and it's contents is in
119 CC a valid arrayHdl lets ingest it in DRMS.
120
121 CC lets get the segment first from our record
122 segHdl = f_drms_segment_lookup(recordHdl, segmentname);
123
124 print 80, 'segHdl', segHdl
125
126 CC Don't autoscale
127 autoscale = 0;
128
129 CC write array to segment
130 status = f_drms_segment_write(segHdl, arrayHdl, autoscale);
131
132 CC We don't need the arrayHdl anymore so lets free it's memory
133 call f_drms_free_array(arrayHdl);
134
135 CC Set the series keywords using a C interface
136 call f_gong2drms_set_keywords(recordHdl, headlen, header);
137
138 CC insert records
139 status = f_drms_insert_records(recordsetHdl);
140
141 print 120, status
142 CC free records. If records are not freed the drms_close will attempt
143 CC a drms_insert_records after return from the DOIT subroutine if the
144 CC records structure is not empty.
145 CC This will result in a DB error trying to insert a duplicate key
146 CC In other words use drms_insert_records and drms_free_records or none
147 call f_drms_free_records(recordsetHdl);
148
149 print*, "About to leave the module ..."
150 DOIT = 0
151 RETURN
152 81 format ('handle : type=', a30, ';value=' i8)
153 80 format ('handle : type=', a30, ';value=' a50)
154 90 format('header ::', a80)
155 95 format('status ::', i8)
156 100 format('drms directory path :', a50)
157 110 format('record size:', i8)
158 120 format("insert status [",i8,"]")
159
160 END FUNCTION DOIT