Blame view

SOFTWARE_NOTES/fortran_implementation_notes.txt 3.76 KB
886c558b   Steve Greedy   SACAMOS Public Re...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
___________________________________________________________________________

Fortran90 data types

Fortran90 real (and complex) types can be specified in different ways:

F90 has intrinsic types:
real and double precision

we could also specify:
real and real*8 though real*8 (8 byte real) is not in the F90 standard though most compilers support it

An alternative is to use kind e.g.
real(kind=kind(1d0))  for double 
real( kind=8 ) is often used but the meaning of the integer value of kind is compiler dependent and does not
always mean an 8 byte real for kind=8 (e.g. Salford fortran)


STARTED:  Set up integer, real and complex types consistently from the module TYPE_SPECS_AND_CONSTANTS/type_specifications
   and propagate to all codes
NOT DONE integer types yet- need to find out what they look like...

___________________________________________________________________________

Error handling.

We need to indicate the correct termination of each of the processes implemented.
One way to do this is to use STOP with an error code as follows:

In fortran90 programs finish with the STOP command using an integer argument which indicates
either correct completiion or an error
i.e. correct termination of the program is implemented as

STOP 0 

or termination due to an error is implemented as

STOP err_code

This MAY allow the interface code or testing script to detect errors in the process from the
return code but this is NOT in the standard so maybe a better way is to usea file to indicate
correct termination of the processs.

STARTED: we use the STOP err_code on termination of the software modules however 
checking whether the code has finished correctly or with an error should be based on looking
at the run_status file.
________________________________________________________________________________

Module based code:
The fortran code should be based on modules which are then included with the USE statement. 
This ensures that the interfaces between subroutines are consistent and checked in the compilation

Note that we must ensure that the SAVe attribute (or statement) is used appropriately in modules
to ensure that variables are saved correctly whn using modules to hold common data. 
______________________________________________________________________

Useful online information

Use of makefiles in multiple directories:

http://stackoverflow.com/questions/12944291/makefiles-in-multiple-directories
https://www.gnu.org/software/make/manual/html_node/index.html#SEC_Contents

___________________________________________________________________________

How to implement a new cable type

1. In CABLE_MODULES/cable_module.F90 include a new cable type with its own unique number

2. Create a new .F90 file in CABLE_MODULES directory for subroutines related to the new cable type

3. include this file in CABLE_MODULES/cable_module.F90 and add it to the dependencies in CABLE_MODULES/Makefile 

4. Create a subroutine to to set the number of conductors, domains, parameters etc.
   In cable_model_builder.F90 add call to this subroutine.

5. If there are internal domains then create a subroutine to allocate and set the
   internal inductance and capacitance matrices and domain decomposition matrices
   In cable_model_builder.F90 add call to this subroutine.

6. In CABLE_BUNDLE_MODULES/cable_module.F90 include a new cable type with its own unique number

7. Create a new .F90 file in CABLE_BUNDLE_MODULES directory for subroutines related to the new cable type

8. include this file in CABLE_BUNDLE_MODULES/cable_module.F90 and add it to the dependencies in CABLE_BUNDLE_MODULES/Makefile 

9. Create a subroutine to to set the bundle information for this conductor i.e. add any new domains required
   create conductors in the external domain.
   In cable_bundle_model_builder.F90 add call to this subroutine.