# Import or "translate" a FORTAN code in Processing

**URL:** <https://discourse.processing.org/t/import-or-translate-a-fortan-code-in-processing/9997>\
**Category:** Coding Questions\
**Created:** [April 5, 2019, 1:55pm UTC](https://discourse.processing.org/t/import-or-translate-a-fortan-code-in-processing/9997 "2019-04-05T13:55:28Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![bking](https://avatars.discourse-cdn.com/v4/letter/b/dc4da7/32.png) [@bking](https://discourse.processing.org/u/bking)\
**Post date:** [April 5, 2019, 1:55pm UTC](https://discourse.processing.org/t/import-or-translate-a-fortan-code-in-processing/9997/1 "2019-04-05T13:55:28Z")

</div>

Hi everyones,

I’m very interested with the synchronisation of globally coupled oscillators due to wonderful pattern it can make.

So, I would like to use the periodic signal of 5 oscillators and see how they synchronise they shift or recover there “natural” pattern oscillation.

The model of the research is based on kuramato model.

We can see several pattern based of kuramato model here  
[![](https://fr.wikipedia.org/wiki/Fichier:Spatial_synchronization_patterns_in_variants_of_the_Kuramoto_Model.png) ](https://fr.wikipedia.org/wiki/Fichier:Spatial_synchronization_patterns_in_variants_of_the_Kuramoto_Model.png)

 ![46](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/c/c85116aa739578a88a6166cd0b3981cf12738c8f.jpeg)

To do that, I think we could use a program all ready made in FORTAN.

I’m looking the best way to use theses numerical simulations of N coupled oscillation (of 5 pendulum for example, it would be enough).

In this program, synchronisation were run with and without noise to supplement and verify the analytical results.

The research is here [http://go.owu.edu/~physics/StudentResearch/2005/BryanDaniels/kuramoto\_paper.pdf](http://go.owu.edu/~physics/StudentResearch/2005/BryanDaniels/kuramoto_paper.pdf)

The program in FORTRAN is at the end of the research.

Finally, I will use the movement of each oscillator to control speed of motors by using Arduino. The 5 motors are ready to receive data from Processing. 😉

Thanks for your attention.

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [April 6, 2019, 11:19pm UTC](https://discourse.processing.org/t/import-or-translate-a-fortan-code-in-processing/9997/2 "2019-04-06T23:19:13Z")

</div>

Interesting project.

Is your question: “How do I import or translate Daniels’ FORTRAN code into Processing (Java)?” …?

There is no way to “import” FORTRAN. In theory, you could use f2j to compile Fortran77 directly to java, but I don’t think this is what you want. You will probably need to read it and rewrite it.

Do you want your sketch to your produce pictures, or sound, or both?

If you want sound, have you look at the Sound library for Processing, or minim? Those are your two main options for oscillators, unless you want to [write your own](http://www.drdobbs.com/jvm/music-components-in-java-creating-oscill/230500178) of course.

---

<div class="post-metadata">

**Author:** ![mcintyre](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mcintyre/32/14561_2.png) [@mcintyre](https://discourse.processing.org/u/mcintyre)\
**Post date:** [April 8, 2019, 3:00am UTC](https://discourse.processing.org/t/import-or-translate-a-fortan-code-in-processing/9997/3 "2019-04-08T03:00:46Z")

</div>

Neat!

It looks like at least [one person](https://medium.com/wwblog/java-fortran-integration-using-jni-7376879f45cd) has achieved something similar through a mix of C and JNI. I managed to compile the paper’s [example code](https://github.com/nickmcintyre/kuramoto-lorentzian-noise) with gfortran on macOS but… no output. Hmm.

---

<div class="post-metadata">

**Author:** ![mcintyre](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mcintyre/32/14561_2.png) [@mcintyre](https://discourse.processing.org/u/mcintyre)\
**Post date:** [April 8, 2019, 3:41am UTC](https://discourse.processing.org/t/import-or-translate-a-fortan-code-in-processing/9997/4 "2019-04-08T03:41:09Z")

</div>

Scratch that–it works! Change line 16 to `parameter (N=50) ! number of oscillators` and you should see output in a reasonable amount of time.

---

<div class="post-metadata">

**Author:** ![bking](https://avatars.discourse-cdn.com/v4/letter/b/dc4da7/32.png) [@bking](https://discourse.processing.org/u/bking)\
**Post date:** [April 8, 2019, 8:05am UTC](https://discourse.processing.org/t/import-or-translate-a-fortan-code-in-processing/9997/5 "2019-04-08T08:05:30Z")

</div>

I am very happy that you have successfully rewritten the code.  
But I do not know what the result should look like. Are these sinusoidal waves synchronizing? Or does it look like a pattern that looks like turbulence, or something else?

In my project, I would like the noise (by modulating it in a special way) to synchronize or desynchronize the speed of my motors.  
And later, what will be more interesting, I wish that the simple fact that I manually modify the speed of a motor (by blocking it a little), modifies the speed of an oscillator in the algorithm, and that the algorithm recalculates data to readjust motor speed.  
Will it be possible to do this with this algorithm? Later, with the data of the movements of the 5 phases of my 5 motors synchronized or not, on which I interact, I will transform these changes of speed into sound with minim library.  
So, for the moment, my question is: can you adapt your code to the processing language? Can I ask you or someone else to do it, for a fee?  
Thank you very much for your attention and your answers.

---

<div class="post-metadata">

**Author:** ![mcintyre](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mcintyre/32/14561_2.png) [@mcintyre](https://discourse.processing.org/u/mcintyre)\
**Post date:** [April 8, 2019, 5:35pm UTC](https://discourse.processing.org/t/import-or-translate-a-fortan-code-in-processing/9997/6 "2019-04-08T17:35:17Z")

</div>

I didn’t analyze or visualize the model output. This is the first time I’ve looked at FORTRAN in years and it’s kinda fun. I’m game to re-implement the model in Processing and started the project [here](https://github.com/nickmcintyre/processing-synchronization).

---

<div class="post-metadata">

**Author:** ![mcintyre](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mcintyre/32/14561_2.png) [@mcintyre](https://discourse.processing.org/u/mcintyre)\
**Post date:** [April 14, 2019, 11:56pm UTC](https://discourse.processing.org/t/import-or-translate-a-fortan-code-in-processing/9997/7 "2019-04-14T23:56:04Z")

</div>

@bking the basic implementation is done and the output looks reasonable–let’s move the conversation to GitHub issues.

---

<div class="post-metadata">

**Author:** ![bking](https://avatars.discourse-cdn.com/v4/letter/b/dc4da7/32.png) [@bking](https://discourse.processing.org/u/bking)\
**Post date:** [April 16, 2019, 9:24am UTC](https://discourse.processing.org/t/import-or-translate-a-fortan-code-in-processing/9997/8 "2019-04-16T09:24:27Z")

</div>

Great, Let’s see how will I can use your program with Arduino. I have a lot of exciting idea.  
I have just made a account on Github, and invite you Nick McIntyre in “my” _self OrganicNation._ (I’m not sure of the beauty of the name, I wanted to play with self organisation and auto organic nation).  
I 'm French. Now it’s 12.00 am to me and maybe 8 pm for you, so have a good night.  
My name is _bvking_ on GitHub too.  
See you there.
