6.3.6. STEP 6 : Extand the rank of vectors

Every position in a mesh will be located by indexes (i, j) : It is necessary to add a new dimension to the vectors (not all!). Then, the loops over i have to be increased by a j loop (if necessary…).

It is proposed to go through this step in 2 stages.

6.3.6.1. Step 6A

Define the value NY the total number in the y direction: at this point it must be equal to 1.

Seek for all the loops over the mesh (generally the index is i). Add a loop over j that goes from 1 to NY …

6.3.6.2. Step 6B

Increase the rank of the vectors, if necessary.

You should have noticed that the unknown vector is VAR. Its rank is 2 and its dimensions are 0:NX+1 and NEQ.

It is defined by VAR( 0:NX+1, NEQ): the first index is related to the location in the mesh, the second is related to the unknown that is to say the equation considered. This vector will have to be defined by VAR( 0:NX+1, 0:NY+1 ,NEQ).

Hint

Not very tricky, the stage 6B must be done very carefully: Choose one vector to increase its dimensions, and track it through the program before picking another vector. Then :

  • Compile. Use the compilation option th check the bounds of arrays (with gnu fortran -fbounds-check)
  • Save the file in a temporarely version.
  • Choosee an other vector.
  • Redo.

For example: take your main.f90 file from the step6A. Name it main6b1.f90. Change all the dimensions in the vector VAR. Compile. If there is no error, name the file main6b2.f90 and redo on the next vector of your choice. The solution is recovered only when all dimensions are extended…