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 9222197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:46:24+00:00 2026-06-18T03:46:24+00:00

I have a FORTRAN program written for the parallel computing. The program takes the

  • 0

I have a FORTRAN program written for the parallel computing. The program takes the arguments and the number of threads can be defined as the argument. The sample code is as follows:

COUNT = NARGS()
      NTHREADS = 1

      ! *** GET THE COMMAND LINE ARGUMENTS, IF ANY
      IF(COUNT.GT.1)THEN
        ! *** ARGUMENT 1
        CALL GETARG(1, BUFFER, iStatus)
        IF (Buffer(1:4).EQ.'-NOP'.OR.Buffer(1:4).EQ.'-nop') THEN
          PAUSEIT=.FALSE.
        ENDIF
        IF (Buffer(1:3).EQ.'-NT'.OR.Buffer(1:3).EQ.'-nt') THEN
          READ(Buffer(4:10),*) NTHREADS
        ENDIF
        IF(COUNT.GT.2)THEN
          ! *** ARGUMENT 2
          CALL GETARG(2, BUFFER, iStatus)
          IF (Buffer(1:4).EQ.'-NOP'.OR.Buffer(1:4).EQ.'-nop') THEN
            PAUSEIT=.FALSE.
          ENDIF
          IF (Buffer(1:3).EQ.'-NT'.OR.Buffer(1:3).EQ.'-nt') THEN
            READ(Buffer(4:10),*) NTHREADS
          ENDIF
         ENDIF
      ENDIF

Let’s say my compiled file name is “hellofortran”. I can define the number of threads as

./hellofortran -nt4 

My program will read the program with 4 threads. The problem is that I can run with as many cores in any computer. Lets say I have dual core processor. I have only two cores but I can still run with 6-8 threads or any number. How can I properly define the number of threads in this particular instance ?

I hope I explained my problem. Looking forward to hearing soon on how can I improve my program. Thanks.

Jdbaba

  • 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-18T03:46:26+00:00Added an answer on June 18, 2026 at 3:46 am

    If you’re using OpenMP and just looking to set up how many threads to use, I would just specify the number of threads in the environment:

    OMP_NUM_THREADS=4
    ./hellofortran
    

    and write your OpenMP code as you would normally. There are programmatic ways of setting thread counts but this is likely more straightforward for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Fortran program, which I can compile using f77, f95 or ifort
I have a program written in Fortran and I have more than 100 subroutines.
I have a Fortran code like this: file1.f90 program myprog use func1mod do i=1,N
I have a program written in Fortran by someone else which consequently reads a
I have written a fairly large program in Fortran 90. It has been working
I have a program where code in C, C++ and Fortran has been compiled
I have a program written in Fortran 90/95; after invocation it always reads a
We have a complex program written in Fortran 90, I've only been able to
I have a bash script that runs a simulation program written in Fortran 90,
I have Fortran-based 3D column-major order array flattened into linear memory. What formula/algorithm can

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.