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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:21:14+00:00 2026-06-15T22:21:14+00:00

I am trying to compile someone else’s FORTRAN code using gfortran 4.4.6. The original

  • 0

I am trying to compile someone else’s FORTRAN code using gfortran 4.4.6. The original coder used something like Compaq FORTRAN.

The code in question is supposed to read a filename like ‘foo.txt’ and create a new file called ‘foo_c.txt’:

    file_label_end = SCAN(filename, '.') - 1
    WRITE (output_filename,5) filename
    5 FORMAT (A<file_label_end>, '_c.txt' )

gfortran complains about the opening angle bracket of the character specifier. That is, rather than “A3” he has “A<(a variable with value 3)>”. I cannot find any information about interpolating format widths from variables… Is this possible? If not, what’s the best way to fix this?

Update:

This seems to be working (compiling):

file_label_end = SCAN(par_filename, '.', .TRUE. ) + 1
output_filename = par_filename(1:file_label_end) // '_c.par'

but I later have a similar case:

12 FORMAT (<n-1>F10.5)
...
READ(1,12) (cat_parm (blk,j), j = 1,n-1)

which I attempted to fix by creating a format string:

write(fmt12,'(I0,A4)') n-1, 'F10.5'
!12 FORMAT (fmt12)
12 FORMAT (fmt=fmt12)

But the “t” in “fmt” gets flagged with an error about “Nonnegative width required in format string”

  • 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-15T22:21:15+00:00Added an answer on June 15, 2026 at 10:21 pm

    The use of <> in Fortran edit descriptors is non-standard, though widely implemented. You certainly can build edit descriptors from variables, the standard way is through an internal write, something like this (omitting declarations):

    format_string = ''
    write(format_string,'(a1,i0,a6)') 'A', file_label_end,'''_c.txt''' ! WARNING I haven't tested this
    

    and then

    write(output_filename,fmt=format_string) filename
    

    But in your case this is not entirely necessary. You could try this instead

    file_label_end = SCAN(filename, '.') - 1
    WRITE (output_filename,'(a)') filename(1:file_label_end)//'_c.txt'
    

    With the ‘a’ edit descriptor omitting a width means that all the characters in the expression will be written. You may want to declare

    character(len=*), allocatable :: output_filename
    

    if you haven’t already done so.

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

Sidebar

Related Questions

I'm trying to compile someone's code right now and the person is using a
I'm experimenting with XCode and trying to compile someone else's Windows code. There's this:
I'm trying to compile someone else's C++ code. I have 0 experience with C++
When trying to compile this code: #include <iostream> #include <vector> using namespace std; class
I'm trying to compile someone else's project, and I'm getting about 850 errors all
I'm trying to compile a c++ program that I got from someone else. It's
I am trying to compile the following code on Linux using gcc 4.2: #include
I am modifying someone else's code, and just trying to add a fourth checkbox
While trying to compile a 64 bit linux kernel using gcc, I see the
When trying to compile the following code, I am getting a warning that line

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.