Git Product home page Git Product logo

Comments (3)

benjaminmenetrier avatar benjaminmenetrier commented on August 16, 2024

OK, I have found the solution for the ATLAS State that I am finally using:

  • in C++ :
    • declare a State pointer:
    State * state = new State(...)
    
    • pass it to the Fortran function:
    my_fortran_subroutine_f90(state, ...)
    
  • in the C interface: pass the State pointer
extern "C" {
  void my_fortran_subroutine_f90(State * state, ...);
}
  • in Fortran: get the State pointer as a type(c_ptr) and use it to initialize a type(atlas_state):
subroutine my_fortran_subroutine_c(state_ptr,...) bind (c,name='my_fortran_function_f90')

type(c_ptr),intent(in),value :: state_ptr
type(atlas_state) :: state

state = atlas_state(state_ptr)

end subroutine my_fortran_subroutine_c

Maybe it would be worth adding an example in the documentation. Not a top priority though...

from atlas.

wdeconinck avatar wdeconinck commented on August 16, 2024

Hi @benjaminmenetrier I'm happy you figured it out.
Perhaps I could advise to you to use atlas_FieldSet instead of atlas_State?
The State is more of an experimental tryout I once did to show Yannick Tremolet what is possible.
Conceptually it is the same as a FieldSet with the difference that it could be constructed from a configuration as shown experimentally here:
https://github.com/ecmwf/atlas/blob/0.19.0/src/tests/grid/test_state.cc#L137
If you don't need that, then you could probably use FieldSet instead, as that is more widespread used in API's, and maintained.

from atlas.

benjaminmenetrier avatar benjaminmenetrier commented on August 16, 2024

Thank you for the tip! I'll switch to FieldSet now, before the use of State is too widespread in the code...

from atlas.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.