Skip to content

Commit c1d6eb5

Browse files
authored
Merge pull request #13 from csiro/fits-regrid-maxdim-fixes
Some small fixes to fits and regrid. Generalise maxdim parameter handling - move all to CMakeLists.txt
2 parents 39d7d30 + a113b35 commit c1d6eb5

5 files changed

Lines changed: 45 additions & 39 deletions

File tree

CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,20 @@ if(LARGEN)
2929
set(MAXCHAN 4096)
3030
set(MAXAVER 20000000)
3131
set(MAXWIN 16)
32-
set(MAXWIDE 18)
3332
set(MAXSRC 36)
3433
else()
3534
set(MAXBUF 1024*1024*32)
3635
set(MAXANT 50)
3736
set(MAXCHAN 70000)
3837
set(MAXAVER 2000000)
3938
set(MAXWIN 60)
40-
set(MAXWIDE 18)
4139
set(MAXSRC 1024)
4240
endif()
41+
set(MAXDIM 65536)
42+
set(MAXWIDE 18)
43+
set(MAXFBIN 16)
44+
set(MAXPNT 20000)
45+
4346
set(MIRROOT ${CMAKE_INSTALL_PREFIX})
4447

4548
# Preprocessing flags

inc/maxdim.h.in

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,18 @@
11
C=======================================================================
22
C-----------------------------------------------------------------------
33
C Size of an INTEGER array used to implement a memory heap. This
4-
C array is the sole variable in blank COMMON in Miriad. Trial-and-
5-
C error compilations on an x86-64 system with gcc/g77 show that the
6-
C limit on MAXBUF for which most tasks build successfully is
7-
C 1073741823 (2**30 - 1) which corresponds to 4GiB. With MAXDIM
8-
C less than 32768 the limit for which all tasks build successfully
9-
C is about 260000000; unsuccessful links produce messages about
10-
C truncated relocations, imom being the worst offender.
4+
C array is the sole variable in blank COMMON in Miriad.
115
C The default value allocates 128MiB (for normal 4-byte INTEGERs).
126
INTEGER MAXBUF
137
PARAMETER(MAXBUF = @MAXBUF@)
148

159
C Maximum image axis length. Array dimensions are typically a few
1610
C times MAXDIM (never MAXDIM**2) so MAXDIM is associated with a much
17-
C smaller allocation of static memory than MAXBUF. Thus the default
18-
C value of MAXDIM is quite generous.
19-
C The current value of MAXDIM is the largest value that keeps the
20-
C memory allocation to store a single image plane below the current
21-
C limit of 8GB. Note that invert is limited to 32768, the highest
22-
C power of 2 below the limit.
11+
C smaller allocation of static memory than MAXBUF.
2312
INTEGER MAXDIM
24-
PARAMETER(MAXDIM = 32768)
13+
PARAMETER(MAXDIM = @MAXDIM@)
2514

26-
C Maximum number of antennas (ATA=64).
15+
C Maximum number of antennas.
2716
INTEGER MAXANT
2817
PARAMETER(MAXANT = @MAXANT@)
2918

@@ -45,9 +34,9 @@ C Maximum number of wideband channels.
4534

4635
C Maximum number of frequency bins in gains table
4736
INTEGER MAXFBIN
48-
PARAMETER(MAXFBIN = 16)
37+
PARAMETER(MAXFBIN = @MAXFBIN@)
4938

5039
C Maximum number of mosaic pointings
5140
INTEGER MAXPNT
52-
PARAMETER(MAXPNT = 20000)
41+
PARAMETER(MAXPNT = @MAXPNT@)
5342
C=======================================================================

inc/maxdimc.h.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#define MAXBUF 16777216
2626

2727
/* Maximum number of pixels on an image axis. */
28-
#define MAXDIM 32768
28+
#define MAXDIM @MAXDIM@
2929

3030
/* Maximum number of image axes. */
3131
#define MAXNAX 7
@@ -46,4 +46,4 @@
4646
#define MAXWIDE @MAXWIDE@
4747

4848
/* Maximum number of mosaic pointings. */
49-
#define MAXPNT 20000
49+
#define MAXPNT @MAXPNT@

src/prog/fits.for

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1652,8 +1652,6 @@ c
16521652
call output(' Using antenna table information')
16531653
nconfig = nconfig + 1
16541654
call ftabInfo(lu,'STABXYZ',type,units,n,nxyz)
1655-
if (nconfig.gt.MAXCONFG)
1656-
* call bug('f','Too many array configurations')
16571655
if (nxyz.ne.3 .or. n.le.0 .or. type.ne.'D')
16581656
* call bug('f','Something is screwy with the antenna table')
16591657
if (n.gt.MAXANT) call bug('f','Too many antennas for me')
@@ -1728,6 +1726,10 @@ c
17281726
emok = emok .and. .not.badmnt
17291727

17301728
call ftabNxt(lu,'AIPS AN',found)
1729+
if (nconfig.ge.MAXCONFG) then
1730+
call bug('w','Too many array configurations')
1731+
found = .false.
1732+
endif
17311733
enddo
17321734
c
17331735
c If no antenna table was found, try for an OB table!

src/prog/regrid.for

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ c (WCS) standard as defined in "WCS Paper II",
2525
c Calabretta & Greisen (2002), A&A 395, 1077.
2626
c@ in
2727
c The input image name. In the first instance, coordinate
28-
c descriptors for the output image are copied from the input.
28+
c descriptors for the output image are copied from the input.
2929
c They may then be overridden by other parameters as described
3030
c below. No default.
3131
c@ out
@@ -130,7 +130,7 @@ c AIR Airy (1,D)
130130
c Cylindricals:
131131
c CYP Cylindrical perspective (2,G|D)
132132
c CEA Cylindrical equal area (1,E,G)
133-
c CAR Plate carrée (aka Cartesian) (0,G) - please note that
133+
c CAR Plate Carrée (aka Cartesian) (0,G) - please note that
134134
c this is NOT the same as the simple linear system used
135135
c previously unless the reference coordinates (CRVAL)
136136
c are (0,0)
@@ -200,7 +200,7 @@ c@ options
200200
c Extra processing options that alter the axis description defined
201201
c by the template image, axis descriptors, or input image.
202202
c Several can be given, separated by commas, with minimum-match.
203-
c altprj Interpret a CAR (plate carée) projection in the
203+
c altprj Interpret a CAR (Plate Carrée) projection in the
204204
c input ot template image as a simple linear
205205
c coordinate system with an additional 1/cos(lat0)
206206
c scaling factor applied when computing the longitude,
@@ -232,6 +232,11 @@ c@ tol
232232
c Interpolation tolerance. Tolerate an error of the specified
233233
c amount in converting pixel locations in the input to the output.
234234
c Must be less that 0.5. The default is 0.05.
235+
c@ div
236+
c Number of divisions of the coordinate axes to use with offset
237+
c option. Some projections, like TAN, require finer division near
238+
c discontinuities. Default is 10 on first 3 axes. Suggested
239+
c maximum: 200. Specify up to 3 values.
235240
c
236241
c--
237242
c History:
@@ -255,7 +260,7 @@ c-----------------------------------------------------------------------
255260
* maxc(3), maxv(3), minc(3), minv(3), n, naxes,
256261
* nAxIn(MAXNAX), nAxOut(MAXNAX), nAxTem(MAXNAX), nblank,
257262
* nBuf(3), ndesc, nIAxes, npv, nTAxes, nxy, off(3),
258-
* offset, order(3), xyzero
263+
* offset, order(3), xyzero, div(3), ndiv
259264
ptrdiff xv, yv, zv, valid, rBuf, lBuf
260265
real tol, fblank
261266
double precision cdelt, crpix, crval, desc(4,MAXNAX), latpol,
@@ -319,6 +324,15 @@ c Get the input parameters.
319324
if (tol.lt.0.0 .or. tol.ge.0.5)
320325
* call bug('f','Invalid value for the tol parameter')
321326

327+
if (doOff) then
328+
call mkeyi('div',div,3,ndiv)
329+
do i=ndiv+1,3
330+
div(i) = 10
331+
enddo
332+
if (div(1).le.0.or.div(2).le.0.or.div(3).le.0)
333+
* call bug('f',"Invalid div values")
334+
endif
335+
322336
call keyfin
323337

324338
c Open the input dataset.
@@ -515,7 +529,7 @@ c Set up output celestial coordinates.
515529
call setCel(lIn, cOut, doDesc, doEqEq, doGalEq)
516530

517531
c Set up offset coordinates.
518-
if (doOff) call doOffset(lIn,nAxIn,cOut,nAxOut)
532+
if (doOff) call doOffset(lIn,nAxIn,cOut,nAxOut,div)
519533

520534
c Initialise coordinate conversions.
521535
call pCvtInit(cOut,lIn)
@@ -848,29 +862,27 @@ c Put coordinates in the normal orientation, i.e. with north up.
848862

849863
c***********************************************************************
850864

851-
subroutine doOffset(lIn,nAxIn,lOut,nAxOut)
865+
subroutine doOffset(lIn,nAxIn,lOut,nAxOut,div)
852866

853-
integer lIn,lOut,nAxIn(3),nAxOut(3)
867+
integer lIn,lOut,nAxIn(3),nAxOut(3),div(3)
854868
c-----------------------------------------------------------------------
855869
include 'maxdim.h'
856870

857-
integer NV
858871
double precision TOL
859-
parameter (NV = 10, TOL = 0.49d0)
872+
parameter (TOL = 0.49d0)
860873

861-
logical first, valid(NV,NV,NV), warned, weird(3)
874+
logical first, valid(div(1),div(2),div(3)), warned, weird(3)
862875
integer i, j, k, l, maxv(3), minv(3), nv1, nv2, nv3
863-
double precision crpix, in(3), out(3,NV,NV,NV)
876+
double precision crpix, in(3), out(3,div(1),div(2),div(3))
864877

865878
external itoaf
866879
character itoaf*2
867880
c-----------------------------------------------------------------------
868881
call pCvtInit(lIn,lOut)
869882

870-
nv1 = min(max(3,nAxIn(1)),NV)
871-
nv2 = min(max(3,nAxIn(2)),NV)
872-
nv3 = min(max(3,nAxIn(3)),NV)
873-
883+
nv1 = min(max(3,nAxIn(1)),div(1))
884+
nv2 = min(max(3,nAxIn(2)),div(2))
885+
nv3 = min(max(3,nAxIn(3)),div(3))
874886
first = .true.
875887
do k = 1, nv3
876888
do j = 1, nv2
@@ -1161,7 +1173,7 @@ c-----------------------------------------------------------------------
11611173
zv(i,j) = real(out(3))
11621174
else
11631175
zv(i,j) = real(in(3))
1164-
endif
1176+
endif
11651177
endif
11661178
enddo
11671179
enddo

0 commit comments

Comments
 (0)