dinosauria123 / Koko

Koko is raytracing software for the design and analysis of optical imaging and illumination systems
Other
28 stars 12 forks source link

Introduction to compilation #12

Open Jonas231 opened 3 years ago

Jonas231 commented 3 years ago

Hello, I wondered if you could provide some kind of guide here on how to build koko in linux (and windows) here.

Why I am asking: I looked into the macro language of KDP-2 a little bit, which is very similar to the one of ACCOS V. See for instance: https://spie.org/Publications/Proceedings/Paper/10.1117/12.933359?SSO=1 I wanted to implement a linear fit with the macro language to describe distorted images of non-centered optical systems. I think this is more complicated than doing it in fortran. If I knew how to build Koko I could add an operand / command which does this (I would share it of course).

Do you think it is possible to provide this guide, here?

Another related issue: Where in the program source code would you add such a command?

Kind regards, Jonas

Jonas231 commented 2 years ago

Hello, I tried to build Koko on windows using https://www.msys2.org. At first I used this tutorial: https://iraspa.org/blog/visual-studio-code-c-cpp-fortran-with-multiple-source-files/ After this worked I used CodeRunner on the makefile you provided.

I got this error (in grafik ): grafik And this one: grafik

I also got errors of this kind: grafik I fixed those by deleting one 3.

I got this error: grafik So I had to add: grafik

And I finally I get this output: C:\msys64\mingw64\bin\ar.exe: creating liblinenoise.a mv liblinenoise.a ../lib make[2]: Verzeichnis „/c/Users/herbst/projects/Koko/Src/linenoise“ wird verlassen gfortran -o koko-cli koko.o cmder.o names.o libload.o saverest.o -L./lib -static -Wl,--start-group -lkmath -lldm -lconfig -lhardware -lmacro -loptimize -lparaxial -lpickup -lraytrace -lspecsurf -lnonseq -lutility -lwavespot -lglass -lplotcad -llinenoise -lkmod -Wl,--end-group -lm -lstdc++ -lregex C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../lib\libregex.a(systre.o):(.text+0x1): undefined reference to tre_regcomp' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../lib\libregex.a(systre.o):(.text+0x11): undefined reference totre_regfree' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../lib\libregex.a(systre.o):(.text+0x21): undefined reference to tre_regerror' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../lib\libregex.a(systre.o):(.text+0x31): undefined reference totre_regexec' collect2.exe: error: ld returned 1 exit status make[1]: [Makefile:60: koko-cli] Fehler 1 make[1]: Verzeichnis „/c/Users/herbst/projects/Koko/Src“ wird verlassen make: [Makefile:31: all] Fehler 2

Do you have an idea why this is the case? Best regards, Jonas

dinosauria123 commented 2 years ago

Thank you for your interests.

I don’t know porting to windows 64 but but I think you need tre library for windows.

http://gnuwin32.sourceforge.net/packages/tre.htm

I also think you need “gnuwin64” library, but it is not exist.

Jonas231 commented 2 years ago

Hello, thank you very much for your answer. I installed tre using the installer, however the error message remains the same. What do you mean by "I also think you need “gnuwin64” library, but it is not exist."? Any help on how to solve the problem on windows would be very appreciated. I assume you build koko for windows from Linux?

In this case I could also switch to Linux, however I have some optical design programs I would like to compare with (e.g. ZEMAX, OpTaliX which only run on Windows).

My plan is this one (however I have zero experience with fortran):

I. I would like to add a vtk-based 3D optical layout plot as an option in your gui. Basically an upgrade to your gnuplot VIE. Also I am thinking about making it in a way that it is a windows always open in the background but only updated on demand (update button). Steps:

  1. use https://github.com/szaghi/VTKFortran for writing vtk files (ideally this is done in fortran including all surfaces and the layout rays)
  2. These vtk files could be opened with Paraview or continously read with Python (e.g. Pyvista) as a first step
  3. Add some viewer to your Qt gui. A window once opened which stays open or can be closed and updated at any time.

II. Add some comment for https://sphinx-fortran.readthedocs.io/en/latest/ This would allow to get a better overview of the original "Src" by Mr. Klein.

I know these are very ambitious goals and will take a while but would be very useful.

Best regards, Jonas

dinosauria123 commented 2 years ago

Thank you for your reply.

I think you try to compile 64 bit enviorent.

compilation for Koko needs gnu tool( gnuwin32) kit and MSYS but any 64bit gnuwin64 tool kit not available now.

you need compile pre library as 64 bit library.

You should use WSL2 on Windows, It gave Linux environment on Windows.

Did you tried my 32bit windows binary ?

Jonas231 commented 2 years ago

Thank you. I will try to compile a 32 bit version. I tried your 32 bit binary. The KODS gui starts however "VIE" does not work. Adding a surface "Edit > Insert surface" makes the gui crashing... . The default CURLENS Lenstext.dat is the Cook Tripet which should be shown, right? LensView > XZ or ortho does not show anything. Your LINUX version worked.

dinosauria123 commented 2 years ago

Sorry for inconvenience.

Please try CUI version koko and install gnuplot for windows.

Jonas231 commented 2 years ago

What is CUI?

dinosauria123 commented 2 years ago

Try Koko-cli.exe

Jonas231 commented 2 years ago

Hi,

I tried Koko-cli on two pcs with windows 10. The one with admin rights could open the cli. The one without not. Okay. Nice to know so I do not need the qt gui and I could basically do everything from koko-cli.exe including plotting with gnuplot?!

It would also be very helpful for me if you could provide some explanation in which source file (module) exactly the surface coordinates, sags, apertures (i.e. everything which defines an optical surface) and the layout rays are converted to something which gnuplot can plot. Then I could write something similar for vtk plotting and a command like "VTK" instead of "VIE".

Best regards, Jonas

dinosauria123 commented 2 years ago

you will see gnuplot folder in KODS folder. The gnuplot folder has plotting data corresponding to color data.

All plotting done by gnuplot.f in gnuplot folder among source files. You will see the functions which corresponding colors.

Jonas231 commented 2 years ago

Okay. Thank you. I will check this out: https://github.com/dinosauria123/Koko/blob/master/Src/plotcad/gnuplot.f

Jonas231 commented 2 years ago

Or more exactly what I am looking for are the KDP/Koko data arrays (names of fortran arrays and module names) wherein the data to be plotted is stored.

dinosauria123 commented 2 years ago

I try to remenber memories of several years ago... please wait.

I rebuild koko-gui.exe to work with koko-cli.exe. Place koko folder on your desktop and edit .kokorc PATH to fit your username.

https://github.com/dinosauria123/Koko/releases/download/untagged-1ad8ab22029e39255c87/koko.zip

dinosauria123 commented 2 years ago

the KDP/Koko data arrays (names of fortran arrays and module names)

Check "P1ARAY" array. IK is a surface number and other index are flags for plot data or not and plot colors.

Jonas231 commented 2 years ago

Thank you. The link you provided for the new "koko.zip" does not work. I will check the array or some similar name...

dinosauria123 commented 2 years ago

Sorry for inconvinience. Check koko.zip on this page.

https://github.com/dinosauria123/Koko/releases/tag/20220129-win32-test

dinosauria123 commented 2 years ago

I try to compile koko-cli on MSYS64 mingw-w64-x86_64-toolchain. I found linking error caused by missing regex library.

I build regex library for MSYS64 env and it is possible to build koko-cli.exe.

My regex librery atteched below. copy your home dir and "make install" will copy needed libraries regex-2.7-src.zip .

Jonas231 commented 2 years ago

I checked out the most important arrays that I would have to access from C++ in order to do a 3D layout plot with vtk:

Maybe you have some experience how to make these arrays accessable from C++? Another approach would be to write a vtk file with a Fortran routine (perhaps VTKFortran) and read this file with C++, python or any other language that supports vtk.

Jonas231 commented 2 years ago

Just making some notes here: https://westgrid.github.io/trainingMaterials/materials/paraviewWorkshop.pdf https://www.xdmf.org/index.php/Write_from_Fortran

dinosauria123 commented 2 years ago

Maybe you have some experience how to make these arrays accessable from C++?

No, I am not.

linenoise library use C++ and F90. It was written by Ulf Grissmann. I think his source is something help you.