0

If I have some real vectors, say vector_a, vector_b, vector_c, ...vector_n, how can I use a character input (for example 'vector_a') for writing the real vector_a?

This is an example:

 DOUBLE PRECISION :: g_xx( Nx, Ny, Nz ), g_xy( Nx, Ny, Nz ), g_xz( Nx, Ny, Nz ) 

 CHARACTER *10 :: g_ij

 g_ij = 'g_xx'

 PRINT*, MAXVAL( g_ij )

The last row is clearly wrong, because MAXVAL don't take in input a character.

How can I do?

blackhole
  • 1
  • 1
  • Welcome, please take the [tour]. Also, please use tag [tag:fortran] for all Fortran questions. I do not really understand what you are asking. You want to access a Fortran variable by its name stored in a character string? That is not possible and we have some existing questions and answers about that. – Vladimir F Героям слава Jan 20 '20 at 18:43
  • Yes, I want to access to a real vector using the corresponding character string. I searched in old questions but found nothing. Can you link me some threads about that? Thanks you – blackhole Jan 20 '20 at 19:24
  • Also https://stackoverflow.com/questions/9268418/interpret-strings-as-variable-names-in-fortran?noredirect=1&lq=1 https://stackoverflow.com/questions/28226498/fortran-dynamic-variables-names?noredirect=1&lq=1 – Vladimir F Героям слава Jan 20 '20 at 19:31

0 Answers0