Quantcast
Channel: Intel® Software - Intel® Visual Fortran Compiler for Windows*
Viewing all articles
Browse latest Browse all 5691

Fortran -> C Interop w/ Argument Errors

$
0
0

All,

In my continuing journey in learning how to interoperate Fortran with C, I've come across yet another confusing situation. Below, I'm trying to pass two REAL data arrays to a C routine gpc _cvlist to populate a data structure with the data in the arrays but when I compile, I get the error #6633: The type of the actual argument differs from the type of the dummy argument.   [XV] & [YV] . I'm not understanding why this error would occur since I (thought)  was consistent with my declarations concerning the two arrays.

Below is the code:

!  F2CGPCList.f90
!
!  FUNCTIONS:
!  F2CGPCList - Entry point of console application.
!

!****************************************************************************
!
!  PROGRAM: F2CGPCList
!
!  PURPOSE:  Entry point for the console application.
!
!****************************************************************************

    module gpc_list
	   use, intrinsic :: ISO_C_BINDING
	   implicit none
	   private
	   public C_GPC_VERTEX, C_GPC_VERTEX_LIST, C_GPC_POLYGON
       public gpc_cvlist

	   TYPE, BIND(C) :: C_GPC_VERTEX
	      REAL(C_DOUBLE) :: x
	      REAL(C_DOUBLE) :: y
	   END TYPE C_GPC_VERTEX

	   TYPE, BIND(C) :: C_GPC_VERTEX_LIST
	      INTEGER(C_INT) :: num_vertices
	      TYPE(C_PTR) :: C_vertex
	   END TYPE C_GPC_VERTEX_LIST

	   TYPE, BIND(C) :: C_GPC_POLYGON
	      integer(C_INT) num_contours
	      type(C_PTR) hole
	      type(C_PTR) C_contour
	   END TYPE C_GPC_POLYGON

	   interface

!*********************************************************************
!                   GPC FUNCTION ADD-ONS
!
	      SUBROUTINE gpc_cvlist(npoly, px, py, vertex_list, iret) &
	         BIND(C,name='gpc_cvlist')
	         IMPORT :: C_INT, C_FLOAT, C_GPC_VERTEX_LIST
             implicit none
 	         integer(C_INT),    intent(inout) :: npoly
 	         integer(C_FLOAT),  intent(inout) :: px(*)
 	         integer(C_FLOAT),  intent(inout) :: py(*)
	         TYPE(C_GPC_VERTEX_LIST) vertex_list
 	         integer(C_INT),    intent(inout) :: iret
	      end SUBROUTINE gpc_cvlist

	   end interface

	end module gpc_list


    program F2CGPCList

    use GPC_List

    use, intrinsic :: ISO_C_BINDING

    implicit none

    ! Variables
! - - - local declarations - - -
  INTEGER :: nverts,ii,ier

  REAL    :: xv(10),yv(10)

  type(C_GPC_VERTEX_LIST) C_verticies

    ! Body of F2CGPCList
  WRITE (*,*) "The following are the polygon points to be xfered "

  nverts = 10
  DO ii = 1,nverts
    xv(ii) = float(ii*10)
    yv(ii) = float(ii*10+1)
    write(*,*)'x/yv = ',ii,xv(ii),yv(ii)
  END DO

  CALL gpc_cvlist( nverts, xv, yv, C_verticies, ier )

  end program F2CGPCList

#include "gpc.h"

#define	G_MALLOC(p,type,np,str)  { if ((np) > 0) { \
		(p)=(type*)malloc((np)*sizeof(type)); \
		if (p==((type*)NULL)) { \
		    fprintf(stderr, "malloc failure: %s\n", (str) ); \
		  } \
		} \
		else \
		    (p)=(type*)NULL; \
		}

void gpc_cvlist ( int npoly, float *px, float *py,
				gpc_vertex_list *contour, int *iret )
/************************************************************************
 * gpc_cvlist                                                           *
 *                                                                      *
 * This function generates a GPC vertex list structure given a set of	*
 * polygon points.							*
 *                                                                      *
 * gpc_cvlist ( npoly, px, py, contour, iret )				*
 *                                                                      *
 * Input parameters:                                                    *
 *      *npoly  	int             Number of points in polygon	*
 *      *px     	float[]         X array				*
 *      *py     	float[]         Y array				*
 *                                                                      *
 * Output parameters:                                                   *
 *      *contour  	gpc_vertex_list Vertex list structure		*
 *      *iret   	int     	Return code                     *
 *                                                                      *
 **                                                                     *
 ***********************************************************************/
{
int	ii;
/*---------------------------------------------------------------------*/

    *iret = 0;

    contour->num_vertices = npoly;

    G_MALLOC ( contour->vertex, gpc_vertex, npoly, "gpc_vertex creation" );

    for ( ii = 0; ii < npoly; ii++ )  {
	contour->vertex[ii].x = px[ii];
	contour->vertex[ii].y = py[ii];
    }

    return;

}

Thanks in advance,

Jeff

 


Viewing all articles
Browse latest Browse all 5691

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>