Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29285 Discussions

quick question: compiling .f and .f90

rreis
New Contributor I
1,774 Views
is there any problem in compiling .f and .f90 files into the same program?
0 Kudos
1 Solution
Kevin_D_Intel
Employee
1,774 Views
You may, however, have to compile the .f and .f90 sources on separate command lines, and then link them together. I know in the past that it did not work to mix file types on the same ifort line - have not tried that lately.

We are good in this regard with 11.1. I did not check earlier releases.

$ cat -n main.f90
1 program demo
2 call sub1
3 end

$ cat -n sub1.f
1 subroutine sub1
2 write(*,*)'In sub1'
3 end

$ ifort -V main.f90 sub1.f
Intel Fortran Intel 64 Compiler Professional for applications running on Intel 64, Version 11.1 Build 20091012 Package ID: l_cprof_p_11.1.059
Copyright (C) 1985-2009 Intel Corporation. All rights reserved.

Intel Fortran 11.1-2620
Intel Fortran 11.1-2620
GNU ld version 2.17.50.0.6-5.el5 20061020

$ ./a.out
In sub1

View solution in original post

0 Kudos
6 Replies
Kevin_D_Intel
Employee
1,774 Views
Quoting - rreis
is there any problem in compiling .f and .f90 files into the same program?

No.
Steven_L_Intel1
Employee
1,774 Views
You may, however, have to compile the .f and .f90 sources on separate command lines, and then link them together. I know in the past that it did not work to mix file types on the same ifort line - have not tried that lately.
0 Kudos
Kevin_D_Intel
Employee
1,775 Views
You may, however, have to compile the .f and .f90 sources on separate command lines, and then link them together. I know in the past that it did not work to mix file types on the same ifort line - have not tried that lately.

We are good in this regard with 11.1. I did not check earlier releases.

$ cat -n main.f90
1 program demo
2 call sub1
3 end

$ cat -n sub1.f
1 subroutine sub1
2 write(*,*)'In sub1'
3 end

$ ifort -V main.f90 sub1.f
Intel Fortran Intel 64 Compiler Professional for applications running on Intel 64, Version 11.1 Build 20091012 Package ID: l_cprof_p_11.1.059
Copyright (C) 1985-2009 Intel Corporation. All rights reserved.

Intel Fortran 11.1-2620
Intel Fortran 11.1-2620
GNU ld version 2.17.50.0.6-5.el5 20061020

$ ./a.out
In sub1
0 Kudos
rreis
New Contributor I
1,774 Views
cool. many thanks for answering (and producing ifort)
0 Kudos
Steven_L_Intel1
Employee
1,774 Views
Kevin, your test needed to have the .f file include fixed-form continuation or other coding that would not be acceptable in free-form source. However I did test this just now and it does work, so we're good.
0 Kudos
Kevin_D_Intel
Employee
1,774 Views

Yes good point, or reverse the order of the source files to see if the lack of fixed-form indentation in main.f90 triggered errors.
0 Kudos
Reply