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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:26:58+00:00 2026-05-25T13:26:58+00:00

I am a dummy in Fortran 77 and have always been a C++ coder,

  • 0

I am a dummy in Fortran 77 and have always been a C++ coder, but I have to modify a code from years long ago…
I want to create a variable size array of strings and I cannot find online how to do this in Fortran 77.
Ideally, it should be array with both dimensions variable but if it is not possible, length of the string I can fix, but I need to have variable number of strings.

I tried this:

CHARACTER*32 STR1*(VAR1)
...
WRITE(6,*) STR1(10)

But this does not work…

  • 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-05-25T13:26:59+00:00Added an answer on May 25, 2026 at 1:26 pm

    Apparently FORTRAN 77 does not support dynamic memory allocation .
    You could try allocating memory in a c program and passing the result back to the FORTRAN routine.

    As done here
    http://owen.sj.ca.us/~rk/howto/FandC/FandC.mem.html

    Or more clearly – using some kind of an Interop to call a c method

    from fortran.

    The Unix portable Fortran-77 compiler (‘f77’) is written almost
    entirely in C. The second pass of the compiler is the same one used by
    the C compiler, and most ‘f77’ library routines are simply interfaces
    to corresponding C library routines. However, since Fortran does not
    support data structures like those used in C, you may not be able to
    take advantage of all the functionality that the ‘curses’ library
    offers. Manipulating windows with ‘curses’ is especially difficult. If
    you are interested in using routines involving data structures, you
    should probably use C instead of Fortran.

    To call C routines from a Fortran program, you will have to write some
    C code. Fortran passes arguments by reference or address, so the C
    function has to be prepared to accept the variable as an address. This
    means that you will have to write functions in C that are called from
    Fortran that set up the arguments properly before calling the library
    function. Schematically, this might be something like:

    Note underscore ( _ ) in name of routine.

    In the C source file:

    foo_(bar) /* Note underscore */ int bar; / Note variables are
    passed by address */

    { : }

    In the Fortran source file:

    call foo(baz) /* Assuming that “baz” is an integer. */ { : }

    The underscore is important because Fortran uses the character to keep
    its symbols straight. If you are compiling on an RS6000 this is not
    default behavior, but compiling with the -qextname option on the
    RS6000 will cause it to perform identical to the other platforms.

    Calling C From Fortran

    Note the Fortran example below and how it calls C routines:

    call initscr() call clear() . . . call move(x, y) . . . call
    refresh() call endwin() end

    …where x and y are integers specifying the new coordinates.

    Calling Curses from Fortran

    If you were calling the ‘curses’ routine ‘move()’, you might do
    something like this:

    The C source file contains the interface routine to the ‘curses’
    library function ‘move()’, along with the other C functions that
    provide an interface to the some other ‘curses’ functions:

    #include

    initscr_() { initscr(); }

    clear_() { clear(); }

    move_(x, y) int *x, y; / These are pointers */ { move(*x,
    *y); }

    refresh_() { refresh(); }

    endwin_() { endwin(); }

    The routines are compiled by using these commands:

    cc -c curses.c f77 test.f curses.o -lcurses -ltermcap

    If you are using macros defined in /usr/include/curses.h in your
    Fortran file, be warned that they assume conventions of the C
    language. Be aware that this may affect the results you obtain when
    using them in Fortran.

    from
    https://engineering.purdue.edu/ECN/Support/KB/Docs/CallingCFromFortran

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

Sidebar

Related Questions

I want to create simple dummy tag which can work with Struts2. I have
I have a generic method with this (dummy) code (yes I'm aware IList has
I have created a dummy mail to create Empty Label in Google APPs mail.
I have a small dummy project in VS 2008, contains only the following code
I have dummy username and pasword to enter in linkedin. From an asp.net application,
I have a dummy question. I always read that C++ std::list container has constant
I have a dummy Java Program, which I want to write in Clojure. It
I have the following files dummy.py #!c:/Python27/python.exe -u from mako import exceptions from mako.template
I tried this dummy code below to test unnamed namespace. I have the following
Sorry for the dummy question but I'm a regular expressions newbie. I want these

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.