uDALES / u-dales

uDALES: large-eddy-simulation software for urban flow, dispersion and microclimate modelling
https://udales.github.io/u-dales
GNU General Public License v3.0
54 stars 18 forks source link

Stop compiling f90 on the fly in pre-processing #196

Open dc2917 opened 2 months ago

dc2917 commented 2 months ago

The script write_inputs.m currently compiles some fortran utilities (WriteIBMfiles, Matchfacetstocells, ...(?)) on the fly. This should instead be performed as part of the build process (e.g. user runs make tools), and the binaries are then stored in u-dales/tools/.

For example, in tools/IBM/writeIBMfiles:

if lmypolyfortran
    disp('Determining fluid/solid points using Fortran.')
    % Compile
    n_threads = 8;
    in_mypoly_fortran_path = [folder '/in_mypoly_fortran/'];
    addpath(in_mypoly_fortran_path)
    cd(in_mypoly_fortran_path);
    system('gfortran -O2 -fopenmp in_mypoly_functions.f90 ibm_necessary_functions.f90 IBM_flagging.f90 -o pre.exe');
    copyfile('pre.exe', fpath)
    delete pre.exe in_mypoly_functions.mod ibm_necessary_functions.mod
    ...
    cd(fpath)
    if lwindows
        system('pre.exe');
    else
        system('./pre.exe');
    end
    delete pre.exe inmypoly_inp_info.txt faces.txt vertices.txt zfgrid.txt zhgrid.txt;
    cd(currentPath)

Compiling pre.exe can be done via CMake, such that there exists an appropriately named executable (e.g. mypoly_fortran?) in tools/IBM/in_mypoly_fortran/.