From: <and...@us...> - 2010-05-18 12:56:20
|
Revision: 11005 http://plplot.svn.sourceforge.net/plplot/?rev=11005&view=rev Author: andrewross Date: 2010-05-18 12:56:14 +0000 (Tue, 18 May 2010) Log Message: ----------- Fix up example 19 for fortran 77 / 95. Having an identity transform in plmap / plmeridians is not the same as having no transform at, particularly when there is a global coordinate transform defined. Add in versions of plmap / plmeridians to genuinely clear the transform. Results for example 19 now agree with C version. Modified Paths: -------------- trunk/bindings/f77/plstubs.h trunk/bindings/f77/scstubs.c trunk/bindings/f77/sfstubs.fm4 trunk/bindings/f95/plstubs.h trunk/bindings/f95/scstubs.c trunk/bindings/f95/sfstubs.f90 trunk/bindings/f95/sfstubsf95.f90 trunk/examples/f77/x19f.fm4 trunk/examples/f95/x19f.f90 Modified: trunk/bindings/f77/plstubs.h =================================================================== --- trunk/bindings/f77/plstubs.h 2010-05-18 07:47:37 UTC (rev 11004) +++ trunk/bindings/f77/plstubs.h 2010-05-18 12:56:14 UTC (rev 11005) @@ -322,7 +322,8 @@ #define PLSTAR FNAME( PLSTAR, plstar ) #define PLSTART7 FNAME( PLSTART7, plstart7 ) #define PLSTRANSFORM FNAME( PLSTRANSFORM, plstransform ) -#define PLSTRANSFORMNONE FNAME( PLSTRANSFORMNONE, plstransformnone ) +#define PLSTRANSFORM_NONE FNAME( PLSTRANSFORM_NONE, plstransform_none ) +#define PLSTRANSFORM_NONE_ FNAME( PLSTRANSFORM_NONE_, plstransform_none_ ) #define PLSTRIPA FNAME( PLSTRIPA, plstripa ) #define PLSTRIPC7 FNAME( PLSTRIPC7, plstripc7 ) #define PLSTRIPD FNAME( PLSTRIPD, plstripd ) Modified: trunk/bindings/f77/scstubs.c =================================================================== --- trunk/bindings/f77/scstubs.c 2010-05-18 07:47:37 UTC (rev 11004) +++ trunk/bindings/f77/scstubs.c 2010-05-18 12:56:14 UTC (rev 11005) @@ -544,7 +544,10 @@ PLFLT *minlong, PLFLT *maxlong, PLFLT *minlat, PLFLT *maxlat ) { - c_plmap( plmapf2c, type, *minlong, *maxlong, *minlat, *maxlat ); + if ( plmapform ) + c_plmap( plmapf2c, type, *minlong, *maxlong, *minlat, *maxlat ); + else + c_plmap( NULL, type, *minlong, *maxlong, *minlat, *maxlat ); } @@ -552,7 +555,10 @@ PLMERIDIANS7( PLFLT *dlong, PLFLT *dlat, PLFLT *minlong, PLFLT *maxlong, PLFLT *minlat, PLFLT *maxlat ) { - c_plmeridians( plmapf2c, *dlong, *dlat, *minlong, *maxlong, *minlat, *maxlat ); + if ( plmapform ) + c_plmeridians( plmapf2c, *dlong, *dlat, *minlong, *maxlong, *minlat, *maxlat ); + else + c_plmeridians( NULL, *dlong, *dlat, *minlong, *maxlong, *minlat, *maxlat ); } void @@ -820,6 +826,7 @@ /* Auxiliary routine - not to be used publicly */ #define PLSETMAPFORMC FNAME( PLSETMAPFORMC, plsetmapformc ) +#define PLCLEARMAPFORMC FNAME( PLCLEARMAPFORMC, plclearmapformc ) void PLSETMAPFORMC( void ( STDCALL *mapform )( PLINT *, PLFLT *, PLFLT * ) ) { @@ -827,6 +834,12 @@ } void +PLCLEARMAPFORMC( ) +{ + plmapform = NULL; +} + +void PLSETOPT7( const char *opt, const char *optarg ) { c_plsetopt( opt, optarg ); @@ -969,13 +982,20 @@ } void -PLSTRANSFORMNONE( void ) +PLSTRANSFORM_NONE( void ) { pltransform = NULL; c_plstransform( NULL, NULL ); } void +PLSTRANSFORM_NONE_( void ) +{ + pltransform = NULL; + c_plstransform( NULL, NULL ); +} + +void PLSTRIPA( PLINT *id, PLINT *pen, PLFLT *x, PLFLT *y ) { c_plstripa( *id, *pen, *x, *y ); Modified: trunk/bindings/f77/sfstubs.fm4 =================================================================== --- trunk/bindings/f77/sfstubs.fm4 2010-05-18 07:47:37 UTC (rev 11004) +++ trunk/bindings/f77/sfstubs.fm4 2010-05-18 12:56:14 UTC (rev 11005) @@ -719,6 +719,23 @@ c*********************************************************************** + subroutine plmap_none(mapname,minx,maxx,miny,maxy) + + implicit none + real*8 minx, maxx, miny, maxy + character*(*) mapname + + include 'sfstubs.h' + + call plstrf2c(mapname, string1, maxlen) + + call plclearmapformc() + call plmap7(s1,minx,maxx,miny,maxy) + + end subroutine + +c*********************************************************************** + subroutine plmeridians(mapform,dlong,dlat,minlong,maxlong, & minlat,maxlat) @@ -736,6 +753,22 @@ c*********************************************************************** + subroutine plmeridians_none(dlong,dlat,minlong,maxlong, + & minlat,maxlat) + + implicit none + real*8 dlong, dlat, minlong, maxlong, minlat, maxlat + + include 'sfstubs.h' + + call plclearmapformc() + call plmeridians7(dlong,dlat,minlong,maxlong,minlat,maxlat) + + end subroutine + + +c*********************************************************************** + subroutine plstripc(id, xspec, yspec, xmin, xmax, xjump, & ymin, ymax, xlpos, ylpos, y_ascl, acc, & colbox, collab, colline, styline, legline, Modified: trunk/bindings/f95/plstubs.h =================================================================== --- trunk/bindings/f95/plstubs.h 2010-05-18 07:47:37 UTC (rev 11004) +++ trunk/bindings/f95/plstubs.h 2010-05-18 12:56:14 UTC (rev 11005) @@ -333,9 +333,9 @@ #define PLSSYM FNAME( PLSSYM, plssym ) #define PLSTAR FNAME( PLSTAR, plstar ) #define PLSTART7 FNAME( PLSTART7, plstart7 ) -#define PLSTRANSFORMON FNAME( PLSTRANSFORMON, plstransformon ) -#define PLSTRANSFORMOFF FNAME( PLSTRANSFORMOFF, plstransformoff ) -#define PLSTRANSFORMNONE FNAME( PLSTRANSFORMNONE, plstransformnone ) +#define PLSTRANSFORM1 FNAME( PLSTRANSFORM1, plstransform1 ) +#define PLSTRANSFORM2 FNAME( PLSTRANSFORM2, plstransform2 ) +#define PLSTRANSFORM3 FNAME( PLSTRANSFORM3, plstransform3 ) #define PLSTRIPA FNAME( PLSTRIPA, plstripa ) #define PLSTRIPC FNAME( PLSTRIPCF77, plstripcf77 ) #define PLSTRIPD FNAME( PLSTRIPD, plstripd ) Modified: trunk/bindings/f95/scstubs.c =================================================================== --- trunk/bindings/f95/scstubs.c 2010-05-18 07:47:37 UTC (rev 11004) +++ trunk/bindings/f95/scstubs.c 2010-05-18 12:56:14 UTC (rev 11005) @@ -587,7 +587,10 @@ PLFLT *minlong, PLFLT *maxlong, PLFLT *minlat, PLFLT *maxlat ) { - c_plmap( plmapf2c, type, *minlong, *maxlong, *minlat, *maxlat ); + if ( plmapform ) + c_plmap( plmapf2c, type, *minlong, *maxlong, *minlat, *maxlat ); + else + c_plmap( NULL, type, *minlong, *maxlong, *minlat, *maxlat ); } @@ -595,7 +598,10 @@ PLMERIDIANS7( PLFLT *dlong, PLFLT *dlat, PLFLT *minlong, PLFLT *maxlong, PLFLT *minlat, PLFLT *maxlat ) { - c_plmeridians( plmapf2c, *dlong, *dlat, *minlong, *maxlong, *minlat, *maxlat ); + if ( plmapform ) + c_plmeridians( plmapf2c, *dlong, *dlat, *minlong, *maxlong, *minlat, *maxlat ); + else + c_plmeridians( NULL, *dlong, *dlat, *minlong, *maxlong, *minlat, *maxlat ); } void @@ -877,11 +883,17 @@ /* Auxiliary routine - not to be used publicly */ #define PLSETMAPFORMC FNAME( PLSETMAPFORMC, plsetmapformc ) +#define PLCLEARMAPFORMC FNAME( PLCLEARMAPFORMC, plclearmapformc ) void PLSETMAPFORMC( void ( STDCALL *mapform )( PLINT *, PLFLT *, PLFLT * ) ) { plmapform = mapform; } +void +PLCLEARMAPFORMC( ) +{ + plmapform = NULL; +} void PLSETOPT7( const char *opt, const char *optarg ) @@ -1040,7 +1052,7 @@ } void -PLSTRANSFORMON( void ( STDCALL *transformfunc )( PLFLT *, PLFLT *, PLFLT *, PLFLT * ) ) +PLSTRANSFORM1( void ( STDCALL *transformfunc )( PLFLT *, PLFLT *, PLFLT *, PLFLT * ) ) { pltransform = transformfunc; @@ -1048,15 +1060,16 @@ } void -PLSTRANSFORMOFF( PLINT *dummy ) +PLSTRANSFORM2( PLINT *dummy ) { pltransform = NULL; c_plstransform( NULL, NULL ); } +/* Provided for symmetry with FORTRAN 77 */ void -PLSTRANSFORMNONE( void ) +PLSTRANSFORM3( void ) { pltransform = NULL; Modified: trunk/bindings/f95/sfstubs.f90 =================================================================== --- trunk/bindings/f95/sfstubs.f90 2010-05-18 07:47:37 UTC (rev 11004) +++ trunk/bindings/f95/sfstubs.f90 2010-05-18 12:56:14 UTC (rev 11005) @@ -793,41 +793,6 @@ !*********************************************************************** - subroutine plmap(mapform,mapname,minx,maxx,miny,maxy) - - implicit none - real(kind=plflt) minx, maxx, miny, maxy - character*(*) mapname - external mapform - - include 'sfstubs.h' - - call plstrf2c(mapname, string1, maxlen) - - call plsetmapformc(mapform) - s1 = transfer( string1, s1 ) - call plmap7(s1,minx,maxx,miny,maxy) - - end subroutine - -!*********************************************************************** - - subroutine plmeridians(mapform,dlong,dlat,minlong,maxlong, & - minlat,maxlat) - - implicit none - real(kind=plflt) dlong, dlat, minlong, maxlong, minlat, maxlat - external mapform - - include 'sfstubs.h' - - call plsetmapformc(mapform) - call plmeridians7(dlong,dlat,minlong,maxlong,minlat,maxlat) - - end subroutine - -!*********************************************************************** - subroutine pltimefmt(fmt) implicit none Modified: trunk/bindings/f95/sfstubsf95.f90 =================================================================== --- trunk/bindings/f95/sfstubsf95.f90 2010-05-18 07:47:37 UTC (rev 11004) +++ trunk/bindings/f95/sfstubsf95.f90 2010-05-18 12:56:14 UTC (rev 11005) @@ -505,6 +505,14 @@ end subroutine pllsty end interface + interface plmap + module procedure plmap1, plmap2 + end interface plmap + + interface plmeridians + module procedure plmeridians1, plmeridians2 + end interface plmeridians + interface plmesh module procedure plmesh end interface @@ -836,7 +844,7 @@ end interface interface plstransform - subroutine plstransformon( transformfunc ) + subroutine plstransform1( transformfunc ) interface subroutine transformfunc(x, y, xt, yt) use plplot_flt @@ -844,19 +852,18 @@ real(kind=plflt) :: x, y, xt, yt end subroutine transformfunc end interface - end subroutine plstransformon + end subroutine plstransform1 - subroutine plstransformoff( dummy ) + subroutine plstransform2( dummy ) implicit none integer :: dummy - end subroutine plstransformoff + end subroutine plstransform2 - subroutine plstransformnone - end subroutine plstransformnone + subroutine plstransform3 + end subroutine plstransform3 end interface - interface subroutine plstripa( id, pen, x, y ) use plplot_flt @@ -1103,6 +1110,67 @@ call plline3f77( size(x), x, y, z ) end subroutine plline3 + subroutine plmap1(mapform,mapname,minx,maxx,miny,maxy) + use plplot_flt + implicit none + real(kind=plflt) minx, maxx, miny, maxy + character*(*) mapname + external mapform + + include 'sfstubs.h' + + call plstrf2c(mapname, string1, maxlen) + + call plsetmapformc(mapform) + s1 = transfer( string1, s1 ) + call plmap7(s1,minx,maxx,miny,maxy) + + end subroutine plmap1 + + subroutine plmap2(mapname,minx,maxx,miny,maxy) + use plplot_flt + implicit none + real(kind=plflt) minx, maxx, miny, maxy + character*(*) mapname + + include 'sfstubs.h' + + call plstrf2c(mapname, string1, maxlen) + + call plclearmapformc() + s1 = transfer( string1, s1 ) + call plmap7(s1,minx,maxx,miny,maxy) + + end subroutine plmap2 + + subroutine plmeridians1(mapform,dlong,dlat,minlong,maxlong, & + minlat,maxlat) + + implicit none + real(kind=plflt) dlong, dlat, minlong, maxlong, minlat, maxlat + external mapform + + include 'sfstubs.h' + + call plsetmapformc(mapform) + call plmeridians7(dlong,dlat,minlong,maxlong,minlat,maxlat) + + end subroutine plmeridians1 + + subroutine plmeridians2(dlong,dlat,minlong,maxlong, & + minlat,maxlat) + + implicit none + real(kind=plflt) dlong, dlat, minlong, maxlong, minlat, maxlat + external mapform + + include 'sfstubs.h' + + call plclearmapformc + call plmeridians7(dlong,dlat,minlong,maxlong,minlat,maxlat) + + end subroutine plmeridians2 + subroutine plmesh( x, y, z, opt ) integer :: opt real(kind=plflt), dimension(:) :: x, y Modified: trunk/examples/f77/x19f.fm4 =================================================================== --- trunk/examples/f77/x19f.fm4 2010-05-18 07:47:37 UTC (rev 11004) +++ trunk/examples/f77/x19f.fm4 2010-05-18 12:56:14 UTC (rev 11005) @@ -20,24 +20,6 @@ c-------------------------------------------------------------------------- -c ident -c -c Defines identity transformation for example 19. -c x(), y() are the coordinates to be plotted. -c This is a 0-OP routine, to play the role of NULL in the C version! -c-------------------------------------------------------------------------- - - subroutine ident(n, x, y) - implicit none - - integer n - real*8 x - real*8 y - - return - end - -c-------------------------------------------------------------------------- c floor c c Compatibility function - keep all examples as equal as possible @@ -51,6 +33,11 @@ endif end +c-------------------------------------------------------------------------- +c map_transform +c +c General coordinate transform function +c-------------------------------------------------------------------------- subroutine map_transform(x, y, xt, yt) implicit none @@ -85,9 +72,7 @@ real*8 xp, yp, radius do i = 1,n - radius = 90.0d0 - y(i) - xp = radius * cos(x(i) * PI / 180.0d0) - yp = radius * sin(x(i) * PI / 180.0d0) + call map_transform(x(i),y(i),xp,yp) x(i) = xp y(i) = yp enddo @@ -166,7 +151,6 @@ implicit none real*8 minx, maxx, miny, maxy real*8 x, y - external ident external map_transform external mapform19 external geolocation_labeler @@ -194,7 +178,7 @@ call plcol0(1) call plenv(minx, maxx, miny, maxy, 1, 70) - call plmap(ident, 'usaglobe', minx, maxx, miny, maxy) + call plmap_none('usaglobe', minx, maxx, miny, maxy) c The Americas @@ -203,7 +187,7 @@ call plcol0(1) call plenv(minx, maxx, miny, maxy, 1, 70) - call plmap(ident, 'usaglobe', minx, maxx, miny, maxy) + call plmap_none('usaglobe', minx, maxx, miny, maxy) c Clear the labeling function c (Note: FORTRAN 77 does not handle NULL pointers, so an @@ -235,10 +219,10 @@ call plenv( -75.d0, 75.d0, -75.d0, 75.d0, 1, -1 ) ! No need to set the map transform here as the global ! transform will be used. - call plmap( ident, 'globe', minx, maxx, miny, maxy ) + call plmap_none( 'globe', minx, maxx, miny, maxy ) call pllsty( 2 ) - call plmeridians( ident, 10.0d0, 10.0d0, 0.0d0, + call plmeridians_none( 10.0d0, 10.0d0, 0.0d0, & 360.0d0, -10.0d0, 80.0d0 ) ! Show Baltimore, MD on the map @@ -252,7 +236,7 @@ & 0.0d0, 'Baltimore, MD' ) ! For f77, this is how the global transform is cleared - call plstransformnone + call plstransform_none call plend() end Modified: trunk/examples/f95/x19f.f90 =================================================================== --- trunk/examples/f95/x19f.f90 2010-05-18 07:47:37 UTC (rev 11004) +++ trunk/examples/f95/x19f.f90 2010-05-18 12:56:14 UTC (rev 11005) @@ -19,26 +19,6 @@ ! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -!-------------------------------------------------------------------------- -! ident -! -! Defines identity transformation for example 19. -! x(), y() are the coordinates to be plotted. -! This is a 0-OP routine, to play the role of NULL in the C version! -!-------------------------------------------------------------------------- - - subroutine ident(n, x, y) - use plplot - implicit none - - integer n - real(kind=plflt) x - real(kind=plflt) y - - return - end - - subroutine map_transform(x, y, xt, yt) use plplot, PI => PL_PI implicit none @@ -155,7 +135,6 @@ real(kind=plflt) minx, maxx, miny, maxy real(kind=plflt), dimension(1:1) :: x, y integer c - external ident external map_transform external mapform19 external geolocation_labeler @@ -165,40 +144,40 @@ ! Longitude (x) and latitude (y) - miny = -70 - maxy = 80 + miny = -70._plflt + maxy = 80._plflt call plinit() ! Cartesian plots ! Most of world - minx = 190 - maxx = 190+360 + minx = 190._plflt + maxx = 190._plflt+360._plflt ! Setup a custom latitude and longitude-based scaling function. call plslabelfunc(geolocation_labeler) call plcol0(1) call plenv(minx, maxx, miny, maxy, 1, 70) - call plmap(ident, 'usaglobe', minx, maxx, miny, maxy) + call plmap('usaglobe', minx, maxx, miny, maxy) ! The Americas - minx = 190 - maxx = 340 + minx = 190._plflt + maxx = 340._plflt call plcol0(1) call plenv(minx, maxx, miny, maxy, 1, 70) - call plmap(ident, 'usaglobe', minx, maxx, miny, maxy) + call plmap('usaglobe', minx, maxx, miny, maxy) ! Clear the labeling function call plslabelfunc(0) ! Polar, Northern hemisphere - minx = 0 - maxx = 360 + minx = 0._plflt + maxx = 360._plflt call plenv(-75._plflt, 75._plflt, -75._plflt, & 75._plflt, 1, -1) @@ -211,8 +190,8 @@ ! Polar, Northern hemisphere, this time with a PLplot-wide transform - minx = 0 - maxx = 360 + minx = 0._plflt + maxx = 360._plflt call plstransform( map_transform ) @@ -221,10 +200,10 @@ 75._plflt, 1, -1 ) ! No need to set the map transform here as the global ! transform will be used. - call plmap( ident, 'globe', minx, maxx, miny, maxy ) + call plmap('globe', minx, maxx, miny, maxy ) call pllsty( 2 ) - call plmeridians(ident, 10.0_plflt, 10.0_plflt, & + call plmeridians(10.0_plflt, 10.0_plflt, & 0.0_plflt, 360.0_plflt, -10.0_plflt, & 80.0_plflt ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |