Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9251853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:48:14+00:00 2026-06-18T10:48:14+00:00

I have the following start of a subroutine called by python: Called from python

  • 0

I have the following start of a subroutine called by python:

Called from python using: libomp.cic(pos,mpart,boxsize,dim,npart)

subroutine cic(pos,mpart,boxsize,dim,npart,mesh)
use omp_lib
implicit none 
real*8 mpart
!f2py intent(in) :: mpart
real*8 boxsize
!f2py intent(in) :: boxsize
integer dim
!f2py intent(in) :: dim
integer*8 npart
!f2py intent(in) :: npart
real*8, dimension(0:dim-1,0:dim-1,0:dim-1) :: mesh
!f2py intent(out) :: mesh
real*8, dimension(npart,3) :: pos
!f2py intent(in) :: pos

Error when running python script:

error: (shape(pos,0)==npart) failed for 1st keyword npart: cic:npart=47099622
WARNING: Failure executing file: <test.py>

For some reason it works when I set npart as an integer but it can’t receive npart from python and create the array pos on the fly. It works for mesh using dim but not pos, why? Does it have something to do with the ordering in which they are called?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T10:48:15+00:00Added an answer on June 18, 2026 at 10:48 am

    pos is declared to be intent(in) which means that it is supposed to be allocated when you enter the routine. Note that this is completely different than using an automatic array in fortran since pos is a dummy argument. The problem is that since pos is intent(in), f2py is checking it’s declared dimensions with the dimensions that you’re passing in (mpart) because npart is also supposed to be intent(in). Since they don’t match, you’re getting an error.

    In other words, you have 2 intent(in) variables and the values that you’re passing in for them are incompatible. The actual solution really depends on what the subroutine is supposed to be doing, and what the intent of the dummy arguments actually should be.

    If pos is really intent(in), then you could in principle change npart to intent(hide) in which case, numpy will pass the npart to your subroutine based on the allocated dimensions of pos. e.g., I believe it will be called as:

    libomp.cic(pos,mpart,boxsize,dim)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How I can start reading from a specific byte? I have following code: try
I have the following start on a makefile rule (thanks to help from others),
I have the following sequence: Start MBProgressHUD spinner Download several images using NSConnectionURL and
I have following two methods. When user clicks on start button from ui, the
I have the following query to start with: var query = from p in
I have the following code TransitionManager.start(babyPreloader,{type:Fade, direction:Transition.OUT, duration:0.5, easing:Regular.easeOut}); var tempPreloader:DisplayObject = babyPreloader as
I have the following method: public object[] GetEventsByUser(DateTime start, DateTime end, string fullUrl) The
I have the following $_POST function to check if the fields of 'start', 'middle'
I have the following problem: I have an Activity where a user can start
I have the following grammar: grammar bxk; options { language=CSharp3; } // start rule

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.