<div dir="ltr">Hi Barry,<div><br></div><div>Thanks a lot for the codes ! I will test it and let you know if it works.</div><div><br></div><div>Christophe</div></div><div class="gmail_extra"><br clear="all"><div>CIEMAT<br>Laboratorio Nacional de Fusión por Confinamiento Magnético<br>
Unidad de Materiales<div>Edificio 2 - Planta 0 - Despacho 28m<br>Avenida Complutense 40,<br>28040 Madrid, Spain<br>Tel: +34 91496 2582<br>Fax: +34 91346 6442<br><br>--<br><span style="color:rgb(0,128,0);font-family:Webdings;font-size:x-large">Q</span> <div>
<span style="background-color:rgb(255,255,255);white-space:pre-wrap">Por favor, piense en el medio ambiente antes de imprimir este mensaje.</span><div><span style="white-space:pre-wrap">Please consider the environment before printing this email.</span></div>
</div></div></div>
<br><br><div class="gmail_quote">On Thu, Sep 26, 2013 at 4:09 PM, Barry Smith <span dir="ltr"><<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
   Christophe,<br>
<br>
     Despite my LinkIn Endorsement for expertise in Fortran :-) I cannot pretend to be an expert in FortranXX but I have cooked up an example demonstrating accessing the Vec entries as if they are in an array of derived types. I've attached the example code; there needs to be a small C stub that defines the functions for your specific derived type name.<br>

Note that it will only work I think if your N is a compile time constant.<br>
<br>
<br><br>
<br>
    It worked with<br>
~/Downloads$ gfortran --version<br>
GNU Fortran (GCC) 4.8.1 20130404 (prerelease)<br>
<br>
<br>
    I do not understand exactly why it works since it uses F90Array1dCreate(fa,PETSC_SCALAR,1,len,ptr PETSC_F90_2PTR_PARAM(ptrd)); which has a single PETSC_SCALAR as a building block but … I hope it works for you. If it doesn't, let us know the compiler you are using and we may be able to get it working for that compiler.<br>

<br>
   Barry<br>
<br>
<br>
<br>
On Sep 26, 2013, at 4:41 AM, Christophe Ortiz <<a href="mailto:christophe.ortiz@ciemat.es">christophe.ortiz@ciemat.es</a>> wrote:<br>
<br>
> Hi all,<br>
><br>
> Me again !<br>
><br>
> I have read in previous posts that it is hard in Fortran to declare something similar to a typedef struct in C to manage a multicomponent problem.<br>
><br>
> Is it still the case ? Has the problem been solved ?<br>
><br>
> I am asking because my plan is to implement a multicomponent problem (in 1D), with many components that will be organized in arrays of two dimensions. In C I could define<br>
><br>
> typedef struct{<br>
> PetscScalar U;<br>
> PetscScalar V;<br>
> PetscScalar A[N][N];<br>
> } Field;<br>
><br>
> and then I could calculate the residual function with<br>
><br>
> F[i].U = ...<br>
> F[i].V = ...<br>
> F[i].A[k][n] = ...<br>
><br>
> which is quite convenient.<br>
><br>
> If in Fortran it is not possible to use a struct as in C, I am afraid I'll have to deal with<br>
><br>
> F(jdof,i) = ...<br>
><br>
> where I will have only jdof to address U, V and A[ ][ ], which can be difficult and not very convenient I guess. Before I move all my code to C, does anyone have an alternative idea to manage this multi(many)component problem in Fortran ?<br>

><br>
> Many thanks in advance for your help and suggestion !<br>
><br>
> Christophe<br>
<br>
<br></blockquote></div><br></div>