I have a Fortran code which parses a large input file and sets up global
variables to be used by other programs (see code below)
what would be the correct way to return more than one variable assigned in
the parsing module? Eventually, I will need to create a large number of
these variables.
Declaring a tuple of returned types does not work:
ccall( (:__global_variables_MOD_
emdata_read_input, "libglobvar"), (Float64, Float64), ())
Nor does calling on Julia's multiple assignment
x,y = ...
Any suggestions?
Thx,
Ben
***************Code Example******************
MODULE global_variables
IMPLICIT NONE
SAVE
! Variables that are read from the input file
! Frequency
REAL(kind=8)::freq
! current in the wire-type source.
REAL(kind=8)::j_s
! magnetic moment for the magnetic point dipole source
REAL(kind=8)::j_m
!-----!-----!-----!-----!-----!------!------!------!------!-------!
!-----!-----!-----!-----!-----!------!------!------!------!-------!
!-----!-----!-----!-----!-----!------!------!------!------!-------!
CONTAINS
SUBROUTINE EMdata_read_input(inputfile)
! This subroutine reads data from the input file
IMPLICIT NONE
CHARACTER (LEN=*), INTENT(IN) :: inputfile
INTEGER::ni,i
! Reading the frequency from the input file
OPEN(11,FILE='csem3dfwd_test.in')
READ(11,*)
READ(11,*) freq
print*, "FREQUENCY", freq
! Reading the current in the wire (if a wire source is used)
READ(11,*)
READ(11,*) j_s, j_m
print*, "CURRENT", j_s
CLOSE(11)
END SUBROUTINE EMdata_read_input
!-----!-----!-----!-----!-----!------!------!------!------!-------
!-----!-----!-----!-----!-----!------!------!------!------!-------!
END MODULE global_variables