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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T11:05:48+00:00 2026-05-28T11:05:48+00:00

I have a program which performs a useful task. Now I want to produce

  • 0

I have a program which performs a useful task. Now I want to produce the plain-text source code when the compiled executable runs, in addition to performing the original task. This is not a quine, but is probably related.

This capability would be useful in general, but my specific program is written in Fortran 90 and uses Mako Templates. When compiled it has access to the original source code files, but I want to be able to ensure that the source exists when a user runs the executable.

Is this possible to accomplish?

Here is an example of a simple Fortran 90 which does a simple task.

program exampl
  implicit none
  write(*,*) 'this is my useful output'
end program exampl

Can this program be modified such that it performs the same task (outputs a string when compiled) and outputs a Fortran 90 text file containing the source?

Thanks in advance

  • 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-28T11:05:48+00:00Added an answer on May 28, 2026 at 11:05 am

    It’s been so long since I have touched Fortran (and I’ve never dealt with Fortran 90) that I’m not certain but I see a basic approach that should work so long as the language supports string literals in the code.

    Include your entire program inside itself in a block of literals. Obviously you can’t include the literals within this, instead you need some sort of token that tells your program to include the block of literals.

    Obviously this means you have two copies of the source, one inside the other. As this is ugly I wouldn’t do it that way, but rather store your source with the include_me token in it and run it through a program that builds the nested files before you compile it. Note that this program will share a decent amount of code with the routine that recreates the code from the block of literals. If you’re going to go this route I would also make the program spit out the source for this program so whoever is trying to modify the files doesn’t need to deal with the two copies.

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

Sidebar

Related Questions

I have a program which looks in source code, locates methods, and performs some
I have a program which deliberately performs a divide by zero (and stores the
I have a wxPython program which reads from different datasets, performs various types of
I have an MFC application that I was given (without source code) which opens
I have a program which performs a Monte Carlo-type simulation. Currently I have written
I have a c++ program which performs one function. It loads a large data-file
I have a high-speed ADC data capture/analysis program which performs poorly on older computers.
I have a program which needs to invoke a process to perform an operation
I have a program which needs to behave slightly differently on Tiger than on
I have a program which has some Textareas / Labels these can be anywhere

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.