# Fortran Wiki Questions

This page is for general questions about Fortran. If you’re searching for something, such as a library or routine to perform a particular task, feel free to ask here.

Q: Hi! I’m quite new in FORTRAN, and I´m using Microsoft Visual 2008 as IDE and Intel Fortran as compiler. I’d like to know how I can creat a fortran library using them and how I can link my code to the library. Thanks.

Q: Hi! I have a quite simple question: if I have an array of integers as A = (/1,2,3,4,5/), how do I convert this array in the number 12345? Thank you very much in advanced for your help Regards

A: There are a number of ways you could go about doing this. Perhaps the simplest is to create a loop over the array index and use integer arithmatic operations.

number = 0
DO i=1,SIZE(A)
number = number + A(i)*10**(SIZE(A)-i)
END DO

Note that I have not tested this to confirm it’s correctness, but it should be correct. If not, you could easily figure out where I made a typo or went wrong. One could also write the array elements to a character variable and then read the character variable back as an integer.

Q: Does anyone know how to overload intrinsic functions? Preeferably using f95 comnpliant syntax if possible. Thanks.

A: It’s actually simple. You just overload the function you want. For example, you can overload ABS:

module myabs

implicit none

type vector
real :: x, y, z
end type vector

interface ABS
module procedure absvector
end interface ABS

contains

real function absvector(vec)

type(vector), intent(in) :: vec

absvector = sqrt(vec%x ** 2 + vec%y ** 2 + vec%z ** 2)

end function absvector

end module myabs

If you test this, you’ll see that you can now call ABS with REAL, INTEGER, COMPLEX, and even vector.

category: help