| 1 |
C This is a big and complicated program that tests most of |
| 2 |
C the fitsio routines. This code does not represent |
| 3 |
C the most efficient method of reading or writing FITS files |
| 4 |
C because this code is primarily designed to stress the fitsio |
| 5 |
C library routines. |
| 6 |
|
| 7 |
character asciisum*17 |
| 8 |
character*3 cval |
| 9 |
character*1 xinarray(21), binarray(21), boutarray(21), bnul |
| 10 |
character colname*70, tdisp*40, nulstr*40 |
| 11 |
character oskey*15 |
| 12 |
character iskey*21 |
| 13 |
character lstr*200 |
| 14 |
character comm*73 |
| 15 |
character*30 inskey(21) |
| 16 |
character*30 onskey(3) |
| 17 |
character filename*40, card*78, card2*78 |
| 18 |
character keyword*8 |
| 19 |
character value*68, comment*72 |
| 20 |
character uchars*78 |
| 21 |
character*15 ttype(10), tform(10), tunit(10) |
| 22 |
character*15 tblname |
| 23 |
character*15 binname |
| 24 |
character errmsg*75 |
| 25 |
character*8 inclist(2),exclist(2) |
| 26 |
character*8 xctype,yctype,ctype |
| 27 |
character*18 kunit |
| 28 |
|
| 29 |
logical simple,extend,larray(42), larray2(42) |
| 30 |
logical olkey, ilkey, onlkey(3), inlkey(3), anynull |
| 31 |
|
| 32 |
integer*2 imgarray(19,30), imgarray2(10,20) |
| 33 |
integer*2 iinarray(21), ioutarray(21), inul |
| 34 |
|
| 35 |
integer naxes(3), pcount, gcount, npixels, nrows, rowlen |
| 36 |
integer existkeys, morekeys, keynum |
| 37 |
integer datastatus, hdustatus |
| 38 |
integer status, bitpix, naxis, block |
| 39 |
integer ii, jj, jjj, hdutype, hdunum, tfields |
| 40 |
integer nkeys, nfound, colnum, typecode, signval,nmsg |
| 41 |
integer repeat, offset, width, jnulval |
| 42 |
integer kinarray(21), koutarray(21), knul |
| 43 |
integer jinarray(21), joutarray(21), jnul |
| 44 |
integer ojkey, ijkey, otint |
| 45 |
integer onjkey(3), injkey(3) |
| 46 |
integer tbcol(5) |
| 47 |
integer iunit, tmpunit |
| 48 |
integer fpixels(2), lpixels(2), inc(2) |
| 49 |
|
| 50 |
real estatus, vers |
| 51 |
real einarray(21), eoutarray(21), enul, cinarray(42) |
| 52 |
real ofkey, oekey, iekey, onfkey(3),onekey(3), inekey(3) |
| 53 |
|
| 54 |
double precision dinarray(21),doutarray(21),dnul, minarray(42) |
| 55 |
double precision scale, zero |
| 56 |
double precision ogkey, odkey, idkey, otfrac, ongkey(3) |
| 57 |
double precision ondkey(3), indkey(3) |
| 58 |
double precision checksum, datsum |
| 59 |
double precision xrval,yrval,xrpix,yrpix,xinc,yinc,rot |
| 60 |
double precision xpos,ypos,xpix,ypix |
| 61 |
|
| 62 |
tblname = 'Test-ASCII' |
| 63 |
binname = 'Test-BINTABLE' |
| 64 |
onskey(1) = 'first string' |
| 65 |
onskey(2) = 'second string' |
| 66 |
onskey(3) = ' ' |
| 67 |
oskey = 'value_string' |
| 68 |
inclist(1)='key*' |
| 69 |
inclist(2)='newikys' |
| 70 |
exclist(1)='key_pr*' |
| 71 |
exclist(2)='key_pkls' |
| 72 |
xctype='RA---TAN' |
| 73 |
yctype='DEC--TAN' |
| 74 |
|
| 75 |
olkey = .true. |
| 76 |
ojkey = 11 |
| 77 |
otint = 12345678 |
| 78 |
ofkey = 12.121212 |
| 79 |
oekey = 13.131313 |
| 80 |
ogkey = 14.1414141414141414D+00 |
| 81 |
odkey = 15.1515151515151515D+00 |
| 82 |
otfrac = .1234567890123456D+00 |
| 83 |
onlkey(1) = .true. |
| 84 |
onlkey(2) = .false. |
| 85 |
onlkey(3) = .true. |
| 86 |
onjkey(1) = 11 |
| 87 |
onjkey(2) = 12 |
| 88 |
onjkey(3) = 13 |
| 89 |
onfkey(1) = 12.121212 |
| 90 |
onfkey(2) = 13.131313 |
| 91 |
onfkey(3) = 14.141414 |
| 92 |
onekey(1) = 13.131313 |
| 93 |
onekey(2) = 14.141414 |
| 94 |
onekey(3) = 15.151515 |
| 95 |
ongkey(1) = 14.1414141414141414D+00 |
| 96 |
ongkey(2) = 15.1515151515151515D+00 |
| 97 |
ongkey(3) = 16.1616161616161616D+00 |
| 98 |
ondkey(1) = 15.1515151515151515D+00 |
| 99 |
ondkey(2) = 16.1616161616161616D+00 |
| 100 |
ondkey(3) = 17.1717171717171717D+00 |
| 101 |
|
| 102 |
tbcol(1) = 1 |
| 103 |
tbcol(2) = 17 |
| 104 |
tbcol(3) = 28 |
| 105 |
tbcol(4) = 43 |
| 106 |
tbcol(5) = 56 |
| 107 |
status = 0 |
| 108 |
|
| 109 |
call ftvers(vers) |
| 110 |
write(*,'(1x,A)') 'FITSIO TESTPROG' |
| 111 |
write(*, '(1x,A)')' ' |
| 112 |
|
| 113 |
iunit = 15 |
| 114 |
tmpunit = 16 |
| 115 |
|
| 116 |
write(*,'(1x,A)') 'Try opening then closing a nonexistent file: ' |
| 117 |
call ftopen(iunit, 'tq123x.kjl', 1, block, status) |
| 118 |
write(*,'(1x,A,2i4)')' ftopen iunit, status (expect an error) =' |
| 119 |
& ,iunit, status |
| 120 |
call ftclos(iunit, status) |
| 121 |
write(*,'(1x,A,i4)')' ftclos status = ', status |
| 122 |
write(*,'(1x,A)')' ' |
| 123 |
|
| 124 |
call ftcmsg |
| 125 |
status = 0 |
| 126 |
|
| 127 |
filename = 'testf77.fit' |
| 128 |
|
| 129 |
C delete previous version of the file, if it exists |
| 130 |
|
| 131 |
call ftopen(iunit, filename, 1, block, status) |
| 132 |
if (status .eq. 0)then |
| 133 |
call ftdelt(iunit, status) |
| 134 |
else |
| 135 |
C clear the error message stack |
| 136 |
call ftcmsg |
| 137 |
end if |
| 138 |
|
| 139 |
status = 0 |
| 140 |
|
| 141 |
C |
| 142 |
C ##################### |
| 143 |
C # create FITS file # |
| 144 |
C ##################### |
| 145 |
|
| 146 |
|
| 147 |
call ftinit(iunit, filename, 1, status) |
| 148 |
write(*,'(1x,A,i4)')'ftinit create new file status = ', status |
| 149 |
write(*,'(1x,A)')' ' |
| 150 |
|
| 151 |
if (status .ne. 0)go to 999 |
| 152 |
|
| 153 |
simple = .true. |
| 154 |
bitpix = 32 |
| 155 |
naxis = 2 |
| 156 |
naxes(1) = 10 |
| 157 |
naxes(2) = 2 |
| 158 |
npixels = 20 |
| 159 |
pcount = 0 |
| 160 |
gcount = 1 |
| 161 |
extend = .true. |
| 162 |
|
| 163 |
C ############################ |
| 164 |
C # write single keywords # |
| 165 |
C ############################ |
| 166 |
|
| 167 |
call ftphpr(iunit,simple, bitpix, naxis, naxes, |
| 168 |
& 0,1,extend,status) |
| 169 |
|
| 170 |
call ftprec(iunit, |
| 171 |
&'key_prec= ''This keyword was written by fxprec'' / '// |
| 172 |
& 'comment goes here', status) |
| 173 |
|
| 174 |
write(*,'(1x,A)') 'test writing of long string keywords: ' |
| 175 |
card = '1234567890123456789012345678901234567890'// |
| 176 |
& '12345678901234567890123456789012345' |
| 177 |
call ftpkys(iunit, 'card1', card, ' ', status) |
| 178 |
call ftgkey(iunit, 'card1', card2, comment, status) |
| 179 |
|
| 180 |
write(*,'(1x,A)') card |
| 181 |
write(*,'(1x,A)') card2 |
| 182 |
|
| 183 |
card = '1234567890123456789012345678901234567890'// |
| 184 |
& '123456789012345678901234''6789012345' |
| 185 |
call ftpkys(iunit, 'card2', card, ' ', status) |
| 186 |
call ftgkey(iunit, 'card2', card2, comment, status) |
| 187 |
write(*,'(1x,A)') card |
| 188 |
write(*,'(1x,A)') card2 |
| 189 |
|
| 190 |
card = '1234567890123456789012345678901234567890'// |
| 191 |
& '123456789012345678901234''''789012345' |
| 192 |
call ftpkys(iunit, 'card3', card, ' ', status) |
| 193 |
call ftgkey(iunit, 'card3', card2, comment, status) |
| 194 |
write(*,'(1x,A)') card |
| 195 |
write(*,'(1x,A)') card2 |
| 196 |
|
| 197 |
card = '1234567890123456789012345678901234567890'// |
| 198 |
& '123456789012345678901234567''9012345' |
| 199 |
call ftpkys(iunit, 'card4', card, ' ', status) |
| 200 |
call ftgkey(iunit, 'card4', card2, comment, status) |
| 201 |
write(*,'(1x,A)') card |
| 202 |
write(*,'(1x,A)') card2 |
| 203 |
|
| 204 |
call ftpkys(iunit, 'key_pkys', oskey, 'fxpkys comment', status) |
| 205 |
call ftpkyl(iunit, 'key_pkyl', olkey, 'fxpkyl comment', status) |
| 206 |
call ftpkyj(iunit, 'key_pkyj', ojkey, 'fxpkyj comment', status) |
| 207 |
call ftpkyf(iunit,'key_pkyf',ofkey,5, 'fxpkyf comment', status) |
| 208 |
call ftpkye(iunit,'key_pkye',oekey,6, 'fxpkye comment', status) |
| 209 |
call ftpkyg(iunit,'key_pkyg',ogkey,14, 'fxpkyg comment',status) |
| 210 |
call ftpkyd(iunit,'key_pkyd',odkey,14, 'fxpkyd comment',status) |
| 211 |
|
| 212 |
lstr='This is a very long string '// |
| 213 |
& 'value that is continued over more than one keyword.' |
| 214 |
|
| 215 |
call ftpkls(iunit,'key_pkls',lstr,'fxpkls comment',status) |
| 216 |
|
| 217 |
call ftplsw(iunit, status) |
| 218 |
call ftpkyt(iunit,'key_pkyt',otint,otfrac,'fxpkyt comment', |
| 219 |
& status) |
| 220 |
call ftpcom(iunit, 'This keyword was written by fxpcom.', |
| 221 |
& status) |
| 222 |
call ftphis(iunit, |
| 223 |
&' This keyword written by fxphis (w/ 2 leading spaces).', |
| 224 |
& status) |
| 225 |
|
| 226 |
call ftpdat(iunit, status) |
| 227 |
|
| 228 |
if (status .gt. 0)go to 999 |
| 229 |
|
| 230 |
C |
| 231 |
C ############################### |
| 232 |
C # write arrays of keywords # |
| 233 |
C ############################### |
| 234 |
|
| 235 |
nkeys = 3 |
| 236 |
|
| 237 |
comm = 'fxpkns comment&' |
| 238 |
call ftpkns(iunit, 'ky_pkns', 1, nkeys, onskey, comm, status) |
| 239 |
comm = 'fxpknl comment&' |
| 240 |
call ftpknl(iunit, 'ky_pknl', 1, nkeys, onlkey, comm, status) |
| 241 |
|
| 242 |
comm = 'fxpknj comment&' |
| 243 |
call ftpknj(iunit, 'ky_pknj', 1, nkeys, onjkey, comm, status) |
| 244 |
|
| 245 |
comm = 'fxpknf comment&' |
| 246 |
call ftpknf(iunit, 'ky_pknf', 1, nkeys, onfkey,5,comm,status) |
| 247 |
|
| 248 |
comm = 'fxpkne comment&' |
| 249 |
call ftpkne(iunit, 'ky_pkne', 1, nkeys, onekey,6,comm,status) |
| 250 |
|
| 251 |
comm = 'fxpkng comment&' |
| 252 |
call ftpkng(iunit, 'ky_pkng', 1, nkeys, ongkey,13,comm,status) |
| 253 |
|
| 254 |
comm = 'fxpknd comment&' |
| 255 |
call ftpknd(iunit, 'ky_pknd', 1, nkeys, ondkey,14,comm,status) |
| 256 |
|
| 257 |
if (status .gt. 0)go to 999 |
| 258 |
|
| 259 |
C ############################ |
| 260 |
C # write generic keywords # |
| 261 |
C ############################ |
| 262 |
|
| 263 |
|
| 264 |
oskey = '1' |
| 265 |
call ftpkys(iunit, 'tstring', oskey, 'tstring comment',status) |
| 266 |
|
| 267 |
olkey = .true. |
| 268 |
call ftpkyl(iunit, 'tlogical', olkey, 'tlogical comment', |
| 269 |
& status) |
| 270 |
|
| 271 |
ojkey = 11 |
| 272 |
call ftpkyj(iunit, 'tbyte', ojkey, 'tbyte comment', status) |
| 273 |
|
| 274 |
ojkey = 21 |
| 275 |
call ftpkyj(iunit, 'tshort', ojkey, 'tshort comment', status) |
| 276 |
|
| 277 |
ojkey = 31 |
| 278 |
call ftpkyj(iunit, 'tint', ojkey, 'tint comment', status) |
| 279 |
|
| 280 |
ojkey = 41 |
| 281 |
call ftpkyj(iunit, 'tlong', ojkey, 'tlong comment', status) |
| 282 |
|
| 283 |
oekey = 42 |
| 284 |
call ftpkye(iunit, 'tfloat', oekey, 6,'tfloat comment', status) |
| 285 |
|
| 286 |
odkey = 82.D+00 |
| 287 |
call ftpkyd(iunit, 'tdouble', odkey, 14, 'tdouble comment', |
| 288 |
& status) |
| 289 |
|
| 290 |
if (status .gt. 0)go to 999 |
| 291 |
write(*,'(1x,A)') 'Wrote all Keywords successfully ' |
| 292 |
|
| 293 |
|
| 294 |
C ############################ |
| 295 |
C # write data # |
| 296 |
C ############################ |
| 297 |
|
| 298 |
|
| 299 |
C define the null value (must do this before writing any data) |
| 300 |
call ftpkyj(iunit,'BLANK',-99, |
| 301 |
& 'value to use for undefined pixels', status) |
| 302 |
|
| 303 |
C initialize arrays of values to write to primary array |
| 304 |
do ii = 1, npixels |
| 305 |
boutarray(ii) = char(ii) |
| 306 |
ioutarray(ii) = ii |
| 307 |
joutarray(ii) = ii |
| 308 |
eoutarray(ii) = ii |
| 309 |
doutarray(ii) = ii |
| 310 |
end do |
| 311 |
|
| 312 |
C write a few pixels with each datatype |
| 313 |
C set the last value in each group of 4 as undefined |
| 314 |
call ftpprb(iunit, 1, 1, 2, boutarray(1), status) |
| 315 |
call ftppri(iunit, 1, 5, 2, ioutarray(5), status) |
| 316 |
call ftpprj(iunit, 1, 9, 2, joutarray(9), status) |
| 317 |
call ftppre(iunit, 1, 13, 2, eoutarray(13), status) |
| 318 |
call ftpprd(iunit, 1, 17, 2, doutarray(17), status) |
| 319 |
bnul = char(4) |
| 320 |
call ftppnb(iunit, 1, 3, 2, boutarray(3), bnul, status) |
| 321 |
inul = 8 |
| 322 |
call ftppni(iunit, 1, 7, 2, ioutarray(7), inul, status) |
| 323 |
call ftppnj(iunit, 1, 11, 2, joutarray(11), 12, status) |
| 324 |
call ftppne(iunit, 1, 15, 2, eoutarray(15), 16., status) |
| 325 |
dnul = 20. |
| 326 |
call ftppnd(iunit, 1, 19, 2, doutarray(19), dnul, status) |
| 327 |
call ftppru(iunit, 1, 1, 1, status) |
| 328 |
|
| 329 |
if (status .gt. 0)then |
| 330 |
write(*,'(1x,A,I4)')'ftppnx status = ', status |
| 331 |
goto 999 |
| 332 |
end if |
| 333 |
|
| 334 |
call ftflus(iunit, status) |
| 335 |
C flush all data to the disk file |
| 336 |
write(*,'(1x,A,I4)')'ftflus status = ', status |
| 337 |
write(*,'(1x,A)')' ' |
| 338 |
|
| 339 |
call ftghdn(iunit, hdunum) |
| 340 |
write(*,'(1x,A,I4)')'HDU number = ', hdunum |
| 341 |
|
| 342 |
C ############################ |
| 343 |
C # read data # |
| 344 |
C ############################ |
| 345 |
|
| 346 |
|
| 347 |
C read back the data, setting null values = 99 |
| 348 |
write(*,'(1x,A)') |
| 349 |
& 'Values read back from primary array (99 = null pixel)' |
| 350 |
write(*,'(1x,A)') |
| 351 |
& 'The 1st, and every 4th pixel should be undefined: ' |
| 352 |
|
| 353 |
anynull = .false. |
| 354 |
bnul = char(99) |
| 355 |
call ftgpvb(iunit, 1, 1, 10, bnul, binarray, anynull, status) |
| 356 |
call ftgpvb(iunit, 1, 11, 10, bnul, binarray(11),anynull,status) |
| 357 |
|
| 358 |
do ii = 1,npixels |
| 359 |
iinarray(ii) = ichar(binarray(ii)) |
| 360 |
end do |
| 361 |
|
| 362 |
write(*,1101) (iinarray(ii), ii = 1, npixels), anynull, |
| 363 |
& ' (ftgpvb) ' |
| 364 |
1101 format(1x,20i3,l3,a) |
| 365 |
|
| 366 |
inul = 99 |
| 367 |
call ftgpvi(iunit, 1, 1, npixels, inul, iinarray,anynull,status) |
| 368 |
|
| 369 |
write(*,1101) (iinarray(ii), ii = 1, npixels), anynull, |
| 370 |
& ' (ftgpvi) ' |
| 371 |
|
| 372 |
call ftgpvj(iunit, 1, 1, npixels, 99, jinarray,anynull,status) |
| 373 |
|
| 374 |
write(*,1101) (jinarray(ii), ii = 1, npixels), anynull, |
| 375 |
& ' (ftgpvj) ' |
| 376 |
|
| 377 |
call ftgpve(iunit, 1, 1, npixels, 99., einarray,anynull,status) |
| 378 |
|
| 379 |
write(*,1102) (einarray(ii), ii = 1, npixels), anynull, |
| 380 |
& ' (ftgpve) ' |
| 381 |
|
| 382 |
1102 format(2x,20f3.0,l2,a) |
| 383 |
|
| 384 |
dnul = 99. |
| 385 |
call ftgpvd(iunit, 1, 1, 10, dnul, dinarray, anynull, status) |
| 386 |
call ftgpvd(iunit, 1, 11, 10, dnul,dinarray(11),anynull,status) |
| 387 |
|
| 388 |
write(*,1102) (dinarray(ii), ii = 1, npixels), anynull, |
| 389 |
& ' (ftgpvd) ' |
| 390 |
|
| 391 |
if (status .gt. 0)then |
| 392 |
write(*,'(1x,A,I4)')'ERROR: ftgpv_ status = ', status |
| 393 |
goto 999 |
| 394 |
end if |
| 395 |
|
| 396 |
if (.not. anynull)then |
| 397 |
write(*,'(1x,A)') 'ERROR: ftgpv_ did not detect null values ' |
| 398 |
go to 999 |
| 399 |
end if |
| 400 |
|
| 401 |
C reset the output null value to the expected input value |
| 402 |
|
| 403 |
do ii = 4, npixels, 4 |
| 404 |
boutarray(ii) = char(99) |
| 405 |
ioutarray(ii) = 99 |
| 406 |
joutarray(ii) = 99 |
| 407 |
eoutarray(ii) = 99. |
| 408 |
doutarray(ii) = 99. |
| 409 |
end do |
| 410 |
|
| 411 |
ii = 1 |
| 412 |
boutarray(ii) = char(99) |
| 413 |
ioutarray(ii) = 99 |
| 414 |
joutarray(ii) = 99 |
| 415 |
eoutarray(ii) = 99. |
| 416 |
doutarray(ii) = 99. |
| 417 |
|
| 418 |
|
| 419 |
C compare the output with the input flag any differences |
| 420 |
do ii = 1, npixels |
| 421 |
|
| 422 |
if (boutarray(ii) .ne. binarray(ii))then |
| 423 |
write(*,'(1x,A,2A2)') 'bout != bin ', boutarray(ii), |
| 424 |
& binarray(ii) |
| 425 |
end if |
| 426 |
|
| 427 |
if (ioutarray(ii) .ne. iinarray(ii))then |
| 428 |
write(*,'(1x,A,2I8)') 'bout != bin ', ioutarray(ii), |
| 429 |
& iinarray(ii) |
| 430 |
end if |
| 431 |
|
| 432 |
if (joutarray(ii) .ne. jinarray(ii))then |
| 433 |
write(*,'(1x,A,2I12)') 'bout != bin ', joutarray(ii), |
| 434 |
& jinarray(ii) |
| 435 |
end if |
| 436 |
|
| 437 |
if (eoutarray(ii) .ne. einarray(ii))then |
| 438 |
write(*,'(1x,A,2E15.3)') 'bout != bin ', eoutarray(ii), |
| 439 |
& einarray(ii) |
| 440 |
end if |
| 441 |
|
| 442 |
if (doutarray(ii) .ne. dinarray(ii))then |
| 443 |
write(*,'(1x,A,2D20.6)') 'bout != bin ', doutarray(ii), |
| 444 |
& dinarray(ii) |
| 445 |
end if |
| 446 |
end do |
| 447 |
|
| 448 |
do ii = 1, npixels |
| 449 |
binarray(ii) = char(0) |
| 450 |
iinarray(ii) = 0 |
| 451 |
jinarray(ii) = 0 |
| 452 |
einarray(ii) = 0. |
| 453 |
dinarray(ii) = 0. |
| 454 |
end do |
| 455 |
|
| 456 |
anynull = .false. |
| 457 |
call ftgpfb(iunit, 1, 1, 10, binarray, larray, anynull,status) |
| 458 |
call ftgpfb(iunit, 1, 11, 10, binarray(11), larray(11), |
| 459 |
& anynull, status) |
| 460 |
|
| 461 |
do ii = 1, npixels |
| 462 |
if (larray(ii))binarray(ii) = char(0) |
| 463 |
end do |
| 464 |
|
| 465 |
do ii = 1,npixels |
| 466 |
iinarray(ii) = ichar(binarray(ii)) |
| 467 |
end do |
| 468 |
|
| 469 |
write(*,1101)(iinarray(ii),ii = 1,npixels),anynull,' (ftgpfb)' |
| 470 |
|
| 471 |
call ftgpfi(iunit, 1, 1, npixels, iinarray, larray, anynull, |
| 472 |
& status) |
| 473 |
|
| 474 |
do ii = 1, npixels |
| 475 |
if (larray(ii))iinarray(ii) = 0 |
| 476 |
end do |
| 477 |
|
| 478 |
write(*,1101)(iinarray(ii),ii = 1,npixels),anynull,' (ftgpfi)' |
| 479 |
|
| 480 |
call ftgpfj(iunit, 1, 1, npixels, jinarray, larray, anynull, |
| 481 |
& status) |
| 482 |
|
| 483 |
do ii = 1, npixels |
| 484 |
if (larray(ii))jinarray(ii) = 0 |
| 485 |
end do |
| 486 |
|
| 487 |
write(*,1101)(jinarray(ii),ii = 1,npixels),anynull,' (ftgpfj)' |
| 488 |
|
| 489 |
call ftgpfe(iunit, 1, 1, npixels, einarray, larray, anynull, |
| 490 |
& status) |
| 491 |
|
| 492 |
do ii = 1, npixels |
| 493 |
if (larray(ii))einarray(ii) = 0. |
| 494 |
end do |
| 495 |
|
| 496 |
write(*,1102)(einarray(ii),ii = 1,npixels),anynull,' (ftgpfe)' |
| 497 |
|
| 498 |
call ftgpfd(iunit, 1, 1, 10, dinarray, larray, anynull,status) |
| 499 |
call ftgpfd(iunit, 1, 11, 10, dinarray(11), larray(11), |
| 500 |
& anynull, status) |
| 501 |
|
| 502 |
do ii = 1, npixels |
| 503 |
if (larray(ii))dinarray(ii) = 0. |
| 504 |
end do |
| 505 |
|
| 506 |
write(*,1102)(dinarray(ii),ii = 1,npixels),anynull,' (ftgpfd)' |
| 507 |
|
| 508 |
if (status .gt. 0)then |
| 509 |
write(*,'(1x,A,I4)')'ERROR: ftgpf_ status = ', status |
| 510 |
go to 999 |
| 511 |
end if |
| 512 |
|
| 513 |
if (.not. anynull)then |
| 514 |
write(*,'(1x,A)') 'ERROR: ftgpf_ did not detect null values' |
| 515 |
go to 999 |
| 516 |
end if |
| 517 |
|
| 518 |
|
| 519 |
C ########################################## |
| 520 |
C # close and reopen file multiple times # |
| 521 |
C ########################################## |
| 522 |
|
| 523 |
|
| 524 |
do ii = 1, 10 |
| 525 |
call ftclos(iunit, status) |
| 526 |
|
| 527 |
if (status .gt. 0)then |
| 528 |
write(*,'(1x,A,I4)')'ERROR in ftclos (1) = ', status |
| 529 |
go to 999 |
| 530 |
end if |
| 531 |
|
| 532 |
call ftopen(iunit, filename, 1, block, status) |
| 533 |
|
| 534 |
if (status .gt. 0)then |
| 535 |
write(*,'(1x,A,I4)')'ERROR: ftopen open file status = ', |
| 536 |
& status |
| 537 |
go to 999 |
| 538 |
end if |
| 539 |
end do |
| 540 |
|
| 541 |
write(*,'(1x,A)') ' ' |
| 542 |
write(*,'(1x,A)') 'Closed then reopened the FITS file 10 times.' |
| 543 |
write(*,'(1x,A)')' ' |
| 544 |
|
| 545 |
call ftghdn(iunit, hdunum) |
| 546 |
write(*,'(1x,A,I4)')'HDU number = ', hdunum |
| 547 |
|
| 548 |
|
| 549 |
C ############################ |
| 550 |
C # read single keywords # |
| 551 |
C ############################ |
| 552 |
|
| 553 |
|
| 554 |
simple = .false. |
| 555 |
bitpix = 0 |
| 556 |
naxis = 0 |
| 557 |
naxes(1) = 0 |
| 558 |
naxes(2) = 0 |
| 559 |
pcount = -99 |
| 560 |
gcount = -99 |
| 561 |
extend = .false. |
| 562 |
write(*,'(1x,A)') 'Read back keywords: ' |
| 563 |
call ftghpr(iunit, 3, simple, bitpix, naxis, naxes, pcount, |
| 564 |
& gcount, extend, status) |
| 565 |
write(*,'(1x,A,L4,4I4)')'simple, bitpix, naxis, naxes = ', |
| 566 |
& simple, bitpix, naxis, naxes(1), naxes(2) |
| 567 |
write(*,'(1x,A,2I4,L4)')' pcount, gcount, extend = ', |
| 568 |
& pcount, gcount, extend |
| 569 |
|
| 570 |
call ftgrec(iunit, 9, card, status) |
| 571 |
write(*,'(1x,A)') card |
| 572 |
if (card(1:15) .ne. 'KEY_PREC= ''This') |
| 573 |
& write(*,'(1x,A)') 'ERROR in ftgrec ' |
| 574 |
|
| 575 |
call ftgkyn(iunit, 9, keyword, value, comment, status) |
| 576 |
write(*,'(1x,5A)') keyword,' ', value(1:35),' ', comment(1:20) |
| 577 |
|
| 578 |
if (keyword(1:8) .ne. 'KEY_PREC' ) |
| 579 |
& write(*,'(1x,2A)') 'ERROR in ftgkyn: ', keyword |
| 580 |
|
| 581 |
call ftgcrd(iunit, keyword, card, status) |
| 582 |
write(*,'(1x,A)') card |
| 583 |
|
| 584 |
if (keyword(1:8) .ne. card(1:8) ) |
| 585 |
& write(*,'(1x,2A)') 'ERROR in ftgcrd: ', keyword |
| 586 |
|
| 587 |
call ftgkey(iunit, 'KY_PKNS1', value, comment, status) |
| 588 |
write(*,'(1x,5A)') 'KY_PKNS1 ',':', value(1:15),':', comment(1:16) |
| 589 |
|
| 590 |
if (value(1:14) .ne. '''first string''') |
| 591 |
& write(*,'(1x,2A)') 'ERROR in ftgkey: ', value |
| 592 |
|
| 593 |
call ftgkys(iunit, 'key_pkys', iskey, comment, status) |
| 594 |
write(*,'(1x,5A,I4)')'KEY_PKYS ',':',iskey,':',comment(1:16), |
| 595 |
& status |
| 596 |
|
| 597 |
call ftgkyl(iunit, 'key_pkyl', ilkey, comment, status) |
| 598 |
write(*,'(1x,2A,L4,2A,I4)') 'KEY_PKYL ',':', ilkey,':', |
| 599 |
&comment(1:16), status |
| 600 |
|
| 601 |
call ftgkyj(iunit, 'KEY_PKYJ', ijkey, comment, status) |
| 602 |
write(*,'(1x,2A,I4,2A,I4)') 'KEY_PKYJ ',':',ijkey,':', |
| 603 |
& comment(1:16), status |
| 604 |
|
| 605 |
call ftgkye(iunit, 'KEY_PKYJ', iekey, comment, status) |
| 606 |
write(*,'(1x,2A,f12.5,2A,I4)') 'KEY_PKYE ',':',iekey,':', |
| 607 |
& comment(1:16), status |
| 608 |
|
| 609 |
call ftgkyd(iunit, 'KEY_PKYJ', idkey, comment, status) |
| 610 |
write(*,'(1x,2A,F12.5,2A,I4)') 'KEY_PKYD ',':',idkey,':', |
| 611 |
& comment(1:16), status |
| 612 |
|
| 613 |
if (ijkey .ne. 11 .or. iekey .ne. 11. .or. idkey .ne. 11.) |
| 614 |
& write(*,'(1x,A,I4,2F5.1)') 'ERROR in ftgky(jed): ', |
| 615 |
& ijkey, iekey, idkey |
| 616 |
|
| 617 |
iskey= ' ' |
| 618 |
call ftgkys(iunit, 'key_pkys', iskey, comment, status) |
| 619 |
write(*,'(1x,5A,I4)') 'KEY_PKYS ',':', iskey,':', comment(1:16), |
| 620 |
& status |
| 621 |
|
| 622 |
ilkey = .false. |
| 623 |
call ftgkyl(iunit, 'key_pkyl', ilkey, comment, status) |
| 624 |
write(*,'(1x,2A,L4,2A,I4)') 'KEY_PKYL ',':', ilkey,':', |
| 625 |
& comment(1:16), status |
| 626 |
|
| 627 |
ijkey = 0 |
| 628 |
call ftgkyj(iunit, 'KEY_PKYJ', ijkey, comment, status) |
| 629 |
write(*,'(1x,2A,I4,2A,I4)') 'KEY_PKYJ ',':',ijkey,':', |
| 630 |
& comment(1:16), status |
| 631 |
|
| 632 |
iekey = 0 |
| 633 |
call ftgkye(iunit, 'KEY_PKYE', iekey, comment, status) |
| 634 |
write(*,'(1x,2A,f12.5,2A,I4)') 'KEY_PKYE ',':',iekey,':', |
| 635 |
& comment(1:16), status |
| 636 |
|
| 637 |
idkey = 0 |
| 638 |
call ftgkyd(iunit, 'KEY_PKYD', idkey, comment, status) |
| 639 |
write(*,'(1x,2A,F12.5,2A,I4)') 'KEY_PKYD ',':',idkey,':', |
| 640 |
& comment(1:16), status |
| 641 |
|
| 642 |
iekey = 0 |
| 643 |
call ftgkye(iunit, 'KEY_PKYF', iekey, comment, status) |
| 644 |
write(*,'(1x,2A,f12.5,2A,I4)') 'KEY_PKYF ',':',iekey,':', |
| 645 |
& comment(1:16), status |
| 646 |
|
| 647 |
iekey = 0 |
| 648 |
call ftgkye(iunit, 'KEY_PKYE', iekey, comment, status) |
| 649 |
write(*,'(1x,2A,f12.5,2A,I4)') 'KEY_PKYE ',':',iekey,':', |
| 650 |
& comment(1:16), status |
| 651 |
|
| 652 |
idkey = 0 |
| 653 |
call ftgkyd(iunit, 'KEY_PKYG', idkey, comment, status) |
| 654 |
write(*,'(1x,2A,f16.12,2A,I4)') 'KEY_PKYG ',':',idkey,':', |
| 655 |
& comment(1:16), status |
| 656 |
|
| 657 |
idkey = 0 |
| 658 |
call ftgkyd(iunit, 'KEY_PKYD', idkey, comment, status) |
| 659 |
write(*,'(1x,2A,f16.12,2A,I4)') 'KEY_PKYD ',':',idkey,':', |
| 660 |
& comment(1:16), status |
| 661 |
|
| 662 |
call ftgkyt(iunit, 'KEY_PKYT', ijkey, idkey, comment, status) |
| 663 |
write(*,'(1x,2A,i10,A,f16.14,A,I4)') 'KEY_PKYT ',':', |
| 664 |
& ijkey,':', idkey, comment(1:16), status |
| 665 |
|
| 666 |
call ftpunt(iunit, 'KEY_PKYJ', 'km/s/Mpc', status) |
| 667 |
ijkey = 0 |
| 668 |
call ftgkyj(iunit, 'KEY_PKYJ', ijkey, comment, status) |
| 669 |
write(*,'(1x,2A,I4,2A,I4)') 'KEY_PKYJ ',':',ijkey,':', |
| 670 |
& comment(1:38), status |
| 671 |
call ftgunt(iunit,'KEY_PKYJ',kunit,status) |
| 672 |
write(*,'(1x,2A)') 'keyword unit=', kunit |
| 673 |
|
| 674 |
call ftpunt(iunit, 'KEY_PKYJ', ' ', status) |
| 675 |
ijkey = 0 |
| 676 |
call ftgkyj(iunit, 'KEY_PKYJ', ijkey, comment, status) |
| 677 |
write(*,'(1x,2A,I4,2A,I4)') 'KEY_PKYJ ',':',ijkey,':', |
| 678 |
& comment(1:38), status |
| 679 |
call ftgunt(iunit,'KEY_PKYJ',kunit,status) |
| 680 |
write(*,'(1x,2A)') 'keyword unit=', kunit |
| 681 |
|
| 682 |
call ftpunt(iunit, 'KEY_PKYJ', 'feet/second/second', status) |
| 683 |
ijkey = 0 |
| 684 |
call ftgkyj(iunit, 'KEY_PKYJ', ijkey, comment, status) |
| 685 |
write(*,'(1x,2A,I4,2A,I4)') 'KEY_PKYJ ',':',ijkey,':', |
| 686 |
& comment(1:38), status |
| 687 |
call ftgunt(iunit,'KEY_PKYJ',kunit,status) |
| 688 |
write(*,'(1x,2A)') 'keyword unit=', kunit |
| 689 |
|
| 690 |
call ftgkys(iunit, 'key_pkls', lstr, comment, status) |
| 691 |
write(*,'(1x,2A)') 'KEY_PKLS long string value = ', lstr(1:50) |
| 692 |
write(*,'(1x,A)')lstr(51:120) |
| 693 |
|
| 694 |
C get size and position in header |
| 695 |
call ftghps(iunit, existkeys, keynum, status) |
| 696 |
write(*,'(1x,A,I4,A,I4)') 'header contains ', existkeys, |
| 697 |
& ' keywords; located at keyword ', keynum |
| 698 |
|
| 699 |
C ############################ |
| 700 |
C # read array keywords # |
| 701 |
C ############################ |
| 702 |
|
| 703 |
call ftgkns(iunit, 'ky_pkns', 1, 3, inskey, nfound, status) |
| 704 |
write(*,'(1x,4A)') 'ftgkns: ', inskey(1)(1:14), inskey(2)(1:14), |
| 705 |
& inskey(3)(1:14) |
| 706 |
if (nfound .ne. 3 .or. status .gt. 0) |
| 707 |
& write(*,'(1x,A,2I4)') ' ERROR in ftgkns ', nfound, status |
| 708 |
|
| 709 |
call ftgknl(iunit, 'ky_pknl', 1, 3, inlkey, nfound, status) |
| 710 |
write(*,'(1x,A,3L4)') 'ftgknl: ', inlkey(1), inlkey(2), inlkey(3) |
| 711 |
if (nfound .ne. 3 .or. status .gt. 0) |
| 712 |
& write(*,'(1x,A,2I4)') ' ERROR in ftgknl ', nfound, status |
| 713 |
|
| 714 |
call ftgknj(iunit, 'ky_pknj', 1, 3, injkey, nfound, status) |
| 715 |
write(*,'(1x,A,3I4)') 'ftgknj: ', injkey(1), injkey(2), injkey(3) |
| 716 |
if (nfound .ne. 3 .or. status .gt. 0) |
| 717 |
& write(*,'(1x,A,2I4)') ' ERROR in ftgknj ', nfound, status |
| 718 |
|
| 719 |
call ftgkne(iunit, 'ky_pkne', 1, 3, inekey, nfound, status) |
| 720 |
write(*,'(1x,A,3F10.5)') 'ftgkne: ',inekey(1),inekey(2),inekey(3) |
| 721 |
if (nfound .ne. 3 .or. status .gt. 0) |
| 722 |
& write(*,'(1x,A,2I4)') ' ERROR in ftgkne ', nfound, status |
| 723 |
|
| 724 |
call ftgknd(iunit, 'ky_pknd', 1, 3, indkey, nfound, status) |
| 725 |
write(*,'(1x,A,3F10.5)') 'ftgknd: ',indkey(1),indkey(2),indkey(3) |
| 726 |
if (nfound .ne. 3 .or. status .gt. 0) |
| 727 |
& write(*,'(1x,A,2I4)') ' ERROR in ftgknd ', nfound, status |
| 728 |
|
| 729 |
write(*,'(1x,A)')' ' |
| 730 |
write(*,'(1x,A)') |
| 731 |
& 'Before deleting the HISTORY and DATE keywords...' |
| 732 |
do ii = 29, 32 |
| 733 |
call ftgrec(iunit, ii, card, status) |
| 734 |
write(*,'(1x,A)') card(1:8) |
| 735 |
end do |
| 736 |
|
| 737 |
C don't print date value, so that |
| 738 |
C the output will always be the same |
| 739 |
|
| 740 |
|
| 741 |
C ############################ |
| 742 |
C # delete keywords # |
| 743 |
C ############################ |
| 744 |
|
| 745 |
|
| 746 |
call ftdrec(iunit, 30, status) |
| 747 |
call ftdkey(iunit, 'DATE', status) |
| 748 |
|
| 749 |
write(*,'(1x,A)')' ' |
| 750 |
write(*,'(1x,A)') 'After deleting the keywords... ' |
| 751 |
do ii = 29, 30 |
| 752 |
call ftgrec(iunit, ii, card, status) |
| 753 |
write(*,'(1x,A)') card |
| 754 |
end do |
| 755 |
|
| 756 |
if (status .gt. 0) |
| 757 |
& write(*,'(1x,A)') ' ERROR deleting keywords ' |
| 758 |
|
| 759 |
|
| 760 |
C ############################ |
| 761 |
C # insert keywords # |
| 762 |
C ############################ |
| 763 |
|
| 764 |
call ftirec(iunit,26, |
| 765 |
& 'KY_IREC = ''This keyword inserted by fxirec''', |
| 766 |
& status) |
| 767 |
call ftikys(iunit, 'KY_IKYS', 'insert_value_string', |
| 768 |
& 'ikys comment', status) |
| 769 |
call ftikyj(iunit, 'KY_IKYJ', 49, 'ikyj comment', status) |
| 770 |
call ftikyl(iunit, 'KY_IKYL', .true., 'ikyl comment', status) |
| 771 |
call ftikye(iunit, 'KY_IKYE',12.3456,4,'ikye comment',status) |
| 772 |
odkey = 12.345678901234567D+00 |
| 773 |
call ftikyd(iunit, 'KY_IKYD', odkey, 14, |
| 774 |
& 'ikyd comment', status) |
| 775 |
call ftikyf(iunit, 'KY_IKYF', 12.3456, 4, 'ikyf comment', |
| 776 |
& status) |
| 777 |
call ftikyg(iunit, 'KY_IKYG', odkey, 13, |
| 778 |
& 'ikyg comment', status) |
| 779 |
|
| 780 |
write(*,'(1x,A)')' ' |
| 781 |
write(*,'(1x,A)') 'After inserting the keywords... ' |
| 782 |
do ii = 25, 34 |
| 783 |
call ftgrec(iunit, ii, card, status) |
| 784 |
write(*,'(1x,A)') card |
| 785 |
end do |
| 786 |
|
| 787 |
if (status .gt. 0) |
| 788 |
& write(*,'(1x,A)') ' ERROR inserting keywords ' |
| 789 |
|
| 790 |
|
| 791 |
C ############################ |
| 792 |
C # modify keywords # |
| 793 |
C ############################ |
| 794 |
|
| 795 |
call ftmrec(iunit, 25, |
| 796 |
& 'COMMENT This keyword was modified by fxmrec', status) |
| 797 |
call ftmcrd(iunit, 'KY_IREC', |
| 798 |
& 'KY_MREC = ''This keyword was modified by fxmcrd''', status) |
| 799 |
call ftmnam(iunit, 'KY_IKYS', 'NEWIKYS', status) |
| 800 |
|
| 801 |
call ftmcom(iunit,'KY_IKYJ','This is a modified comment', |
| 802 |
& status) |
| 803 |
call ftmkyj(iunit, 'KY_IKYJ', 50, '&', status) |
| 804 |
call ftmkyl(iunit, 'KY_IKYL', .false., '&', status) |
| 805 |
call ftmkys(iunit, 'NEWIKYS', 'modified_string', '&', status) |
| 806 |
call ftmkye(iunit, 'KY_IKYE', -12.3456, 4, '&', status) |
| 807 |
odkey = -12.345678901234567D+00 |
| 808 |
|
| 809 |
call ftmkyd(iunit, 'KY_IKYD', odkey, 14, |
| 810 |
& 'modified comment', status) |
| 811 |
call ftmkyf(iunit, 'KY_IKYF', -12.3456, 4, '&', status) |
| 812 |
call ftmkyg(iunit,'KY_IKYG', odkey,13,'&',status) |
| 813 |
|
| 814 |
write(*,'(1x,A)')' ' |
| 815 |
write(*,'(1x,A)') 'After modifying the keywords... ' |
| 816 |
do ii = 25, 34 |
| 817 |
call ftgrec(iunit, ii, card, status) |
| 818 |
write(*,'(1x,A)') card |
| 819 |
end do |
| 820 |
|
| 821 |
if (status .gt. 0)then |
| 822 |
write(*,'(1x,A)') ' ERROR modifying keywords ' |
| 823 |
go to 999 |
| 824 |
end if |
| 825 |
|
| 826 |
C ############################ |
| 827 |
C # update keywords # |
| 828 |
C ############################ |
| 829 |
|
| 830 |
call ftucrd(iunit, 'KY_MREC', |
| 831 |
& 'KY_UCRD = ''This keyword was updated by fxucrd''', |
| 832 |
& status) |
| 833 |
|
| 834 |
call ftukyj(iunit, 'KY_IKYJ', 51, '&', status) |
| 835 |
call ftukyl(iunit, 'KY_IKYL', .true., '&', status) |
| 836 |
call ftukys(iunit, 'NEWIKYS', 'updated_string', '&', status) |
| 837 |
call ftukye(iunit, 'KY_IKYE', -13.3456, 4, '&', status) |
| 838 |
odkey = -13.345678901234567D+00 |
| 839 |
|
| 840 |
call ftukyd(iunit, 'KY_IKYD',odkey , 14, |
| 841 |
& 'modified comment', status) |
| 842 |
call ftukyf(iunit, 'KY_IKYF', -13.3456, 4, '&', status) |
| 843 |
call ftukyg(iunit, 'KY_IKYG', odkey, 13, '&', status) |
| 844 |
|
| 845 |
write(*,'(1x,A)')' ' |
| 846 |
write(*,'(1x,A)') 'After updating the keywords... ' |
| 847 |
do ii = 25, 34 |
| 848 |
call ftgrec(iunit, ii, card, status) |
| 849 |
write(*,'(1x,A)') card |
| 850 |
end do |
| 851 |
|
| 852 |
if (status .gt. 0)then |
| 853 |
write(*,'(1x,A)') ' ERROR modifying keywords ' |
| 854 |
go to 999 |
| 855 |
end if |
| 856 |
|
| 857 |
C move to top of header and find keywords using wild cards |
| 858 |
call ftgrec(iunit, 0, card, status) |
| 859 |
|
| 860 |
write(*,'(1x,A)')' ' |
| 861 |
write(*,'(1x,A)') |
| 862 |
& 'Keywords found using wildcard search (should be 9)...' |
| 863 |
nfound = -1 |
| 864 |
91 nfound = nfound +1 |
| 865 |
call ftgnxk(iunit, inclist, 2, exclist, 2, card, status) |
| 866 |
if (status .eq. 0)then |
| 867 |
write(*,'(1x,A)') card |
| 868 |
go to 91 |
| 869 |
end if |
| 870 |
|
| 871 |
if (nfound .ne. 9)then |
| 872 |
write(*,'(1x,A)') |
| 873 |
& 'ERROR reading keywords using wildcards (ftgnxk)' |
| 874 |
go to 999 |
| 875 |
end if |
| 876 |
status = 0 |
| 877 |
|
| 878 |
C ############################ |
| 879 |
C # create binary table # |
| 880 |
C ############################ |
| 881 |
|
| 882 |
tform(1) = '15A' |
| 883 |
tform(2) = '1L' |
| 884 |
tform(3) = '16X' |
| 885 |
tform(4) = '1B' |
| 886 |
tform(5) = '1I' |
| 887 |
tform(6) = '1J' |
| 888 |
tform(7) = '1E' |
| 889 |
tform(8) = '1D' |
| 890 |
tform(9) = '1C' |
| 891 |
tform(10)= '1M' |
| 892 |
|
| 893 |
ttype(1) = 'Avalue' |
| 894 |
ttype(2) = 'Lvalue' |
| 895 |
ttype(3) = 'Xvalue' |
| 896 |
ttype(4) = 'Bvalue' |
| 897 |
ttype(5) = 'Ivalue' |
| 898 |
ttype(6) = 'Jvalue' |
| 899 |
ttype(7) = 'Evalue' |
| 900 |
ttype(8) = 'Dvalue' |
| 901 |
ttype(9) = 'Cvalue' |
| 902 |
ttype(10)= 'Mvalue' |
| 903 |
|
| 904 |
tunit(1) = ' ' |
| 905 |
tunit(2) = 'm**2' |
| 906 |
tunit(3) = 'cm' |
| 907 |
tunit(4) = 'erg/s' |
| 908 |
tunit(5) = 'km/s' |
| 909 |
tunit(6) = ' ' |
| 910 |
tunit(7) = ' ' |
| 911 |
tunit(8) = ' ' |
| 912 |
tunit(9) = ' ' |
| 913 |
tunit(10)= ' ' |
| 914 |
|
| 915 |
nrows = 21 |
| 916 |
tfields = 10 |
| 917 |
pcount = 0 |
| 918 |
|
| 919 |
call ftibin(iunit, nrows, tfields, ttype, tform, tunit, |
| 920 |
& binname, pcount, status) |
| 921 |
write(*,'(1x,A)')' ' |
| 922 |
write(*,'(1x,A,I4)') 'ftibin status = ', status |
| 923 |
call ftghdn(iunit, hdunum) |
| 924 |
write(*,'(1x,A,I4)') 'HDU number = ', hdunum |
| 925 |
|
| 926 |
C get size and position in header, and reserve space for more keywords |
| 927 |
call ftghps(iunit, existkeys, keynum, status) |
| 928 |
write(*,'(1x,A,I4,A,I4)') 'header contains ',existkeys, |
| 929 |
& ' keywords located at keyword ', keynum |
| 930 |
|
| 931 |
morekeys = 40 |
| 932 |
call fthdef(iunit, morekeys, status) |
| 933 |
call ftghsp(iunit, existkeys, morekeys, status) |
| 934 |
write(*,'(1x,A,I4,A,I4,A)') 'header contains ', existkeys, |
| 935 |
&' keywords with room for ', morekeys,' more' |
| 936 |
|
| 937 |
C define null value for int cols |
| 938 |
call fttnul(iunit, 4, 99, status) |
| 939 |
call fttnul(iunit, 5, 99, status) |
| 940 |
call fttnul(iunit, 6, 99, status) |
| 941 |
|
| 942 |
call ftpkyj(iunit, 'TNULL4', 99, 'value for undefined pixels', |
| 943 |
& status) |
| 944 |
call ftpkyj(iunit, 'TNULL5', 99, 'value for undefined pixels', |
| 945 |
& status) |
| 946 |
call ftpkyj(iunit, 'TNULL6', 99, 'value for undefined pixels', |
| 947 |
& status) |
| 948 |
|
| 949 |
naxis = 3 |
| 950 |
naxes(1) = 1 |
| 951 |
naxes(2) = 2 |
| 952 |
naxes(3) = 8 |
| 953 |
call ftptdm(iunit, 3, naxis, naxes, status) |
| 954 |
|
| 955 |
naxis = 0 |
| 956 |
naxes(1) = 0 |
| 957 |
naxes(2) = 0 |
| 958 |
naxes(3) = 0 |
| 959 |
call ftgtdm(iunit, 3, 3, naxis, naxes, status) |
| 960 |
call ftgkys(iunit, 'TDIM3', iskey, comment, status) |
| 961 |
write(*,'(1x,2A,4I4)') 'TDIM3 = ', iskey, naxis, naxes(1), |
| 962 |
& naxes(2), naxes(3) |
| 963 |
|
| 964 |
C force header to be scanned (not required) |
| 965 |
call ftrdef(iunit, status) |
| 966 |
|
| 967 |
C ############################ |
| 968 |
C # write data to columns # |
| 969 |
C ############################ |
| 970 |
|
| 971 |
C initialize arrays of values to write to table |
| 972 |
signval = -1 |
| 973 |
do ii = 1, 21 |
| 974 |
signval = signval * (-1) |
| 975 |
boutarray(ii) = char(ii) |
| 976 |
ioutarray(ii) = (ii) * signval |
| 977 |
joutarray(ii) = (ii) * signval |
| 978 |
koutarray(ii) = (ii) * signval |
| 979 |
eoutarray(ii) = (ii) * signval |
| 980 |
doutarray(ii) = (ii) * signval |
| 981 |
end do |
| 982 |
|
| 983 |
call ftpcls(iunit, 1, 1, 1, 3, onskey, status) |
| 984 |
C write string values |
| 985 |
call ftpclu(iunit, 1, 4, 1, 1, status) |
| 986 |
C write null value |
| 987 |
|
| 988 |
larray(1) = .false. |
| 989 |
larray(2) =.true. |
| 990 |
larray(3) = .false. |
| 991 |
larray(4) = .false. |
| 992 |
larray(5) =.true. |
| 993 |
larray(6) =.true. |
| 994 |
larray(7) = .false. |
| 995 |
larray(8) = .false. |
| 996 |
larray(9) = .false. |
| 997 |
larray(10) =.true. |
| 998 |
larray(11) =.true. |
| 999 |
larray(12) = .true. |
| 1000 |
larray(13) = .false. |
| 1001 |
larray(14) = .false. |
| 1002 |
larray(15) =.false. |
| 1003 |
larray(16) =.false. |
| 1004 |
larray(17) = .true. |
| 1005 |
larray(18) = .true. |
| 1006 |
larray(19) = .true. |
| 1007 |
larray(20) = .true. |
| 1008 |
larray(21) =.false. |
| 1009 |
larray(22) =.false. |
| 1010 |
larray(23) =.false. |
| 1011 |
larray(24) =.false. |
| 1012 |
larray(25) =.false. |
| 1013 |
larray(26) = .true. |
| 1014 |
larray(27) = .true. |
| 1015 |
larray(28) = .true. |
| 1016 |
larray(29) = .true. |
| 1017 |
larray(30) = .true. |
| 1018 |
larray(31) =.false. |
| 1019 |
larray(32) =.false. |
| 1020 |
larray(33) =.false. |
| 1021 |
larray(34) =.false. |
| 1022 |
larray(35) =.false. |
| 1023 |
larray(36) =.false. |
| 1024 |
|
| 1025 |
C write bits |
| 1026 |
call ftpclx(iunit, 3, 1, 1, 36, larray, status) |
| 1027 |
|
| 1028 |
C loop over cols 4 - 8 |
| 1029 |
do ii = 4, 8 |
| 1030 |
call ftpclb(iunit, ii, 1, 1, 2, boutarray, status) |
| 1031 |
if (status .eq. 412) status = 0 |
| 1032 |
|
| 1033 |
call ftpcli(iunit, ii, 3, 1, 2, ioutarray(3), status) |
| 1034 |
if (status .eq. 412) status = 0 |
| 1035 |
|
| 1036 |
call ftpclj(iunit, ii, 5, 1, 2, koutarray(5), status) |
| 1037 |
if (status .eq. 412) status = 0 |
| 1038 |
|
| 1039 |
call ftpcle(iunit, ii, 7, 1, 2, eoutarray(7), status) |
| 1040 |
if (status .eq. 412)status = 0 |
| 1041 |
|
| 1042 |
call ftpcld(iunit, ii, 9, 1, 2, doutarray(9), status) |
| 1043 |
if (status .eq. 412)status = 0 |
| 1044 |
|
| 1045 |
C write null value |
| 1046 |
call ftpclu(iunit, ii, 11, 1, 1, status) |
| 1047 |
end do |
| 1048 |
|
| 1049 |
call ftpclc(iunit, 9, 1, 1, 10, eoutarray, status) |
| 1050 |
call ftpclm(iunit, 10, 1, 1, 10, doutarray, status) |
| 1051 |
|
| 1052 |
C loop over cols 4 - 8 |
| 1053 |
do ii = 4, 8 |
| 1054 |
bnul = char(13) |
| 1055 |
call ftpcnb(iunit, ii, 12, 1, 2, boutarray(12),bnul,status) |
| 1056 |
if (status .eq. 412) status = 0 |
| 1057 |
inul=15 |
| 1058 |
call ftpcni(iunit, ii, 14, 1, 2, ioutarray(14),inul,status) |
| 1059 |
if (status .eq. 412) status = 0 |
| 1060 |
call ftpcnj(iunit, ii, 16, 1, 2, koutarray(16), 17, status) |
| 1061 |
if (status .eq. 412) status = 0 |
| 1062 |
call ftpcne(iunit, ii, 18, 1, 2, eoutarray(18), 19.,status) |
| 1063 |
if (status .eq. 412) status = 0 |
| 1064 |
dnul = 21. |
| 1065 |
call ftpcnd(iunit, ii, 20, 1, 2, doutarray(20),dnul,status) |
| 1066 |
if (status .eq. 412) status = 0 |
| 1067 |
end do |
| 1068 |
|
| 1069 |
C write logicals |
| 1070 |
call ftpcll(iunit, 2, 1, 1, 21, larray, status) |
| 1071 |
C write null value |
| 1072 |
call ftpclu(iunit, 2, 11, 1, 1, status) |
| 1073 |
write(*,'(1x,A,I4)') 'ftpcl_ status = ', status |
| 1074 |
if (status .gt. 0)go to 999 |
| 1075 |
|
| 1076 |
C ######################################### |
| 1077 |
C # get information about the columns # |
| 1078 |
C ######################################### |
| 1079 |
|
| 1080 |
write(*,'(1x,A)')' ' |
| 1081 |
write(*,'(1x,A)') |
| 1082 |
& 'Find the column numbers a returned status value'// |
| 1083 |
& ' of 237 is' |
| 1084 |
write(*,'(1x,A)') |
| 1085 |
& 'expected and indicates that more than one column'// |
| 1086 |
& ' name matches' |
| 1087 |
write(*,'(1x,A)')'the input column name template.'// |
| 1088 |
& ' Status = 219 indicates that' |
| 1089 |
write(*,'(1x,A)') 'there was no matching column name.' |
| 1090 |
|
| 1091 |
call ftgcno(iunit, 0, 'Xvalue', colnum, status) |
| 1092 |
write(*,'(1x,A,I4,A,I4)') 'Column Xvalue is number', colnum, |
| 1093 |
&' status =',status |
| 1094 |
|
| 1095 |
219 continue |
| 1096 |
if (status .ne. 219)then |
| 1097 |
call ftgcnn(iunit, 1, '*ue', colname, colnum, status) |
| 1098 |
write(*,'(1x,3A,I4,A,I4)') 'Column ',colname(1:6),' is number', |
| 1099 |
& colnum,' status = ', status |
| 1100 |
go to 219 |
| 1101 |
end if |
| 1102 |
|
| 1103 |
status = 0 |
| 1104 |
|
| 1105 |
write(*,'(1x,A)')' ' |
| 1106 |
write(*,'(1x,A)') 'Information about each column: ' |
| 1107 |
|
| 1108 |
do ii = 1, tfields |
| 1109 |
call ftgtcl(iunit, ii, typecode, repeat, width, status) |
| 1110 |
call ftgbcl(iunit,ii,ttype,tunit,cval,repeat,scale, |
| 1111 |
& zero, jnulval, tdisp, status) |
| 1112 |
|
| 1113 |
write(*,'(1x,A,3I4,5A,2F8.2,I12,A)') |
| 1114 |
& tform(ii)(1:3), typecode, repeat, width,' ', |
| 1115 |
& ttype(1)(1:6),' ',tunit(1)(1:6), cval, scale, zero, jnulval, |
| 1116 |
& tdisp(1:8) |
| 1117 |
end do |
| 1118 |
|
| 1119 |
write(*,'(1x,A)') ' ' |
| 1120 |
|
| 1121 |
C ############################################### |
| 1122 |
C # insert ASCII table before the binary table # |
| 1123 |
C ############################################### |
| 1124 |
|
| 1125 |
call ftmrhd(iunit, -1, hdutype, status) |
| 1126 |
if (status .gt. 0)goto 999 |
| 1127 |
|
| 1128 |
tform(1) = 'A15' |
| 1129 |
tform(2) = 'I10' |
| 1130 |
tform(3) = 'F14.6' |
| 1131 |
tform(4) = 'E12.5' |
| 1132 |
tform(5) = 'D21.14' |
| 1133 |
|
| 1134 |
ttype(1) = 'Name' |
| 1135 |
ttype(2) = 'Ivalue' |
| 1136 |
ttype(3) = 'Fvalue' |
| 1137 |
ttype(4) = 'Evalue' |
| 1138 |
ttype(5) = 'Dvalue' |
| 1139 |
|
| 1140 |
tunit(1) = ' ' |
| 1141 |
tunit(2) = 'm**2' |
| 1142 |
tunit(3) = 'cm' |
| 1143 |
tunit(4) = 'erg/s' |
| 1144 |
tunit(5) = 'km/s' |
| 1145 |
|
| 1146 |
rowlen = 76 |
| 1147 |
nrows = 11 |
| 1148 |
tfields = 5 |
| 1149 |
|
| 1150 |
call ftitab(iunit, rowlen, nrows, tfields, ttype, tbcol, |
| 1151 |
& tform, tunit, tblname, status) |
| 1152 |
write(*,'(1x,A,I4)') 'ftitab status = ', status |
| 1153 |
call ftghdn(iunit, hdunum) |
| 1154 |
write(*,'(1x,A,I4)') 'HDU number = ', hdunum |
| 1155 |
|
| 1156 |
C define null value for int cols |
| 1157 |
call ftsnul(iunit, 1, 'null1', status) |
| 1158 |
call ftsnul(iunit, 2, 'null2', status) |
| 1159 |
call ftsnul(iunit, 3, 'null3', status) |
| 1160 |
call ftsnul(iunit, 4, 'null4', status) |
| 1161 |
call ftsnul(iunit, 5, 'null5', status) |
| 1162 |
|
| 1163 |
call ftpkys(iunit, 'TNULL1', 'null1', |
| 1164 |
& 'value for undefined pixels', status) |
| 1165 |
call ftpkys(iunit, 'TNULL2', 'null2', |
| 1166 |
& 'value for undefined pixels', status) |
| 1167 |
call ftpkys(iunit, 'TNULL3', 'null3', |
| 1168 |
& 'value for undefined pixels', status) |
| 1169 |
call ftpkys(iunit, 'TNULL4', 'null4', |
| 1170 |
& 'value for undefined pixels', status) |
| 1171 |
call ftpkys(iunit, 'TNULL5', 'null5', |
| 1172 |
& 'value for undefined pixels', status) |
| 1173 |
|
| 1174 |
if (status .gt. 0) goto 999 |
| 1175 |
|
| 1176 |
C ############################ |
| 1177 |
C # write data to columns # |
| 1178 |
C ############################ |
| 1179 |
|
| 1180 |
C initialize arrays of values to write to table |
| 1181 |
do ii = 1,21 |
| 1182 |
boutarray(ii) = char(ii) |
| 1183 |
ioutarray(ii) = ii |
| 1184 |
joutarray(ii) = ii |
| 1185 |
eoutarray(ii) = ii |
| 1186 |
doutarray(ii) = ii |
| 1187 |
end do |
| 1188 |
|
| 1189 |
C write string values |
| 1190 |
call ftpcls(iunit, 1, 1, 1, 3, onskey, status) |
| 1191 |
C write null value |
| 1192 |
call ftpclu(iunit, 1, 4, 1, 1, status) |
| 1193 |
|
| 1194 |
do ii = 2,5 |
| 1195 |
C loop over cols 2 - 5 |
| 1196 |
call ftpclb(iunit, ii, 1, 1, 2, boutarray, status) |
| 1197 |
C char array |
| 1198 |
if (status .eq. 412) status = 0 |
| 1199 |
|
| 1200 |
call ftpcli(iunit, ii, 3, 1, 2, ioutarray(3), status) |
| 1201 |
C short array |
| 1202 |
if (status .eq. 412) status = 0 |
| 1203 |
|
| 1204 |
call ftpclj(iunit, ii, 5, 1, 2, joutarray(5), status) |
| 1205 |
C long array |
| 1206 |
if (status .eq. 412)status = 0 |
| 1207 |
|
| 1208 |
call ftpcle(iunit, ii, 7, 1, 2, eoutarray(7), status) |
| 1209 |
C float array |
| 1210 |
if (status .eq. 412) status = 0 |
| 1211 |
|
| 1212 |
call ftpcld(iunit, ii, 9, 1, 2, doutarray(9), status) |
| 1213 |
C double array |
| 1214 |
if (status .eq. 412) status = 0 |
| 1215 |
|
| 1216 |
call ftpclu(iunit, ii, 11, 1, 1, status) |
| 1217 |
C write null value |
| 1218 |
end do |
| 1219 |
write(*,'(1x,A,I4)') 'ftpcl_ status = ', status |
| 1220 |
write(*,'(1x,A)')' ' |
| 1221 |
|
| 1222 |
C ################################ |
| 1223 |
C # read data from ASCII table # |
| 1224 |
C ################################ |
| 1225 |
|
| 1226 |
call ftghtb(iunit, 99, rowlen, nrows, tfields, ttype, tbcol, |
| 1227 |
& tform, tunit, tblname, status) |
| 1228 |
|
| 1229 |
write(*,'(1x,A,3I3,2A)') |
| 1230 |
& 'ASCII table: rowlen, nrows, tfields, extname:', |
| 1231 |
& rowlen, nrows, tfields,' ',tblname |
| 1232 |
|
| 1233 |
do ii = 1,tfields |
| 1234 |
write(*,'(1x,A,I4,3A)') |
| 1235 |
& ttype(ii)(1:7), tbcol(ii),' ',tform(ii)(1:7), tunit(ii)(1:7) |
| 1236 |
end do |
| 1237 |
|
| 1238 |
nrows = 11 |
| 1239 |
call ftgcvs(iunit, 1, 1, 1, nrows, 'UNDEFINED', inskey, |
| 1240 |
& anynull, status) |
| 1241 |
bnul = char(99) |
| 1242 |
call ftgcvb(iunit, 2, 1, 1, nrows, bnul, binarray, |
| 1243 |
& anynull, status) |
| 1244 |
inul = 99 |
| 1245 |
call ftgcvi(iunit, 2, 1, 1, nrows, inul, iinarray, |
| 1246 |
& anynull, status) |
| 1247 |
call ftgcvj(iunit, 3, 1, 1, nrows, 99, jinarray, |
| 1248 |
& anynull, status) |
| 1249 |
call ftgcve(iunit, 4, 1, 1, nrows, 99., einarray, |
| 1250 |
& anynull, status) |
| 1251 |
dnul = 99. |
| 1252 |
call ftgcvd(iunit, 5, 1, 1, nrows, dnul, dinarray, |
| 1253 |
& anynull, status) |
| 1254 |
|
| 1255 |
write(*,'(1x,A)')' ' |
| 1256 |
write(*,'(1x,A)') 'Data values read from ASCII table: ' |
| 1257 |
do ii = 1, nrows |
| 1258 |
jj = ichar(binarray(ii)) |
| 1259 |
write(*,1011) inskey(ii), jj, |
| 1260 |
& iinarray(ii), jinarray(ii), einarray(ii), dinarray(ii) |
| 1261 |
1011 format(1x,a15,3i3,1x,2f3.0) |
| 1262 |
end do |
| 1263 |
|
| 1264 |
call ftgtbs(iunit, 1, 20, 78, uchars, status) |
| 1265 |
write(*,'(1x,A)')' ' |
| 1266 |
write(*,'(1x,A)') uchars |
| 1267 |
call ftptbs(iunit, 1, 20, 78, uchars, status) |
| 1268 |
|
| 1269 |
C ######################################### |
| 1270 |
C # get information about the columns # |
| 1271 |
C ######################################### |
| 1272 |
|
| 1273 |
call ftgcno(iunit, 0, 'name', colnum, status) |
| 1274 |
write(*,'(1x,A)')' ' |
| 1275 |
write(*,'(1x,A,I4,A,I4)') |
| 1276 |
& 'Column name is number',colnum,' status = ', status |
| 1277 |
|
| 1278 |
2190 continue |
| 1279 |
if (status .ne. 219)then |
| 1280 |
if (status .gt. 0 .and. status .ne. 237)go to 999 |
| 1281 |
|
| 1282 |
call ftgcnn(iunit, 1, '*ue', colname, colnum, status) |
| 1283 |
write(*,'(1x,3A,I4,A,I4)') |
| 1284 |
& 'Column ',colname(1:6),' is number',colnum,' status = ',status |
| 1285 |
go to 2190 |
| 1286 |
end if |
| 1287 |
|
| 1288 |
status = 0 |
| 1289 |
|
| 1290 |
do ii = 1, tfields |
| 1291 |
call ftgtcl(iunit, ii, typecode, repeat, width, status) |
| 1292 |
call ftgacl(iunit, ii, ttype, tbcol,tunit,tform, |
| 1293 |
& scale,zero, nulstr, tdisp, status) |
| 1294 |
|
| 1295 |
write(*,'(1x,A,3I4,2A,I4,2A,2F10.2,3A)') |
| 1296 |
& tform(ii)(1:7), typecode, repeat, width,' ', |
| 1297 |
& ttype(1)(1:6), tbcol(1), ' ',tunit(1)(1:5), |
| 1298 |
& scale, zero, ' ', nulstr(1:6), tdisp(1:2) |
| 1299 |
|
| 1300 |
end do |
| 1301 |
|
| 1302 |
write(*,'(1x,A)') ' ' |
| 1303 |
|
| 1304 |
C ############################################### |
| 1305 |
C # test the insert/delete row/column routines # |
| 1306 |
C ############################################### |
| 1307 |
|
| 1308 |
call ftirow(iunit, 2, 3, status) |
| 1309 |
if (status .gt. 0) goto 999 |
| 1310 |
|
| 1311 |
nrows = 14 |
| 1312 |
call ftgcvs(iunit, 1, 1, 1, nrows, 'UNDEFINED', |
| 1313 |
& inskey, anynull, status) |
| 1314 |
call ftgcvb(iunit, 2, 1, 1, nrows, bnul, binarray, |
| 1315 |
& anynull, status) |
| 1316 |
call ftgcvi(iunit, 2, 1, 1, nrows, inul, iinarray, |
| 1317 |
& anynull, status) |
| 1318 |
call ftgcvj(iunit, 3, 1, 1, nrows, 99, jinarray, |
| 1319 |
& anynull, status) |
| 1320 |
call ftgcve(iunit, 4, 1, 1, nrows, 99., einarray, |
| 1321 |
& anynull, status) |
| 1322 |
call ftgcvd(iunit, 5, 1, 1, nrows, dnul, dinarray, |
| 1323 |
& anynull, status) |
| 1324 |
|
| 1325 |
write(*,'(1x,A)')' ' |
| 1326 |
write(*,'(1x,A)')'Data values after inserting 3 rows after row 2:' |
| 1327 |
do ii = 1, nrows |
| 1328 |
jj = ichar(binarray(ii)) |
| 1329 |
write(*,1011) inskey(ii), jj, |
| 1330 |
& iinarray(ii), jinarray(ii), einarray(ii), dinarray(ii) |
| 1331 |
end do |
| 1332 |
|
| 1333 |
call ftdrow(iunit, 10, 2, status) |
| 1334 |
|
| 1335 |
nrows = 12 |
| 1336 |
call ftgcvs(iunit, 1, 1, 1, nrows, 'UNDEFINED', inskey, |
| 1337 |
& anynull, status) |
| 1338 |
call ftgcvb(iunit, 2, 1, 1, nrows, bnul, binarray, anynull, |
| 1339 |
& status) |
| 1340 |
call ftgcvi(iunit, 2, 1, 1, nrows, inul, iinarray, anynull, |
| 1341 |
& status) |
| 1342 |
call ftgcvj(iunit, 3, 1, 1, nrows, 99, jinarray, anynull, |
| 1343 |
& status) |
| 1344 |
call ftgcve(iunit, 4, 1, 1, nrows, 99., einarray, anynull, |
| 1345 |
& status) |
| 1346 |
call ftgcvd(iunit, 5, 1, 1, nrows, dnul, dinarray, anynull, |
| 1347 |
& status) |
| 1348 |
|
| 1349 |
write(*,'(1x,A)')' ' |
| 1350 |
write(*,'(1x,A)') 'Data values after deleting 2 rows at row 10: ' |
| 1351 |
do ii = 1, nrows |
| 1352 |
jj = ichar(binarray(ii)) |
| 1353 |
write(*,1011) inskey(ii), jj, |
| 1354 |
& iinarray(ii), jinarray(ii), einarray(ii), dinarray(ii) |
| 1355 |
end do |
| 1356 |
call ftdcol(iunit, 3, status) |
| 1357 |
|
| 1358 |
call ftgcvs(iunit, 1, 1, 1, nrows, 'UNDEFINED', inskey, |
| 1359 |
& anynull, status) |
| 1360 |
call ftgcvb(iunit, 2, 1, 1, nrows, bnul, binarray, anynull, |
| 1361 |
& status) |
| 1362 |
call ftgcvi(iunit, 2, 1, 1, nrows, inul, iinarray, anynull, |
| 1363 |
& status) |
| 1364 |
call ftgcve(iunit, 3, 1, 1, nrows, 99., einarray, anynull, |
| 1365 |
& status) |
| 1366 |
call ftgcvd(iunit, 4, 1, 1, nrows, dnul, dinarray, anynull, |
| 1367 |
& status) |
| 1368 |
|
| 1369 |
write(*,'(1x,A)')' ' |
| 1370 |
write(*,'(1x,A)') 'Data values after deleting column 3: ' |
| 1371 |
do ii = 1,nrows |
| 1372 |
jj = ichar(binarray(ii)) |
| 1373 |
write(*,1012) inskey(ii), jj, |
| 1374 |
& iinarray(ii), einarray(ii), dinarray(ii) |
| 1375 |
1012 format(1x,a15,2i3,1x,2f3.0) |
| 1376 |
|
| 1377 |
end do |
| 1378 |
|
| 1379 |
call fticol(iunit, 5, 'INSERT_COL', 'F14.6', status) |
| 1380 |
|
| 1381 |
call ftgcvs(iunit, 1, 1, 1, nrows, 'UNDEFINED', inskey, |
| 1382 |
& anynull, status) |
| 1383 |
call ftgcvb(iunit, 2, 1, 1, nrows, bnul, binarray, anynull, |
| 1384 |
& status) |
| 1385 |
call ftgcvi(iunit, 2, 1, 1, nrows, inul, iinarray, anynull, |
| 1386 |
& status) |
| 1387 |
call ftgcve(iunit, 3, 1, 1, nrows, 99., einarray, anynull, |
| 1388 |
& status) |
| 1389 |
call ftgcvd(iunit, 4, 1, 1, nrows, dnul, dinarray, anynull, |
| 1390 |
& status) |
| 1391 |
call ftgcvj(iunit, 5, 1, 1, nrows, 99, jinarray, anynull, |
| 1392 |
& status) |
| 1393 |
|
| 1394 |
write(*,'(1x,A)')' ' |
| 1395 |
write(*,'(1x,A)') ' Data values after inserting column 5: ' |
| 1396 |
do ii = 1, nrows |
| 1397 |
jj = ichar(binarray(ii)) |
| 1398 |
write(*,1013) inskey(ii), jj, |
| 1399 |
& iinarray(ii), einarray(ii), dinarray(ii) , jinarray(ii) |
| 1400 |
1013 format(1x,a15,2i3,1x,2f3.0,i2) |
| 1401 |
|
| 1402 |
end do |
| 1403 |
|
| 1404 |
C ################################ |
| 1405 |
C # read data from binary table # |
| 1406 |
C ################################ |
| 1407 |
|
| 1408 |
|
| 1409 |
call ftmrhd(iunit, 1, hdutype, status) |
| 1410 |
if (status .gt. 0)go to 999 |
| 1411 |
call ftghdn(iunit, hdunum) |
| 1412 |
write(*,'(1x,A,I4)') 'HDU number = ', hdunum |
| 1413 |
|
| 1414 |
call ftghsp(iunit, existkeys, morekeys, status) |
| 1415 |
write(*,'(1x,A)')' ' |
| 1416 |
write(*,'(1x,A)')'Moved to binary table' |
| 1417 |
write(*,'(1x,A,I4,A,I4,A)') 'header contains ',existkeys, |
| 1418 |
& ' keywords with room for ',morekeys,' more ' |
| 1419 |
|
| 1420 |
call ftghbn(iunit, 99, nrows, tfields, ttype, |
| 1421 |
& tform, tunit, binname, pcount, status) |
| 1422 |
|
| 1423 |
write(*,'(1x,A)')' ' |
| 1424 |
write(*,'(1x,A,2I4,A,I4)') |
| 1425 |
& 'Binary table: nrows, tfields, extname, pcount:', |
| 1426 |
& nrows, tfields, binname, pcount |
| 1427 |
|
| 1428 |
do ii = 1,tfields |
| 1429 |
write(*,'(1x,3A)') ttype(ii), tform(ii), tunit(ii) |
| 1430 |
end do |
| 1431 |
|
| 1432 |
do ii = 1, 40 |
| 1433 |
larray(ii) = .false. |
| 1434 |
end do |
| 1435 |
|
| 1436 |
write(*,'(1x,A)')' ' |
| 1437 |
write(*,'(1x,A)') 'Data values read from binary table: ' |
| 1438 |
write(*,'(1x,A)') ' Bit column (X) data values: ' |
| 1439 |
|
| 1440 |
call ftgcx(iunit, 3, 1, 1, 36, larray, status) |
| 1441 |
write(*,1014) (larray(ii), ii = 1,40) |
| 1442 |
1014 format(1x,8l1,' ',8l1,' ',8l1,' ',8l1,' ',8l1) |
| 1443 |
|
| 1444 |
nrows = 21 |
| 1445 |
do ii = 1, nrows |
| 1446 |
larray(ii) = .false. |
| 1447 |
xinarray(ii) = ' ' |
| 1448 |
binarray(ii) = ' ' |
| 1449 |
iinarray(ii) = 0 |
| 1450 |
kinarray(ii) = 0 |
| 1451 |
einarray(ii) = 0. |
| 1452 |
dinarray(ii) = 0. |
| 1453 |
cinarray(ii * 2 -1) = 0. |
| 1454 |
minarray(ii * 2 -1) = 0. |
| 1455 |
cinarray(ii * 2 ) = 0. |
| 1456 |
minarray(ii * 2 ) = 0. |
| 1457 |
end do |
| 1458 |
|
| 1459 |
write(*,'(1x,A)') ' ' |
| 1460 |
call ftgcvs(iunit, 1, 4, 1, 1, ' ', inskey, anynull,status) |
| 1461 |
if (ichar(inskey(1)(1:1)) .eq. 0)inskey(1)=' ' |
| 1462 |
write(*,'(1x,2A)') 'null string column value (should be blank):', |
| 1463 |
& inskey(1) |
| 1464 |
|
| 1465 |
call ftgcvs(iunit, 1, 1, 1, nrows, 'NOT DEFINED', inskey, |
| 1466 |
& anynull, status) |
| 1467 |
call ftgcl( iunit, 2, 1, 1, nrows, larray, status) |
| 1468 |
bnul = char(98) |
| 1469 |
call ftgcvb(iunit, 3, 1, 1,nrows,bnul, xinarray,anynull,status) |
| 1470 |
call ftgcvb(iunit, 4, 1, 1,nrows,bnul, binarray,anynull,status) |
| 1471 |
inul = 98 |
| 1472 |
call ftgcvi(iunit, 5, 1, 1,nrows,inul, iinarray,anynull,status) |
| 1473 |
call ftgcvj(iunit, 6, 1, 1, nrows, 98, kinarray,anynull,status) |
| 1474 |
call ftgcve(iunit, 7, 1, 1, nrows, 98.,einarray,anynull,status) |
| 1475 |
dnul = 98. |
| 1476 |
call ftgcvd(iunit, 8, 1, 1, nrows,dnul,dinarray,anynull,status) |
| 1477 |
call ftgcvc(iunit, 9, 1, 1, nrows, 98.,cinarray,anynull,status) |
| 1478 |
call ftgcvm(iunit,10, 1, 1, nrows,dnul,minarray,anynull,status) |
| 1479 |
|
| 1480 |
write(*,'(1x,A)')' ' |
| 1481 |
write(*,'(1x,A)') 'Read columns with ftgcv_: ' |
| 1482 |
do ii = 1,nrows |
| 1483 |
jj = ichar(xinarray(ii)) |
| 1484 |
jjj = ichar(binarray(ii)) |
| 1485 |
write(*,1201)inskey(ii),larray(ii),jj,jjj,iinarray(ii), |
| 1486 |
& kinarray(ii), einarray(ii), dinarray(ii), cinarray(ii * 2 -1), |
| 1487 |
&cinarray(ii * 2 ), minarray(ii * 2 -1), minarray(ii * 2 ) |
| 1488 |
end do |
| 1489 |
1201 format(1x,a14,l4,4i4,6f5.0) |
| 1490 |
|
| 1491 |
do ii = 1, nrows |
| 1492 |
larray(ii) = .false. |
| 1493 |
xinarray(ii) = ' ' |
| 1494 |
binarray(ii) = ' ' |
| 1495 |
iinarray(ii) = 0 |
| 1496 |
kinarray(ii) = 0 |
| 1497 |
einarray(ii) = 0. |
| 1498 |
dinarray(ii) = 0. |
| 1499 |
cinarray(ii * 2 -1) = 0. |
| 1500 |
minarray(ii * 2 -1) = 0. |
| 1501 |
cinarray(ii * 2 ) = 0. |
| 1502 |
minarray(ii * 2 ) = 0. |
| 1503 |
end do |
| 1504 |
|
| 1505 |
call ftgcfs(iunit, 1, 1, 1, nrows, inskey, larray2, anynull, |
| 1506 |
& status) |
| 1507 |
C put blanks in strings if they are undefined. (contain nulls) |
| 1508 |
do ii = 1, nrows |
| 1509 |
if (larray2(ii))inskey(ii) = ' ' |
| 1510 |
end do |
| 1511 |
|
| 1512 |
call ftgcfl(iunit, 2, 1, 1, nrows, larray, larray2, anynull, |
| 1513 |
& status) |
| 1514 |
call ftgcfb(iunit, 3, 1, 1, nrows, xinarray, larray2, anynull, |
| 1515 |
& status) |
| 1516 |
call ftgcfb(iunit, 4, 1, 1, nrows, binarray, larray2, anynull, |
| 1517 |
& status) |
| 1518 |
call ftgcfi(iunit, 5, 1, 1, nrows, iinarray, larray2, anynull, |
| 1519 |
& status) |
| 1520 |
call ftgcfj(iunit, 6, 1, 1, nrows, kinarray, larray2, anynull, |
| 1521 |
& status) |
| 1522 |
call ftgcfe(iunit, 7, 1, 1, nrows, einarray, larray2, anynull, |
| 1523 |
& status) |
| 1524 |
call ftgcfd(iunit, 8, 1, 1, nrows, dinarray, larray2, anynull, |
| 1525 |
& status) |
| 1526 |
call ftgcfc(iunit, 9, 1, 1, nrows, cinarray, larray2, anynull, |
| 1527 |
& status) |
| 1528 |
call ftgcfm(iunit, 10,1, 1, nrows, minarray, larray2, anynull, |
| 1529 |
& status) |
| 1530 |
|
| 1531 |
write(*,'(1x,A)')' ' |
| 1532 |
write(*,'(1x,A)') ' Read columns with ftgcf_: ' |
| 1533 |
do ii = 1, 10 |
| 1534 |
jj = ichar(xinarray(ii)) |
| 1535 |
jjj = ichar(binarray(ii)) |
| 1536 |
write(*,1201) |
| 1537 |
& inskey(ii),larray(ii),jj,jjj,iinarray(ii), |
| 1538 |
& kinarray(ii), einarray(ii), dinarray(ii), cinarray(ii * 2 -1), |
| 1539 |
& cinarray(ii * 2 ), minarray(ii * 2 -1), minarray(ii * 2) |
| 1540 |
end do |
| 1541 |
|
| 1542 |
do ii = 11, 21 |
| 1543 |
C don't try to print the NaN values |
| 1544 |
jj = ichar(xinarray(ii)) |
| 1545 |
jjj = ichar(binarray(ii)) |
| 1546 |
write(*,1201) inskey(ii), larray(ii), jj, |
| 1547 |
& jjj, iinarray(ii) |
| 1548 |
end do |
| 1549 |
|
| 1550 |
call ftprec(iunit,'key_prec= '// |
| 1551 |
&'''This keyword was written by f_prec'' / comment here', |
| 1552 |
& status) |
| 1553 |
|
| 1554 |
C ############################################### |
| 1555 |
C # test the insert/delete row/column routines # |
| 1556 |
C ############################################### |
| 1557 |
|
| 1558 |
call ftirow(iunit, 2, 3, status) |
| 1559 |
if (status .gt. 0) go to 999 |
| 1560 |
|
| 1561 |
nrows = 14 |
| 1562 |
call ftgcvs(iunit, 1, 1, 1, nrows, 'NOT DEFINED', inskey, |
| 1563 |
& anynull, status) |
| 1564 |
call ftgcvb(iunit, 4, 1, 1, nrows,bnul,binarray,anynull,status) |
| 1565 |
call ftgcvi(iunit, 5, 1, 1, nrows,inul,iinarray,anynull,status) |
| 1566 |
call ftgcvj(iunit, 6, 1, 1, nrows, 98, jinarray,anynull,status) |
| 1567 |
call ftgcve(iunit, 7, 1, 1, nrows, 98.,einarray,anynull,status) |
| 1568 |
call ftgcvd(iunit, 8, 1, 1, nrows,dnul,dinarray,anynull,status) |
| 1569 |
|
| 1570 |
write(*,'(1x,A)')' ' |
| 1571 |
write(*,'(1x,A)')'Data values after inserting 3 rows after row 2:' |
| 1572 |
do ii = 1, nrows |
| 1573 |
jj = ichar(binarray(ii)) |
| 1574 |
write(*,1202) inskey(ii), jj, |
| 1575 |
& iinarray(ii), jinarray(ii), einarray(ii), dinarray(ii) |
| 1576 |
end do |
| 1577 |
1202 format(1x,a14,3i4,2f5.0) |
| 1578 |
|
| 1579 |
call ftdrow(iunit, 10, 2, status) |
| 1580 |
if (status .gt. 0)goto 999 |
| 1581 |
|
| 1582 |
nrows = 12 |
| 1583 |
call ftgcvs(iunit, 1, 1, 1, nrows, 'NOT DEFINED', inskey, |
| 1584 |
& anynull, status) |
| 1585 |
call ftgcvb(iunit, 4, 1, 1, nrows,bnul,binarray,anynull,status) |
| 1586 |
call ftgcvi(iunit, 5, 1, 1, nrows,inul,iinarray,anynull,status) |
| 1587 |
call ftgcvj(iunit, 6, 1, 1, nrows, 98,jinarray,anynull,status) |
| 1588 |
call ftgcve(iunit, 7, 1, 1, nrows, 98.,einarray,anynull,status) |
| 1589 |
call ftgcvd(iunit, 8, 1, 1, nrows,dnul,dinarray,anynull,status) |
| 1590 |
|
| 1591 |
write(*,'(1x,A)')' ' |
| 1592 |
write(*,'(1x,A)') 'Data values after deleting 2 rows at row 10: ' |
| 1593 |
do ii = 1, nrows |
| 1594 |
jj = ichar(binarray(ii)) |
| 1595 |
write(*,1202) inskey(ii), jj, |
| 1596 |
& iinarray(ii), jinarray(ii), einarray(ii), dinarray(ii) |
| 1597 |
end do |
| 1598 |
|
| 1599 |
call ftdcol(iunit, 6, status) |
| 1600 |
|
| 1601 |
call ftgcvs(iunit, 1, 1, 1, nrows, 'NOT DEFINED', inskey, |
| 1602 |
& anynull, status) |
| 1603 |
call ftgcvb(iunit, 4, 1, 1, nrows,bnul,binarray,anynull,status) |
| 1604 |
call ftgcvi(iunit, 5, 1, 1, nrows,inul,iinarray,anynull,status) |
| 1605 |
call ftgcve(iunit, 6, 1, 1, nrows, 98.,einarray,anynull,status) |
| 1606 |
call ftgcvd(iunit, 7, 1, 1, nrows,dnul,dinarray,anynull,status) |
| 1607 |
|
| 1608 |
write(*,'(1x,A)')' ' |
| 1609 |
write(*,'(1x,A)') 'Data values after deleting column 6: ' |
| 1610 |
do ii = 1, nrows |
| 1611 |
jj = ichar(binarray(ii)) |
| 1612 |
write(*,1203) inskey(ii), jj, |
| 1613 |
& iinarray(ii), einarray(ii), dinarray(ii) |
| 1614 |
1203 format(1x,a14,2i4,2f5.0) |
| 1615 |
|
| 1616 |
end do |
| 1617 |
call fticol(iunit, 8, 'INSERT_COL', '1E', status) |
| 1618 |
|
| 1619 |
call ftgcvs(iunit, 1, 1, 1, nrows, 'NOT DEFINED', inskey, |
| 1620 |
& anynull, status) |
| 1621 |
call ftgcvb(iunit, 4, 1, 1, nrows,bnul,binarray,anynull,status) |
| 1622 |
call ftgcvi(iunit, 5, 1, 1, nrows,inul,iinarray,anynull,status) |
| 1623 |
call ftgcve(iunit, 6, 1, 1, nrows, 98.,einarray,anynull,status) |
| 1624 |
call ftgcvd(iunit, 7, 1, 1, nrows,dnul,dinarray,anynull,status) |
| 1625 |
call ftgcvj(iunit, 8, 1, 1, nrows, 98,jinarray,anynull,status) |
| 1626 |
|
| 1627 |
write(*,'(1x,A)')' ' |
| 1628 |
write(*,'(1x,A)') 'Data values after inserting column 8: ' |
| 1629 |
do ii = 1, nrows |
| 1630 |
jj = ichar(binarray(ii)) |
| 1631 |
write(*,1204) inskey(ii), jj, |
| 1632 |
& iinarray(ii), einarray(ii), dinarray(ii) , jinarray(ii) |
| 1633 |
1204 format(1x,a14,2i4,2f5.0,i3) |
| 1634 |
end do |
| 1635 |
call ftpclu(iunit, 8, 1, 1, 10, status) |
| 1636 |
|
| 1637 |
call ftgcvs(iunit, 1, 1, 1, nrows, 'NOT DEFINED', inskey, |
| 1638 |
& anynull, status) |
| 1639 |
call ftgcvb(iunit, 4,1,1,nrows,bnul,binarray,anynull,status) |
| 1640 |
call ftgcvi(iunit, 5,1,1,nrows,inul,iinarray,anynull,status) |
| 1641 |
call ftgcve(iunit, 6,1,1,nrows,98., einarray,anynull,status) |
| 1642 |
call ftgcvd(iunit, 7,1,1,nrows,dnul, dinarray,anynull,status) |
| 1643 |
call ftgcvj(iunit, 8,1,1,nrows,98, jinarray,anynull, status) |
| 1644 |
|
| 1645 |
write(*,'(1x,A)')' ' |
| 1646 |
write(*,'(1x,A)') |
| 1647 |
& 'Values after setting 1st 10 elements in column 8 = null: ' |
| 1648 |
do ii = 1, nrows |
| 1649 |
jj = ichar(binarray(ii)) |
| 1650 |
write(*,1204) inskey(ii), jj, |
| 1651 |
& iinarray(ii), einarray(ii), dinarray(ii) , jinarray(ii) |
| 1652 |
end do |
| 1653 |
|
| 1654 |
C #################################################### |
| 1655 |
C # insert binary table following the primary array # |
| 1656 |
C #################################################### |
| 1657 |
|
| 1658 |
call ftmahd(iunit, 1, hdutype, status) |
| 1659 |
|
| 1660 |
tform(1) = '15A' |
| 1661 |
tform(2) = '1L' |
| 1662 |
tform(3) = '16X' |
| 1663 |
tform(4) = '1B' |
| 1664 |
tform(5) = '1I' |
| 1665 |
tform(6) = '1J' |
| 1666 |
tform(7) = '1E' |
| 1667 |
tform(8) = '1D' |
| 1668 |
tform(9) = '1C' |
| 1669 |
tform(10)= '1M' |
| 1670 |
|
| 1671 |
ttype(1) = 'Avalue' |
| 1672 |
ttype(2) = 'Lvalue' |
| 1673 |
ttype(3) = 'Xvalue' |
| 1674 |
ttype(4) = 'Bvalue' |
| 1675 |
ttype(5) = 'Ivalue' |
| 1676 |
ttype(6) = 'Jvalue' |
| 1677 |
ttype(7) = 'Evalue' |
| 1678 |
ttype(8) = 'Dvalue' |
| 1679 |
ttype(9) = 'Cvalue' |
| 1680 |
ttype(10)= 'Mvalue' |
| 1681 |
|
| 1682 |
tunit(1)= ' ' |
| 1683 |
tunit(2)= 'm**2' |
| 1684 |
tunit(3)= 'cm' |
| 1685 |
tunit(4)= 'erg/s' |
| 1686 |
tunit(5)= 'km/s' |
| 1687 |
tunit(6)= ' ' |
| 1688 |
tunit(7)= ' ' |
| 1689 |
tunit(8)= ' ' |
| 1690 |
tunit(9)= ' ' |
| 1691 |
tunit(10)= ' ' |
| 1692 |
|
| 1693 |
nrows = 20 |
| 1694 |
tfields = 10 |
| 1695 |
pcount = 0 |
| 1696 |
|
| 1697 |
call ftibin(iunit, nrows, tfields, ttype, tform, tunit, |
| 1698 |
& binname, pcount, status) |
| 1699 |
write(*,'(1x,A)')' ' |
| 1700 |
write(*,'(1x,A,I4)') 'ftibin status = ', status |
| 1701 |
call ftghdn(iunit, hdunum) |
| 1702 |
write(*,'(1x,A,I4)') 'HDU number = ', hdunum |
| 1703 |
|
| 1704 |
call ftpkyj(iunit, 'TNULL4', 77, |
| 1705 |
& 'value for undefined pixels', status) |
| 1706 |
call ftpkyj(iunit, 'TNULL5', 77, |
| 1707 |
& 'value for undefined pixels', status) |
| 1708 |
call ftpkyj(iunit, 'TNULL6', 77, |
| 1709 |
& 'value for undefined pixels', status) |
| 1710 |
|
| 1711 |
call ftpkyj(iunit, 'TSCAL4', 1000, 'scaling factor', status) |
| 1712 |
call ftpkyj(iunit, 'TSCAL5', 1, 'scaling factor', status) |
| 1713 |
call ftpkyj(iunit, 'TSCAL6', 100, 'scaling factor', status) |
| 1714 |
|
| 1715 |
call ftpkyj(iunit, 'TZERO4', 0, 'scaling offset', status) |
| 1716 |
call ftpkyj(iunit, 'TZERO5', 32768, 'scaling offset', status) |
| 1717 |
call ftpkyj(iunit, 'TZERO6', 100, 'scaling offset', status) |
| 1718 |
|
| 1719 |
call fttnul(iunit, 4, 77, status) |
| 1720 |
C define null value for int cols |
| 1721 |
call fttnul(iunit, 5, 77, status) |
| 1722 |
call fttnul(iunit, 6, 77, status) |
| 1723 |
|
| 1724 |
C set scaling |
| 1725 |
scale=1000. |
| 1726 |
zero = 0. |
| 1727 |
call fttscl(iunit, 4, scale, zero, status) |
| 1728 |
scale=1. |
| 1729 |
zero = 32768. |
| 1730 |
call fttscl(iunit, 5, scale, zero, status) |
| 1731 |
scale=100. |
| 1732 |
zero = 100. |
| 1733 |
call fttscl(iunit, 6, scale, zero, status) |
| 1734 |
|
| 1735 |
C for some reason, it is still necessary to call ftrdef at this point |
| 1736 |
call ftrdef(iunit,status) |
| 1737 |
|
| 1738 |
C ############################ |
| 1739 |
C # write data to columns # |
| 1740 |
C ############################ |
| 1741 |
|
| 1742 |
C initialize arrays of values to write to table |
| 1743 |
|
| 1744 |
joutarray(1) = 0 |
| 1745 |
joutarray(2) = 1000 |
| 1746 |
joutarray(3) = 10000 |
| 1747 |
joutarray(4) = 32768 |
| 1748 |
joutarray(5) = 65535 |
| 1749 |
|
| 1750 |
|
| 1751 |
do ii = 4,6 |
| 1752 |
|
| 1753 |
call ftpclj(iunit, ii, 1, 1, 5, joutarray, status) |
| 1754 |
if (status .eq. 412)then |
| 1755 |
write(*,'(1x,A,I4)') 'Overflow writing to column ', ii |
| 1756 |
status = 0 |
| 1757 |
end if |
| 1758 |
|
| 1759 |
call ftpclu(iunit, ii, 6, 1, 1, status) |
| 1760 |
C write null value |
| 1761 |
end do |
| 1762 |
|
| 1763 |
do jj = 4,6 |
| 1764 |
call ftgcvj(iunit, jj, 1,1,6, -999,jinarray,anynull,status) |
| 1765 |
write(*,'(1x,6I6)') (jinarray(ii), ii=1,6) |
| 1766 |
end do |
| 1767 |
|
| 1768 |
write(*,'(1x,A)') ' ' |
| 1769 |
|
| 1770 |
C turn off scaling, and read the unscaled values |
| 1771 |
scale = 1. |
| 1772 |
zero = 0. |
| 1773 |
call fttscl(iunit, 4, scale, zero, status) |
| 1774 |
call fttscl(iunit, 5, scale, zero, status) |
| 1775 |
call fttscl(iunit, 6, scale, zero, status) |
| 1776 |
|
| 1777 |
do jj = 4,6 |
| 1778 |
call ftgcvj(iunit, jj,1,1,6,-999,jinarray,anynull,status) |
| 1779 |
write(*,'(1x,6I6)') (jinarray(ii), ii = 1,6) |
| 1780 |
end do |
| 1781 |
|
| 1782 |
if (status .gt. 0)go to 999 |
| 1783 |
|
| 1784 |
C ###################################################### |
| 1785 |
C # insert image extension following the binary table # |
| 1786 |
C ###################################################### |
| 1787 |
|
| 1788 |
bitpix = -32 |
| 1789 |
naxis = 2 |
| 1790 |
naxes(1) = 15 |
| 1791 |
naxes(2) = 25 |
| 1792 |
call ftiimg(iunit, bitpix, naxis, naxes, status) |
| 1793 |
write(*,'(1x,A)')' ' |
| 1794 |
write(*,'(1x,A,I4)') |
| 1795 |
& ' Create image extension: ftiimg status = ', status |
| 1796 |
call ftghdn(iunit, hdunum) |
| 1797 |
write(*,'(1x,A,I4)') 'HDU number = ', hdunum |
| 1798 |
|
| 1799 |
do jj = 0,29 |
| 1800 |
do ii = 0,18 |
| 1801 |
imgarray(ii+1,jj+1) = (jj * 10) + ii |
| 1802 |
end do |
| 1803 |
end do |
| 1804 |
|
| 1805 |
call ftp2di(iunit, 1, 19, naxes(1),naxes(2),imgarray,status) |
| 1806 |
write(*,'(1x,A)') ' ' |
| 1807 |
write(*,'(1x,A,I4)')'Wrote whole 2D array: ftp2di status =', |
| 1808 |
& status |
| 1809 |
|
| 1810 |
do jj =1, 30 |
| 1811 |
do ii = 1, 19 |
| 1812 |
imgarray(ii,jj) = 0 |
| 1813 |
end do |
| 1814 |
end do |
| 1815 |
|
| 1816 |
call ftg2di(iunit,1,0,19,naxes(1),naxes(2),imgarray,anynull, |
| 1817 |
& status) |
| 1818 |
write(*,'(1x,A)')' ' |
| 1819 |
write(*,'(1x,A,I4)')'Read whole 2D array: ftg2di status =',status |
| 1820 |
|
| 1821 |
do jj =1, 30 |
| 1822 |
write (*,1301)(imgarray(ii,jj),ii=1,19) |
| 1823 |
1301 format(1x,19I4) |
| 1824 |
end do |
| 1825 |
|
| 1826 |
write(*,'(1x,A)') ' ' |
| 1827 |
|
| 1828 |
|
| 1829 |
do jj =1, 30 |
| 1830 |
do ii = 1, 19 |
| 1831 |
imgarray(ii,jj) = 0 |
| 1832 |
end do |
| 1833 |
end do |
| 1834 |
|
| 1835 |
do jj =0, 19 |
| 1836 |
do ii = 0, 9 |
| 1837 |
imgarray2(ii+1,jj+1) = (jj * (-10)) - ii |
| 1838 |
end do |
| 1839 |
end do |
| 1840 |
|
| 1841 |
fpixels(1) = 5 |
| 1842 |
fpixels(2) = 5 |
| 1843 |
lpixels(1) = 14 |
| 1844 |
lpixels(2) = 14 |
| 1845 |
call ftpssi(iunit, 1, naxis, naxes, fpixels, lpixels, |
| 1846 |
& imgarray2, status) |
| 1847 |
write(*,'(1x,A)')' ' |
| 1848 |
write(*,'(1x,A,I4)')'Wrote subset 2D array: ftpssi status =', |
| 1849 |
& status |
| 1850 |
|
| 1851 |
call ftg2di(iunit,1,0,19,naxes(1), naxes(2),imgarray,anynull, |
| 1852 |
& status) |
| 1853 |
write(*,'(1x,A)')' ' |
| 1854 |
write(*,'(1x,A,I4)')'Read whole 2D array: ftg2di status =',status |
| 1855 |
|
| 1856 |
do jj =1, 30 |
| 1857 |
write (*,1301)(imgarray(ii,jj),ii=1,19) |
| 1858 |
end do |
| 1859 |
write(*,'(1x,A)') ' ' |
| 1860 |
|
| 1861 |
|
| 1862 |
fpixels(1) = 2 |
| 1863 |
fpixels(2) = 5 |
| 1864 |
lpixels(1) = 10 |
| 1865 |
lpixels(2) = 8 |
| 1866 |
inc(1) = 2 |
| 1867 |
inc(2) = 3 |
| 1868 |
|
| 1869 |
do jj = 1,30 |
| 1870 |
do ii = 1, 19 |
| 1871 |
imgarray(ii,jj) = 0 |
| 1872 |
end do |
| 1873 |
end do |
| 1874 |
|
| 1875 |
call ftgsvi(iunit, 1, naxis, naxes, fpixels, lpixels, inc, 0, |
| 1876 |
& imgarray, anynull, status) |
| 1877 |
write(*,'(1x,A)')' ' |
| 1878 |
write(*,'(1x,A,I4)') |
| 1879 |
& 'Read subset of 2D array: ftgsvi status = ',status |
| 1880 |
|
| 1881 |
write(*,'(1x,10I5)')(imgarray(ii,1),ii = 1,10) |
| 1882 |
|
| 1883 |
|
| 1884 |
C ########################################################### |
| 1885 |
C # insert another image extension # |
| 1886 |
C # copy the image extension to primary array of tmp file. # |
| 1887 |
C # then delete the tmp file, and the image extension # |
| 1888 |
C ########################################################### |
| 1889 |
|
| 1890 |
bitpix = 16 |
| 1891 |
naxis = 2 |
| 1892 |
naxes(1) = 15 |
| 1893 |
naxes(2) = 25 |
| 1894 |
call ftiimg(iunit, bitpix, naxis, naxes, status) |
| 1895 |
write(*,'(1x,A)') ' ' |
| 1896 |
write(*,'(1x,A,I4)')'Create image extension: ftiimg status =', |
| 1897 |
& status |
| 1898 |
call ftrdef(iunit, status) |
| 1899 |
call ftghdn(iunit, hdunum) |
| 1900 |
write(*,'(1x,A,I4)') 'HDU number = ', hdunum |
| 1901 |
|
| 1902 |
|
| 1903 |
filename = 't1q2s3v4.tmp' |
| 1904 |
call ftinit(tmpunit, filename, 1, status) |
| 1905 |
write(*,'(1x,A,I4)')'Create temporary file: ftinit status = ', |
| 1906 |
& status |
| 1907 |
|
| 1908 |
call ftcopy(iunit, tmpunit, 0, status) |
| 1909 |
write(*,'(1x,A)') |
| 1910 |
& 'Copy image extension to primary array of tmp file.' |
| 1911 |
write(*,'(1x,A,I4)')'ftcopy status = ',status |
| 1912 |
|
| 1913 |
|
| 1914 |
call ftgrec(tmpunit, 1, card, status) |
| 1915 |
write(*,'(1x,A)') card |
| 1916 |
call ftgrec(tmpunit, 2, card, status) |
| 1917 |
write(*,'(1x,A)') card |
| 1918 |
call ftgrec(tmpunit, 3, card, status) |
| 1919 |
write(*,'(1x,A)') card |
| 1920 |
call ftgrec(tmpunit, 4, card, status) |
| 1921 |
write(*,'(1x,A)') card |
| 1922 |
call ftgrec(tmpunit, 5, card, status) |
| 1923 |
write(*,'(1x,A)') card |
| 1924 |
call ftgrec(tmpunit, 6, card, status) |
| 1925 |
write(*,'(1x,A)') card |
| 1926 |
|
| 1927 |
call ftdelt(tmpunit, status) |
| 1928 |
write(*,'(1x,A,I4)')'Delete the tmp file: ftdelt status =',status |
| 1929 |
call ftdhdu(iunit, hdutype, status) |
| 1930 |
write(*,'(1x,A,2I4)') |
| 1931 |
& 'Delete the image extension hdutype, status =', |
| 1932 |
& hdutype, status |
| 1933 |
call ftghdn(iunit, hdunum) |
| 1934 |
write(*,'(1x,A,I4)') 'HDU number = ', hdunum |
| 1935 |
|
| 1936 |
|
| 1937 |
C ########################################################### |
| 1938 |
C # append bintable extension with variable length columns # |
| 1939 |
C ########################################################### |
| 1940 |
|
| 1941 |
call ftcrhd(iunit, status) |
| 1942 |
write(*,'(1x,A,I4)') 'ftcrhd status = ', status |
| 1943 |
|
| 1944 |
tform(1)= '1PA' |
| 1945 |
tform(2)= '1PL' |
| 1946 |
tform(3)= '1PB' |
| 1947 |
C Fortran FITSIO doesn't support 1PX |
| 1948 |
tform(4)= '1PB' |
| 1949 |
tform(5)= '1PI' |
| 1950 |
tform(6)= '1PJ' |
| 1951 |
tform(7)= '1PE' |
| 1952 |
tform(8)= '1PD' |
| 1953 |
tform(9)= '1PC' |
| 1954 |
tform(10)= '1PM' |
| 1955 |
|
| 1956 |
ttype(1)= 'Avalue' |
| 1957 |
ttype(2)= 'Lvalue' |
| 1958 |
ttype(3)= 'Xvalue' |
| 1959 |
ttype(4)= 'Bvalue' |
| 1960 |
ttype(5)= 'Ivalue' |
| 1961 |
ttype(6)= 'Jvalue' |
| 1962 |
ttype(7)= 'Evalue' |
| 1963 |
ttype(8)= 'Dvalue' |
| 1964 |
ttype(9)= 'Cvalue' |
| 1965 |
ttype(10)= 'Mvalue' |
| 1966 |
|
| 1967 |
tunit(1)= ' ' |
| 1968 |
tunit(2)= 'm**2' |
| 1969 |
tunit(3)= 'cm' |
| 1970 |
tunit(4)= 'erg/s' |
| 1971 |
tunit(5)= 'km/s' |
| 1972 |
tunit(6)= ' ' |
| 1973 |
tunit(7)= ' ' |
| 1974 |
tunit(8)= ' ' |
| 1975 |
tunit(9)= ' ' |
| 1976 |
tunit(10)= ' ' |
| 1977 |
|
| 1978 |
nrows = 20 |
| 1979 |
tfields = 10 |
| 1980 |
pcount = 0 |
| 1981 |
|
| 1982 |
call ftphbn(iunit, nrows, tfields, ttype, tform, |
| 1983 |
& tunit, binname, pcount, status) |
| 1984 |
write(*,'(1x,A,I4)')'Variable length arrays: ftphbn status =', |
| 1985 |
& status |
| 1986 |
call ftpkyj(iunit, 'TNULL4', 88, 'value for undefined pixels', |
| 1987 |
& status) |
| 1988 |
call ftpkyj(iunit, 'TNULL5', 88, 'value for undefined pixels', |
| 1989 |
& status) |
| 1990 |
call ftpkyj(iunit, 'TNULL6', 88, 'value for undefined pixels', |
| 1991 |
& status) |
| 1992 |
|
| 1993 |
C ############################ |
| 1994 |
C # write data to columns # |
| 1995 |
C ############################ |
| 1996 |
|
| 1997 |
C initialize arrays of values to write to table |
| 1998 |
iskey='abcdefghijklmnopqrst' |
| 1999 |
|
| 2000 |
do ii = 1, 20 |
| 2001 |
|
| 2002 |
boutarray(ii) = char(ii) |
| 2003 |
ioutarray(ii) = ii |
| 2004 |
joutarray(ii) = ii |
| 2005 |
eoutarray(ii) = ii |
| 2006 |
doutarray(ii) = ii |
| 2007 |
end do |
| 2008 |
|
| 2009 |
larray(1) = .false. |
| 2010 |
larray(2) = .true. |
| 2011 |
larray(3) = .false. |
| 2012 |
larray(4) = .false. |
| 2013 |
larray(5) = .true. |
| 2014 |
larray(6) = .true. |
| 2015 |
larray(7) = .false. |
| 2016 |
larray(8) = .false. |
| 2017 |
larray(9) = .false. |
| 2018 |
larray(10) = .true. |
| 2019 |
larray(11) = .true. |
| 2020 |
larray(12) = .true. |
| 2021 |
larray(13) = .false. |
| 2022 |
larray(14) = .false. |
| 2023 |
larray(15) = .false. |
| 2024 |
larray(16) = .false. |
| 2025 |
larray(17) = .true. |
| 2026 |
larray(18) = .true. |
| 2027 |
larray(19) = .true. |
| 2028 |
larray(20) = .true. |
| 2029 |
|
| 2030 |
C inskey(1) = iskey(1:1) |
| 2031 |
inskey(1) = ' ' |
| 2032 |
|
| 2033 |
call ftpcls(iunit, 1, 1, 1, 1, inskey, status) |
| 2034 |
C write string values |
| 2035 |
call ftpcll(iunit, 2, 1, 1, 1, larray, status) |
| 2036 |
C write logicals |
| 2037 |
call ftpclx(iunit, 3, 1, 1, 1, larray, status) |
| 2038 |
C write bits |
| 2039 |
call ftpclb(iunit, 4, 1, 1, 1, boutarray, status) |
| 2040 |
call ftpcli(iunit, 5, 1, 1, 1, ioutarray, status) |
| 2041 |
call ftpclj(iunit, 6, 1, 1, 1, joutarray, status) |
| 2042 |
call ftpcle(iunit, 7, 1, 1, 1, eoutarray, status) |
| 2043 |
call ftpcld(iunit, 8, 1, 1, 1, doutarray, status) |
| 2044 |
|
| 2045 |
do ii = 2, 20 |
| 2046 |
C loop over rows 1 - 20 |
| 2047 |
|
| 2048 |
inskey(1) = iskey(1:ii) |
| 2049 |
call ftpcls(iunit, 1, ii, 1, ii, inskey, status) |
| 2050 |
C write string values |
| 2051 |
|
| 2052 |
call ftpcll(iunit, 2, ii, 1, ii, larray, status) |
| 2053 |
C write logicals |
| 2054 |
call ftpclu(iunit, 2, ii, ii-1, 1, status) |
| 2055 |
|
| 2056 |
call ftpclx(iunit, 3, ii, 1, ii, larray, status) |
| 2057 |
C write bits |
| 2058 |
|
| 2059 |
call ftpclb(iunit, 4, ii, 1, ii, boutarray, status) |
| 2060 |
call ftpclu(iunit, 4, ii, ii-1, 1, status) |
| 2061 |
|
| 2062 |
call ftpcli(iunit, 5, ii, 1, ii, ioutarray, status) |
| 2063 |
call ftpclu(iunit, 5, ii, ii-1, 1, status) |
| 2064 |
|
| 2065 |
call ftpclj(iunit, 6, ii, 1, ii, joutarray, status) |
| 2066 |
call ftpclu(iunit, 6, ii, ii-1, 1, status) |
| 2067 |
|
| 2068 |
call ftpcle(iunit, 7, ii, 1, ii, eoutarray, status) |
| 2069 |
call ftpclu(iunit, 7, ii, ii-1, 1, status) |
| 2070 |
|
| 2071 |
call ftpcld(iunit, 8, ii, 1, ii, doutarray, status) |
| 2072 |
call ftpclu(iunit, 8, ii, ii-1, 1, status) |
| 2073 |
end do |
| 2074 |
|
| 2075 |
C it is no longer necessary to update the PCOUNT keyword; |
| 2076 |
C FITSIO now does this automatically when the HDU is closed. |
| 2077 |
C call ftmkyj(iunit,'PCOUNT',4446, '&',status) |
| 2078 |
write(*,'(1x,A,I4)') 'ftpcl_ status = ', status |
| 2079 |
|
| 2080 |
C ################################# |
| 2081 |
C # close then reopen this HDU # |
| 2082 |
C ################################# |
| 2083 |
|
| 2084 |
call ftmrhd(iunit, -1, hdutype, status) |
| 2085 |
call ftmrhd(iunit, 1, hdutype, status) |
| 2086 |
|
| 2087 |
C ############################# |
| 2088 |
C # read data from columns # |
| 2089 |
C ############################# |
| 2090 |
|
| 2091 |
|
| 2092 |
call ftgkyj(iunit, 'PCOUNT', pcount, comm, status) |
| 2093 |
write(*,'(1x,A,I4)') 'PCOUNT = ', pcount |
| 2094 |
|
| 2095 |
C initialize the variables to be read |
| 2096 |
inskey(1) =' ' |
| 2097 |
iskey = ' ' |
| 2098 |
|
| 2099 |
do jj = 1, ii |
| 2100 |
larray(jj) = .false. |
| 2101 |
boutarray(jj) = char(0) |
| 2102 |
ioutarray(jj) = 0 |
| 2103 |
joutarray(jj) = 0 |
| 2104 |
eoutarray(jj) = 0 |
| 2105 |
doutarray(jj) = 0 |
| 2106 |
end do |
| 2107 |
|
| 2108 |
call ftghdn(iunit, hdunum) |
| 2109 |
write(*,'(1x,A,I4)') 'HDU number = ', hdunum |
| 2110 |
|
| 2111 |
do ii = 1, 20 |
| 2112 |
C loop over rows 1 - 20 |
| 2113 |
|
| 2114 |
do jj = 1, ii |
| 2115 |
larray(jj) = .false. |
| 2116 |
boutarray(jj) = char(0) |
| 2117 |
ioutarray(jj) = 0 |
| 2118 |
joutarray(jj) = 0 |
| 2119 |
eoutarray(jj) = 0 |
| 2120 |
doutarray(jj) = 0 |
| 2121 |
end do |
| 2122 |
|
| 2123 |
call ftgcvs(iunit, 1, ii, 1,1,iskey,inskey,anynull,status) |
| 2124 |
write(*,'(1x,2A,I4)') 'A ', inskey(1), status |
| 2125 |
|
| 2126 |
call ftgcl( iunit, 2, ii, 1, ii, larray, status) |
| 2127 |
write(*,1400)'L',status,(larray(jj),jj=1,ii) |
| 2128 |
1400 format(1x,a1,i3,20l3) |
| 2129 |
1401 format(1x,a1,21i3) |
| 2130 |
|
| 2131 |
call ftgcx(iunit, 3, ii, 1, ii, larray, status) |
| 2132 |
write(*,1400)'X',status,(larray(jj),jj=1,ii) |
| 2133 |
|
| 2134 |
bnul = char(99) |
| 2135 |
call ftgcvb(iunit, 4, ii, 1,ii,bnul,boutarray,anynull,status) |
| 2136 |
do jj = 1,ii |
| 2137 |
jinarray(jj) = ichar(boutarray(jj)) |
| 2138 |
end do |
| 2139 |
write(*,1401)'B',(jinarray(jj),jj=1,ii),status |
| 2140 |
|
| 2141 |
inul = 99 |
| 2142 |
call ftgcvi(iunit, 5, ii, 1,ii,inul,ioutarray,anynull,status) |
| 2143 |
write(*,1401)'I',(ioutarray(jj),jj=1,ii),status |
| 2144 |
|
| 2145 |
call ftgcvj(iunit, 6, ii, 1, ii,99,joutarray,anynull,status) |
| 2146 |
write(*,1401)'J',(joutarray(jj),jj=1,ii),status |
| 2147 |
|
| 2148 |
call ftgcve(iunit, 7, ii, 1,ii,99.,eoutarray,anynull,status) |
| 2149 |
estatus=status |
| 2150 |
write(*,1402)'E',(eoutarray(jj),jj=1,ii),estatus |
| 2151 |
1402 format(1x,a1,1x,21f3.0) |
| 2152 |
|
| 2153 |
dnul = 99. |
| 2154 |
call ftgcvd(iunit, 8, ii,1,ii,dnul,doutarray,anynull,status) |
| 2155 |
estatus=status |
| 2156 |
write(*,1402)'D',(doutarray(jj),jj=1,ii),estatus |
| 2157 |
|
| 2158 |
call ftgdes(iunit, 8, ii, repeat, offset, status) |
| 2159 |
write(*,'(1x,A,2I5)')'Column 8 repeat and offset =', |
| 2160 |
& repeat,offset |
| 2161 |
end do |
| 2162 |
|
| 2163 |
C ##################################### |
| 2164 |
C # create another image extension # |
| 2165 |
C ##################################### |
| 2166 |
|
| 2167 |
|
| 2168 |
bitpix = 32 |
| 2169 |
naxis = 2 |
| 2170 |
naxes(1) = 10 |
| 2171 |
naxes(2) = 2 |
| 2172 |
npixels = 20 |
| 2173 |
|
| 2174 |
call ftiimg(iunit, bitpix, naxis, naxes, status) |
| 2175 |
write(*,'(1x,A)')' ' |
| 2176 |
write(*,'(1x,A,I4)')'Create image extension: ftiimg status =', |
| 2177 |
& status |
| 2178 |
|
| 2179 |
C initialize arrays of values to write to primary array |
| 2180 |
do ii = 1, npixels |
| 2181 |
boutarray(ii) = char(ii * 2 -2) |
| 2182 |
ioutarray(ii) = ii * 2 -2 |
| 2183 |
joutarray(ii) = ii * 2 -2 |
| 2184 |
koutarray(ii) = ii * 2 -2 |
| 2185 |
eoutarray(ii) = ii * 2 -2 |
| 2186 |
doutarray(ii) = ii * 2 -2 |
| 2187 |
end do |
| 2188 |
|
| 2189 |
C write a few pixels with each datatype |
| 2190 |
call ftpprb(iunit, 1, 1, 2, boutarray(1), status) |
| 2191 |
call ftppri(iunit, 1, 3, 2, ioutarray(3), status) |
| 2192 |
call ftpprj(iunit, 1, 5, 2, koutarray(5), status) |
| 2193 |
call ftppri(iunit, 1, 7, 2, ioutarray(7), status) |
| 2194 |
call ftpprj(iunit, 1, 9, 2, joutarray(9), status) |
| 2195 |
call ftppre(iunit, 1, 11, 2, eoutarray(11), status) |
| 2196 |
call ftpprd(iunit, 1, 13, 2, doutarray(13), status) |
| 2197 |
write(*,'(1x,A,I4)') 'ftppr status = ', status |
| 2198 |
|
| 2199 |
|
| 2200 |
C read back the pixels with each datatype |
| 2201 |
bnul = char(0) |
| 2202 |
inul = 0 |
| 2203 |
knul = 0 |
| 2204 |
jnul = 0 |
| 2205 |
enul = 0. |
| 2206 |
dnul = 0. |
| 2207 |
|
| 2208 |
call ftgpvb(iunit, 1, 1, 14, bnul, binarray, anynull, status) |
| 2209 |
call ftgpvi(iunit, 1, 1, 14, inul, iinarray, anynull, status) |
| 2210 |
call ftgpvj(iunit, 1, 1, 14, knul, kinarray, anynull, status) |
| 2211 |
call ftgpvj(iunit, 1, 1, 14, jnul, jinarray, anynull, status) |
| 2212 |
call ftgpve(iunit, 1, 1, 14, enul, einarray, anynull, status) |
| 2213 |
call ftgpvd(iunit, 1, 1, 14, dnul, dinarray, anynull, status) |
| 2214 |
|
| 2215 |
write(*,'(1x,A)')' ' |
| 2216 |
write(*,'(1x,A)') |
| 2217 |
& 'Image values written with ftppr and read with ftgpv:' |
| 2218 |
npixels = 14 |
| 2219 |
do jj = 1,ii |
| 2220 |
joutarray(jj) = ichar(binarray(jj)) |
| 2221 |
end do |
| 2222 |
|
| 2223 |
write(*,1501)(joutarray(ii),ii=1,npixels),anynull,'(byte)' |
| 2224 |
1501 format(1x,14i3,l3,1x,a) |
| 2225 |
write(*,1501)(iinarray(ii),ii=1,npixels),anynull,'(short)' |
| 2226 |
write(*,1501)(kinarray(ii),ii=1,npixels),anynull,'(int)' |
| 2227 |
write(*,1501)(jinarray(ii),ii=1,npixels),anynull,'(long)' |
| 2228 |
write(*,1502)(einarray(ii),ii=1,npixels),anynull,'(float)' |
| 2229 |
write(*,1502)(dinarray(ii),ii=1,npixels),anynull,'(double)' |
| 2230 |
1502 format(2x,14f3.0,l2,1x,a) |
| 2231 |
|
| 2232 |
C ########################################## |
| 2233 |
C # test world coordinate system routines # |
| 2234 |
C ########################################## |
| 2235 |
|
| 2236 |
xrval = 45.83D+00 |
| 2237 |
yrval = 63.57D+00 |
| 2238 |
xrpix = 256.D+00 |
| 2239 |
yrpix = 257.D+00 |
| 2240 |
xinc = -.00277777D+00 |
| 2241 |
yinc = .00277777D+00 |
| 2242 |
|
| 2243 |
C write the WCS keywords |
| 2244 |
C use example values from the latest WCS document |
| 2245 |
call ftpkyd(iunit, 'CRVAL1', xrval, 10, 'comment', status) |
| 2246 |
call ftpkyd(iunit, 'CRVAL2', yrval, 10, 'comment', status) |
| 2247 |
call ftpkyd(iunit, 'CRPIX1', xrpix, 10, 'comment', status) |
| 2248 |
call ftpkyd(iunit, 'CRPIX2', yrpix, 10, 'comment', status) |
| 2249 |
call ftpkyd(iunit, 'CDELT1', xinc, 10, 'comment', status) |
| 2250 |
call ftpkyd(iunit, 'CDELT2', yinc, 10, 'comment', status) |
| 2251 |
C call ftpkyd(iunit, 'CROTA2', rot, 10, 'comment', status) |
| 2252 |
call ftpkys(iunit, 'CTYPE1', xctype, 'comment', status) |
| 2253 |
call ftpkys(iunit, 'CTYPE2', yctype, 'comment', status) |
| 2254 |
write(*,'(1x,A)')' ' |
| 2255 |
write(*,'(1x,A,I4)')'Wrote WCS keywords status =', status |
| 2256 |
|
| 2257 |
C reset value, to make sure they are reread correctly |
| 2258 |
xrval = 0.D+00 |
| 2259 |
yrval = 0.D+00 |
| 2260 |
xrpix = 0.D+00 |
| 2261 |
yrpix = 0.D+00 |
| 2262 |
xinc = 0.D+00 |
| 2263 |
yinc = 0.D+00 |
| 2264 |
rot = 67.D+00 |
| 2265 |
|
| 2266 |
call ftgics(iunit, xrval, yrval, xrpix, |
| 2267 |
& yrpix, xinc, yinc, rot, ctype, status) |
| 2268 |
write(*,'(1x,A,I4)')'Read WCS keywords with ftgics status =', |
| 2269 |
& status |
| 2270 |
|
| 2271 |
xpix = 0.5D+00 |
| 2272 |
ypix = 0.5D+00 |
| 2273 |
|
| 2274 |
call ftwldp(xpix,ypix,xrval,yrval,xrpix,yrpix,xinc,yinc, |
| 2275 |
& rot,ctype, xpos, ypos,status) |
| 2276 |
|
| 2277 |
write(*,'(1x,A,2f8.3)')' CRVAL1, CRVAL2 =', xrval,yrval |
| 2278 |
write(*,'(1x,A,2f8.3)')' CRPIX1, CRPIX2 =', xrpix,yrpix |
| 2279 |
write(*,'(1x,A,2f12.8)')' CDELT1, CDELT2 =', xinc,yinc |
| 2280 |
write(*,'(1x,A,f8.3,2A)')' Rotation =',rot,' CTYPE =',ctype |
| 2281 |
write(*,'(1x,A,I4)')'Calculated sky coord. with ftwldp status =', |
| 2282 |
& status |
| 2283 |
write(*,6501)xpix,ypix,xpos,ypos |
| 2284 |
6501 format(' Pixels (',f10.6,f10.6,') --> (',f10.6,f10.6,') Sky') |
| 2285 |
|
| 2286 |
call ftxypx(xpos,ypos,xrval,yrval,xrpix,yrpix,xinc,yinc, |
| 2287 |
& rot,ctype, xpix, ypix,status) |
| 2288 |
write(*,'(1x,A,I4)') |
| 2289 |
& 'Calculated pixel coord. with ftxypx status =', status |
| 2290 |
write(*,6502)xpos,ypos,xpix,ypix |
| 2291 |
6502 format(' Sky (',f10.6,f10.6,') --> (',f10.6,f10.6,') Pixels') |
| 2292 |
|
| 2293 |
|
| 2294 |
C ###################################### |
| 2295 |
C # append another ASCII table # |
| 2296 |
C ###################################### |
| 2297 |
|
| 2298 |
|
| 2299 |
tform(1)= 'A15' |
| 2300 |
tform(2)= 'I11' |
| 2301 |
tform(3)= 'F15.6' |
| 2302 |
tform(4)= 'E13.5' |
| 2303 |
tform(5)= 'D22.14' |
| 2304 |
|
| 2305 |
tbcol(1)= 1 |
| 2306 |
tbcol(2)= 17 |
| 2307 |
tbcol(3)= 29 |
| 2308 |
tbcol(4)= 45 |
| 2309 |
tbcol(5)= 59 |
| 2310 |
rowlen = 80 |
| 2311 |
|
| 2312 |
ttype(1)= 'Name' |
| 2313 |
ttype(2)= 'Ivalue' |
| 2314 |
ttype(3)= 'Fvalue' |
| 2315 |
ttype(4)= 'Evalue' |
| 2316 |
ttype(5)= 'Dvalue' |
| 2317 |
|
| 2318 |
tunit(1)= ' ' |
| 2319 |
tunit(2)= 'm**2' |
| 2320 |
tunit(3)= 'cm' |
| 2321 |
tunit(4)= 'erg/s' |
| 2322 |
tunit(5)= 'km/s' |
| 2323 |
|
| 2324 |
nrows = 11 |
| 2325 |
tfields = 5 |
| 2326 |
tblname = 'new_table' |
| 2327 |
|
| 2328 |
call ftitab(iunit, rowlen, nrows, tfields, ttype, tbcol, |
| 2329 |
& tform, tunit, tblname, status) |
| 2330 |
write(*,'(1x,A)') ' ' |
| 2331 |
write(*,'(1x,A,I4)') 'ftitab status = ', status |
| 2332 |
|
| 2333 |
call ftpcls(iunit, 1, 1, 1, 3, onskey, status) |
| 2334 |
C write string values |
| 2335 |
|
| 2336 |
C initialize arrays of values to write to primary array |
| 2337 |
|
| 2338 |
do ii = 1,npixels |
| 2339 |
boutarray(ii) = char(ii * 3 -3) |
| 2340 |
ioutarray(ii) = ii * 3 -3 |
| 2341 |
joutarray(ii) = ii * 3 -3 |
| 2342 |
koutarray(ii) = ii * 3 -3 |
| 2343 |
eoutarray(ii) = ii * 3 -3 |
| 2344 |
doutarray(ii) = ii * 3 -3 |
| 2345 |
end do |
| 2346 |
|
| 2347 |
do ii = 2,5 |
| 2348 |
C loop over cols 2 - 5 |
| 2349 |
|
| 2350 |
call ftpclb(iunit, ii, 1, 1, 2, boutarray, status) |
| 2351 |
call ftpcli(iunit, ii, 3, 1, 2,ioutarray(3),status) |
| 2352 |
call ftpclj(iunit, ii, 5, 1, 2,joutarray(5),status) |
| 2353 |
call ftpcle(iunit, ii, 7, 1, 2,eoutarray(7),status) |
| 2354 |
call ftpcld(iunit, ii, 9, 1, 2,doutarray(9),status) |
| 2355 |
end do |
| 2356 |
write(*,'(1x,A,I4)') 'ftpcl status = ', status |
| 2357 |
|
| 2358 |
C read back the pixels with each datatype |
| 2359 |
call ftgcvb(iunit, 2, 1, 1, 10, bnul, binarray,anynull, |
| 2360 |
& status) |
| 2361 |
call ftgcvi(iunit, 2, 1, 1, 10, inul, iinarray,anynull, |
| 2362 |
& status) |
| 2363 |
call ftgcvj(iunit, 3, 1, 1, 10, knul, kinarray,anynull, |
| 2364 |
& status) |
| 2365 |
call ftgcvj(iunit, 3, 1, 1, 10, jnul, jinarray,anynull, |
| 2366 |
& status) |
| 2367 |
call ftgcve(iunit, 4, 1, 1, 10, enul, einarray,anynull, |
| 2368 |
& status) |
| 2369 |
call ftgcvd(iunit, 5, 1, 1, 10, dnul, dinarray,anynull, |
| 2370 |
& status) |
| 2371 |
|
| 2372 |
write(*,'(1x,A)') |
| 2373 |
&'Column values written with ftpcl and read with ftgcl: ' |
| 2374 |
npixels = 10 |
| 2375 |
do ii = 1,npixels |
| 2376 |
joutarray(ii) = ichar(binarray(ii)) |
| 2377 |
end do |
| 2378 |
write(*,1601)(joutarray(ii),ii = 1, npixels),anynull,'(byte) ' |
| 2379 |
write(*,1601)(iinarray(ii),ii = 1, npixels),anynull,'(short) ' |
| 2380 |
write(*,1601)(kinarray(ii),ii = 1, npixels),anynull,'(int) ' |
| 2381 |
write(*,1601)(jinarray(ii),ii = 1, npixels),anynull,'(long) ' |
| 2382 |
write(*,1602)(einarray(ii),ii = 1, npixels),anynull,'(float) ' |
| 2383 |
write(*,1602)(dinarray(ii),ii = 1, npixels),anynull,'(double) ' |
| 2384 |
1601 format(1x,10i3,l3,1x,a) |
| 2385 |
1602 format(2x,10f3.0,l2,1x,a) |
| 2386 |
|
| 2387 |
C ########################################################### |
| 2388 |
C # perform stress test by cycling thru all the extensions # |
| 2389 |
C ########################################################### |
| 2390 |
write(*,'(1x,A)')' ' |
| 2391 |
write(*,'(1x,A)')'Repeatedly move to the 1st 4 HDUs of the file: ' |
| 2392 |
|
| 2393 |
do ii = 1,10 |
| 2394 |
call ftmahd(iunit, 1, hdutype, status) |
| 2395 |
call ftghdn(iunit, hdunum) |
| 2396 |
call ftmrhd(iunit, 1, hdutype, status) |
| 2397 |
call ftghdn(iunit, hdunum) |
| 2398 |
call ftmrhd(iunit, 1, hdutype, status) |
| 2399 |
call ftghdn(iunit, hdunum) |
| 2400 |
call ftmrhd(iunit, 1, hdutype, status) |
| 2401 |
call ftghdn(iunit, hdunum) |
| 2402 |
call ftmrhd(iunit, -1, hdutype, status) |
| 2403 |
call ftghdn(iunit, hdunum) |
| 2404 |
if (status .gt. 0) go to 999 |
| 2405 |
end do |
| 2406 |
|
| 2407 |
write(*,'(1x,A)') ' ' |
| 2408 |
|
| 2409 |
checksum = 1234567890.D+00 |
| 2410 |
call ftesum(checksum, .false., asciisum) |
| 2411 |
write(*,'(1x,A,F13.1,2A)')'Encode checksum: ',checksum,' -> ', |
| 2412 |
& asciisum |
| 2413 |
checksum = 0 |
| 2414 |
call ftdsum(asciisum, 0, checksum) |
| 2415 |
write(*,'(1x,3A,F13.1)') 'Decode checksum: ',asciisum,' -> ', |
| 2416 |
& checksum |
| 2417 |
|
| 2418 |
call ftpcks(iunit, status) |
| 2419 |
|
| 2420 |
C don't print the CHECKSUM value because it is different every day |
| 2421 |
C because the current date is in the comment field. |
| 2422 |
|
| 2423 |
call ftgcrd(iunit, 'CHECKSUM', card, status) |
| 2424 |
C write(*,'(1x,A)') card |
| 2425 |
|
| 2426 |
call ftgcrd(iunit, 'DATASUM', card, status) |
| 2427 |
write(*,'(1x,A)') card(1:22) |
| 2428 |
|
| 2429 |
call ftgcks(iunit, datsum, checksum, status) |
| 2430 |
write(*,'(1x,A,F13.1,I4)') 'ftgcks data checksum, status = ', |
| 2431 |
& datsum, status |
| 2432 |
|
| 2433 |
call ftvcks(iunit, datastatus, hdustatus, status) |
| 2434 |
write(*,'(1x,A,3I4)')'ftvcks datastatus, hdustatus, status = ', |
| 2435 |
& datastatus, hdustatus, status |
| 2436 |
|
| 2437 |
call ftprec(iunit, |
| 2438 |
& 'new_key = ''written by fxprec'' / to change checksum',status) |
| 2439 |
call ftucks(iunit, status) |
| 2440 |
write(*,'(1x,A,I4)') 'ftupck status = ', status |
| 2441 |
|
| 2442 |
call ftgcrd(iunit, 'DATASUM', card, status) |
| 2443 |
write(*,'(1x,A)') card(1:22) |
| 2444 |
call ftvcks(iunit, datastatus, hdustatus, status) |
| 2445 |
write(*,'(1x,A,3I4)') 'ftvcks datastatus, hdustatus, status = ', |
| 2446 |
& datastatus, hdustatus, status |
| 2447 |
|
| 2448 |
C delete the checksum keywords, so that the FITS file is always |
| 2449 |
C the same, regardless of the date of when testprog is run. |
| 2450 |
|
| 2451 |
call ftdkey(iunit, 'CHECKSUM', status) |
| 2452 |
call ftdkey(iunit, 'DATASUM', status) |
| 2453 |
|
| 2454 |
|
| 2455 |
C ############################ |
| 2456 |
C # close file and quit # |
| 2457 |
C ############################ |
| 2458 |
|
| 2459 |
|
| 2460 |
999 continue |
| 2461 |
C jump here on error |
| 2462 |
|
| 2463 |
call ftclos(iunit, status) |
| 2464 |
write(*,'(1x,A,I4)') 'ftclos status = ', status |
| 2465 |
write(*,'(1x,A)')' ' |
| 2466 |
|
| 2467 |
write(*,'(1x,A)') |
| 2468 |
& 'Normally, there should be 8 error messages on the' |
| 2469 |
write(*,'(1x,A)') 'stack all regarding ''numerical overflows'':' |
| 2470 |
|
| 2471 |
call ftgmsg(errmsg) |
| 2472 |
nmsg = 0 |
| 2473 |
|
| 2474 |
998 continue |
| 2475 |
if (errmsg .ne. ' ')then |
| 2476 |
write(*,'(1x,A)') errmsg |
| 2477 |
nmsg = nmsg + 1 |
| 2478 |
call ftgmsg(errmsg) |
| 2479 |
go to 998 |
| 2480 |
end if |
| 2481 |
|
| 2482 |
if (nmsg .ne. 8)write(*,'(1x,A)') |
| 2483 |
& ' WARNING: Did not find the expected 8 error messages!' |
| 2484 |
|
| 2485 |
call ftgerr(status, errmsg) |
| 2486 |
write(*,'(1x,A)')' ' |
| 2487 |
write(*,'(1x,A,I4,2A)') 'Status =', status,': ', errmsg(1:50) |
| 2488 |
end |