0

So I wrote some Fortran in the .f90 format and I need the file extension to be .f for compilation reason. Im under the assumption that ive written the fortran in iin the newest fortran 90 way and i need to convert it back to .f fortran 77 way.

  program p1
    implicit none
    integer :: choice
    real :: inputValue 

     do while(choice /= 0) 
            print *, ' '
            print *, 'Enter a conversion option (1-6 or 0 to exit):'
            print *, '-------------'
            print *, '(1) Pounds to Kilograms'
            print *, '(2) Kilograms to Pounds'
            print *, '(3) Feet to meters'
            print *, '(4) Meters to feet'
            print *, '(5) farenheit to Celsius'
            print *, '(6) Celsius to Fahrenheit'
            print *, '(0) Exit this progrm'
            print *, '-------------'
            READ(*,*) choice

            IF (choice == 1) THEN
                print *, 'Please enter the number (Integer) of Pounds to be converted into Kilograms'
                READ(*,*) inputValue
                inputValue  = inputValue / 2.20
                print *, 'Your value is:', inputValue
             ELSE IF (choice == 2) THEN
                print *, 'Please enter the number (Integer) of Kilograms to be converted into Pounds'
                READ(*,*) inputValue
                inputValue = inputValue * 2.20
                print *, 'Your value is:', inputValue
             ELSE IF (choice == 3) THEN
                print *, 'Please enter the number (Integer) of Feet to be converted into Meters'
                READ(*,*) inputValue
                inputValue = inputValue / 3.28
                print *, 'Your value is:', inputValue
             ELSE IF (choice == 4) THEN
                print *, 'Please enter the number (Integer) of Meters to be converted into Feet'
                READ(*,*) inputValue
                inputValue = inputValue * 3.28
                print *, 'Your value is:', inputValue
             ELSE IF (choice == 5) THEN
                print *, 'Please enter the number (Integer) of Fahrenheit to be converted into Celsius'
                READ(*,*) inputValue
                inputValue = (5.0/9.0) * (inputValue - 32)
                print *, 'Your value is:', inputValue
             ELSE IF (choice == 6) THEN
                print *, 'Please enter the number (Integer) of Celsius to be converted into Fahrenheit'
                READ(*,*) inputValue
                inputValue = (inputValue * 9.0/5.0) + 32
                print *, 'Your value is:', inputValue
             ELSE IF (choice == 0) THEN
                print *, 'EXIT'
        
             END IF 
    ENDDO  

  end program p1
francescalus
  • 30,576
  • 16
  • 61
  • 96
  • 1
    Rather than converting from free- to fixed-form source, it's probably better to fix whatever compilation system you have that supports only `.f` file suffixes. If you must do this then read about _intersection format_. – francescalus Aug 24 '21 at 23:55
  • It's an assignment and I already wrote it in .f90 instead of .f and then I found out it had to be .f90 to be submitted for grading. –  Aug 24 '21 at 23:58
  • Which part of writing this in fixed-form are you asking about? Do you know what requirements that source form has? If so, what difficulties have you identified in your conversion? Are you asking how to make gfortran convert? Or asking for some other tool, or even someone to do it for you? – francescalus Aug 25 '21 at 00:06
  • Basically I wrote the program in .f90 before I knew that the professors for whatever reason only wants .f extension. I am aware that the compile can use the compile in free for option, but hes not doing that. So i guess what Im asking is how do i convert this .f90 > .f withouth any special compiling options. i just want to use gcc example.f -o example.. Here is a list of errors im getting when trying to save the .f90 as a .f. Error: Unterminated character constant beginning at (1) Ii already did the 6 spaces and that fixed some errors –  Aug 25 '21 at 00:18
  • 4
    Tell your professor it’s 2021, not 1977. – Time Laird Aug 25 '21 at 00:35
  • 1
    Bro if only you knew...the only errors im getting are –  Aug 25 '21 at 00:37
  • Error: Unterminated character constant beginning at (1) on my long print lines print *, 'Please enter the number (Integer) of Celsius to be conver –  Aug 25 '21 at 00:38
  • The _Unterminated character_ error likely means you have exceeded 72 characters on a line of input. Change .f90 to .f, move everything to column 7 except labels, continuation lines are marked in column 6, and make sure your lines are short. PS: Also go complain to the dean that the professor is requesting homework in a 50+ year old dialect of language, which has been superseded by 5 revision an internatioanl standard. – steve Aug 25 '21 at 00:48
  • Ok I fixed the first part, put the continuation lines are still throwing me off –  Aug 25 '21 at 00:52
  • I dont know how to fix the continuation.. My print lines are defintely longer than 72 but how do I use concatenate over 2 lines. I Here is an example -->>>print *, 'Please enter the number (Integer) of Pounds to be converted into Kilograms' –  Aug 25 '21 at 00:54

0 Answers0