Download Latest Version JTSDK64-4.0.0b1.exe (347.0 MB)
Email in envelope

Get an email when there's a new version of HAMLIB SDK (Evolved JTSDK)

Home / Programming / Fortran
Name Modified Size InfoDownloads / Week
Parent folder
README.md 2023-10-24 11.6 kB
Using Fortran Modules from within GCC.docx 2023-10-23 17.3 kB
Totals: 2 Items   28.9 kB 0

Fortran Resources


Example


This is based around Qt-based command line for Qt 6.6.0

Files

Examples (from http://matrixprogramming.rudnyi.ru/category/tools/ accessed 2023-10-23):

File: call.cpp

// Adapted from Evgenii B. Rudnyi, http://Evgenii.Rudnyi.Ru

#include <iostream>
#include <cstring>
#include <string>

using namespace::std;

extern "C" int test_(char *str, double *adbl, double *dbl, int *aint, int *intv, int nstr);

int main()
{
    char str[20];
    strcpy(str,"test");
    double dbl = 4.5;
    double adbl[4] = {1.2, 3.4, 5.6, 7.8};
    int intv = 3;
    int aint[4] = {3, 4, 5, 6};
    cout << "calling Fortran" << endl;
    test_(str, adbl, &dbl, aint, &intv, 4);
    return 0;
}

File: sub.f

c Evgenii B. Rudnyi, http://Evgenii.Rudnyi.Ru
subroutine test(str, adbl, dbl, aint, int)
      character*4 str
      double precision adbl(4), dbl
      integer aint(4), int
      print *, 'str ', str
      print *, 'dbl ', dbl
      print *, 'int ', int
      print *, 'adbl ', (adbl(i), i = 1, 4)
      print *, 'aint ', (aint(i), i = 1, 4)
      return
end

Qt Environment

Based on Windows 11

• Start / All Apps / Qt / Qt 6.6.0 (MinGW 11.2.0 64-bit)

• Change into source directory (i.e. cd c:\Users\<userid>\Documents\fortran )

• Compile Fortran Source:

c:\Users\<userid>\Documents\Fortran>gfortran -c sub.f

• Compile G++ source:

c:\Users\<userid>\Documents\Fortran>g++ -c -fno-leading-underscore call.cpp

• Link object to libraries and produce executable

c:\Users\<userid>\Documents\Fortran>g++ sub.o call.o -o main.exe -lgfortran

Test

c:\Users\<userid>\Documents\Fortran>main.exe

calling Fortran
 str test
 dbl    4.5000000000000000
 int            3
 adbl    1.2000000000000000        3.3999999999999999        5.5999999999999996        7.7999999999999998
 aint            3           4           5           6

c:\Users\<userid>\Documents\Fortran>

Resources


Here are resources that experimenters may find useful with regards to understanding Fortran and using Fortran-derived modules in their work.

This may also help to explain techniques used by Joe Taylor in the development of WSJT-X.


Contributions


How Can I Help?

We require people to make these README.md scripts better by contributing resources !

** ALL CONTRIBUTIONS AND COMMENTS ARE GRATEFULLY WELCOMED **


Conclusion and Further References


Base ref: https://sourceforge.net/projects/hamlib-sdk/files/Programming/Fortran/README.md Date: 2023-10-24

https://annefou.github.io/Fortran/basics/basics.html <== Start here [F1]: https://gcc.gnu.org/wiki/GFortranGettingStarted <== Second site to visit !

Source: README.md, updated 2023-10-24