Science topic

Programming in Fortran - Science topic

Explore the latest questions and answers in Programming in Fortran, and find Programming in Fortran experts.
Questions related to Programming in Fortran
  • asked a question related to Programming in Fortran
Question
3 answers
mpi.mod is the error
#funwave
#linux
#gfortran
Relevant answer
Answer
To resolve this issue:
1. Double-check the file or directory path: Verify that the file or directory in the error message actually exists in the specified location. Make sure there are no typos or missing files.
2. Check the working directory
3. Include search paths
4. Verify file permissions
5. Check dependencies
Good luck
  • asked a question related to Programming in Fortran
Question
2 answers
Dear all,
I would like to update the yield strength value in a UMAT subroutine in Abaqus. This would happen when a load is applied on an element, the deformation strain would be queried from a meta-model database, and depending on the deformation strain combinations returned by abaqus, the yield strength of the material in the function PROPS() would be updated from the database. I am very new to writing subroutines in ABAQUS. I was wondering if there is a way to implement such an algorithm to update the material properties in each time step. If so, how can I start tackling this issue?
Any help is greatly appreciated. Thanks.
Relevant answer
Answer
the material properties in props array of a umat are constant for the whole analysis and are defined in the material card at the preprocessing stage. If I understand correctly, you have developed a user material that calculates the stress update and the material Jacobian for each increment. In that case the material properties that are needed for your calculations would be retrieved from the meta database (you need to have access of this database in the umat) and not from the props array that is passed as argument in the umat. Then you can proceed with the calculations using the correct value of your material properties.
  • asked a question related to Programming in Fortran
Question
3 answers
Dear All,
Hope you are fine and doing well in this pandemic.
I am working on a FORTRAN program, where I need to sum the Gaussian functions over time. I have observed that my computing time is scaling linearly with the number of iterations. I found FFT is useful for such tasks while reading about techniques to reduce the iterations. So, my question is if FFT can efficient for my task, how can I implement it?.
Pseudocode or suggestions are appreciated.
Cheers!
Anji
Relevant answer
Answer
did you read "Five-step FFT algorithm with reduced computational complexity", please see the follwoing link, may be it will help you.
  • asked a question related to Programming in Fortran
Question
4 answers
For Example, I have a South Carolina map comprising of 5833 grid points as shown below in the picture. How do I interpolate to get data for the unsampled points which are not present in 5833 points but within the South Carolina(red region in the picture) region? Which interpolation technique is best for a South Carolina region of 5833 grid points?
Relevant answer
Answer
Dear Vishnu,
in which format is the data, which you would like to interpolate, available: NetCDF, ASCII-Text, Excel, ... ?
  • asked a question related to Programming in Fortran
Question
6 answers
I am using MS Visual Studio Fortran. I need to incorporate the ERF function in my code.
How to use erf function? I have tried with the example given in help of MS Visual studio, however, it is not working. Kindly help.
Relevant answer
Answer
Hello,
I send you two graph of our function erf(z) depending of y where z=x+iy for x=10 and x=1 with.
Best regards,
Bryan.
  • asked a question related to Programming in Fortran
Question
4 answers
Does anyone have any helpful information (Organised governing equations & subroutine files) about Two & Three surface models which are developed by Shen & Goto respectively?
Regards,
Qusay
  • asked a question related to Programming in Fortran
Question
3 answers
I want to know How I can map the stress when preformed buckling and post-buckling.
I read in one thesis, author mentioned about SIGINI/HARDIN subroutines. Unfortunately he did not explain about it or provide the code. I have got the residual stresses distribution however its not for the full scale section
So, i want to map these stresses/strains to the section using SIGINI/HARDIN subroutines.
Any guidence please?
  • asked a question related to Programming in Fortran
Question
68 answers
Which programming language is the best to use in CFD?
FORTRAN, MATLAB or any other?
Is there difference between the performance of these codes and applications such as OpenFOAM?
Relevant answer
Answer
You may like to use an open source automated PDE solver such as Fenics:
You need to do a minimal coding (either in C++ or Python ) for writing a variational form for your problem and defining the input functions.
.
  • asked a question related to Programming in Fortran
Question
3 answers
I would like to write data in fortran (90 and onwards including 2008) binary format to get the result much quickly and convert into text file so that data can be visualized using Matlab or R.
Relevant answer
Answer
Dear Marcus,
thank for the answer. I had gone through those link. I would like to if ask is there way to convert fortran binary file into text file without any alteration ?
  • asked a question related to Programming in Fortran
Question
7 answers
hi .
Abaqus question;
Hi, I have intel visual fortran compiler 9.1 and Abaqus 6.13-2 versions. I want link abaqus-fortran.
Afte following suggestion here , I did the following.
Abaqus cae..properties . "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64\vcvars64.bat" & "C:\Program Files (x86)\Intel\Compiler\Fortran\9.1\em64t\bin\ifortvars.bat" && C:\SIMULIA\Abaqus\Commands\abq6132.bat cae || pause
Abaqus command..properties .  "C:\Program Files (x86)\Intel\Compiler\Fortran\9.1\em64t\bin\ifortvars.bat" & "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64\vcvars64.bat" && C:\Windows\SysWOW64\cmd.exe /k
Abaqus verification .properties .  "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64\vcvars64.bat" & "C:\Program Files (x86)\Intel\Compiler\Fortran\9.1\em64t\bin\ifortvars.bat" && C:\SIMULIA\Abaqus\Commands\abq6132.bat -verify -all –log
And also I opened abq6132.bat file and I modified as
@echo off
@call "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64\vcvars64.bat"
@call "C:\Program Files (x86)\Intel\Compiler\Fortran\9.1\em64t\bin\ifortvars.bat"
"C:\SIMULIA\Abaqus\6.13-2\code\bin\abq6132.exe" %*
But still I get the error
LINK : fatal error LNK1181: cannot open input file 'msmpi.lib'.
In my Programfiles(X86) I could not find any file named 'msmpi.lib' in any visual studio or fortran or abaqus folders.
Can anyone please help me in solving this issue.
Thanks
Relevant answer
Answer
SOLVED!!
it's simply due to the incompatibility of your microsoft MS-MPI product.
Please uninstall your current MS-MPI package and install with "msmpi installer" from your Abaqus installer DVD (iso).
  • asked a question related to Programming in Fortran
Question
3 answers
Does the Linux version of Abaqus provide the user with more freedom and control over the simulation? Can the necessary subroutines be written in Python?
Relevant answer
Answer
I have benchmarked both linux and win versions of Abaqus 6.9 on the same workstation (8 cores) and the linux version run faster. I attributed this to better handling of memory and efficient hard drive writing.
  • asked a question related to Programming in Fortran
Question
5 answers
I am in the process of establishing the appropriate initial conditions of a saturated soil base, submerged in water (i.e. a seabed). I have encountered some difficulty initializing stresses and void ratio for coupled pore-stress analysis using the built in Abaqus functions and as a result, I need to make use of subroutines SIGNI and VOIDR. I have searched the ABAQUS documentation and google for any examples of these subroutines, but the best I can find is simple descriptions like this, which do not offer any examples of actual code: http://web.mit.edu/calculix_v2.7/CalculiX/ccx_2.7/doc/ccx/node264.html
Does anyone have a sample of SIGNI and VOIDR subroutines that you have written and implemented in a simple Abaqus model? If I could just see how the two subroutines are applied to a working model, I can certainly extrapolate and adapt the code to meet my particular model specifications.
Related to project:
Relevant answer
Answer
Hi Ryan,
The SIGINI and VOIDRI subroutines supply the initial stress components and voids ratio at the integration points of the mesh elements. May I ask why you are using these?
My experiences of these subroutines is linked to my research into extrusion of particulate pastes, which can behave as soils in that the pore fluid and solids matrix can phase separate over time.
Extrusion involves very high strains (10000% or even higher). Thus, the finite element mesh becomes very distorted and one must periodically replace or repair the mesh to continue the simulation. I used the replace approach in the above papers, which meant I had to stop ABAQUS periodically, draw a new mesh with external code, interpolate the stress components, voids ratio and pore pressure from the old mesh to the new mesh and restart ABAQUS using the interpolated data as initial conditions. I used SIGINI and VOIDRI to supply the interpolated stress components and voids ratio at the integration points (IPs) of the elements in the new mesh. SIGINI and VOIDRI are called for each IP within each element. So if you have a 100 element mesh with 8 IPs per element and 6 active stress components per IP, VOIDRI will be call 800 times as ABAQUS initialises the simulation, while SIGINI will be call 800*6=4800 times.
Within the SIGINI subroutine, ABAQUS will tell you which particular element and IP number that the stresses are being requested at. This will change during each call of SIGINI. Back when I was using ABAQUS 6.12, SIGINI did not call for the elements in ascending numerical order, although once it requested stresses for element X, it did request them at the IPs for element X in numerical order, i.e. elem X at IP 1, elem X at IP 2, etc. Thus, SIGINI passes in the element and IP numbers as arguments for you to use when you are calculating the stress at that location. In version 6.12, for some stupid reason I never understood, VOIDRI passes in just the element number and not the IP number. I dealt with this ambiguity by testing and realising that VOIDRI is called for the various elements and IPs in exactly the same sequence as for SIGINI - thus, whenever SIGINI was called, I stored the integration point number argument that it use (NPT) to an external file that VOIDRI then accessed immediately afterwards. SIMULIA may have fixed this unbelievably stupid omission since then, so do check if the argument list for VOIDRI includes the NPT argument which is defined for SIGINI.
With respect to my particular code, I defined the stresses and voids ratios in external text files and opened them at the start of the simulation using the UEXTERNALDB user subroutine. That allows the files to be accessed by SIGINI and VOIDRI during initialisation. Anyway, reading in all of this data meant that ABAQUS was spending a long time reading data off my hard disk . I was able to speed this up by changing the default type of file reading used by ABAQUS ('sequential access') to a much faster type called 'direct access'. This requires that the external data files have a fixed number of characters in each line ('record length'). Thus my code is not the simplest example of SIGINI/VOIDRI usage. However, if you have a little coding experience, you should be able to pick up what I am trying to do in the subroutines.
Anyway, let me know how you go.
Milan.
  • asked a question related to Programming in Fortran
Question
4 answers
I am attempting to conduct a coupled pore-fluid/stress analysis beginning with a geostatic step but I am having convergence problems, in particular the error for ZERO VOLUME FLUX.
After some research, I learned that I can manipulate General solution controls so this error is eliminated, but I am not sure which field to change or what value to change it to.
Also, there is a bug in the CAE software that prevents changing the general solution controls using the GUI, which means I must manipulate the input file. Between which lines in the input file does the *Controls edit go? Can anyone include a sample input file with this implemented?
Attached is the input file for my model.
Relevant answer
Answer
Hi, I always use:
*CONTROLS, ANALYSIS=DISCONTINUOUS on Step part.
The another way is:
*INITIAL CONDITIONS, TYPE=STRESS, FILE=(Your previous step).odb, STEP=1, INC=1
Change GRAV to Body force.
Good luck
  • asked a question related to Programming in Fortran
Question
13 answers
Dear researchers,
I'm looking for an open-source FEM software compatible with ABAQUS subroutines. I know there are a few open-sources FEM software available. But the question is; Is there any open-source FEM compatible with ABAQUS routines? or can be compatible with minor changes in the code?
To conduct my simulation, I need to run a few routines but they are ABAQUS subroutines and are written in FORTRAN and I don't have access to ABAQUS license for now. I know that ABAQUS has a student version, but this version has limitations among which is a restriction on running routines.
Any comments and pieces of advice are highly appreciated.
Best,
Farhad
Relevant answer
Answer
Hi Farhad,
You could try Calculix. I've used it for running ABAQUS-like input files, although I haven't tried out its user subroutine interface.
Let me know how you get along - I am curious :)
Milan.
  • asked a question related to Programming in Fortran
Question
1 answer
I m trying to extract energy at each integration point in Abaqus. I can do it for stresses or strains but i cant do for the energetical quantities. The obtained error is : “KeyError: 'ELEN'”, but in Abaqus it is the good keyword… Below it is my code to extract it :
from odbAccess import *
import numpy as np
odb = openOdb(path='C:/Desktop/Fish1.odb')
# lastFrame = odb.steps['Step-2'].frames[-1]
lastFrame = odb.steps['Step-1'].frames[-1]
topCenter = \
odb.rootAssembly.instances['PART-1-1']
stressField = lastFrame.fieldOutputs['ELEN']
field = stressField.getSubset(region=topCenter,
position=INTEGRATION_POINT, elementType = 'CPS3')
fieldValues = field.values
sortie = open('C:/Users/tests.txt', 'w')
sortie.write('Eleme \t Integ \t\t PE11 \t\t\t PE22 \t\t\t PE12 \n')
for v in fieldValues:
sortie.write('%-10.2f'% ( v.elementLabel))
if v.integrationPoint:
sortie.write('%-10.2f'% (v.integrationPoint))
sortie.write('%-10.3f\t\t %-10.3f\t\t %-10.3f\t\t %-10.3f\t\t \n'% (v.data[0], v.data[1], v.data[2], v.data[3]))
sortie.close()
Relevant answer
Answer
Strain and Stress both are vector quantities, but energy is scalar one. So you may be trying with the same format as you are doing for stress and strain. After reaching to the values[0], do not try to get the data with direction i.e values[0].data[1] etc. I am writing an example below. You can try in same way. I hope this should solve your problem
Energy = ELEN.getSubset(region =    ,position = centroid)
Finalenergy = Energy.values[0].data
  • asked a question related to Programming in Fortran
Question
4 answers
Hi,
Is it possible to import output result of Matlab(for example eps format i.e mesh. eps) in Fluent or CFX?
This output result of Matlab is a mesh file.
Another question:
Is it possible to export output result of Matlab in Fluent or CFX?
Thanks for your help.
best.
Relevant answer
Answer
hi
you can use in fluent this instction
file -import -mechanical apdl- selected all file and insert your file.eps .
The same for the second equation
  • asked a question related to Programming in Fortran
Question
3 answers
I am simulating a metal cutting process in Abaqus / explicit and want to implement a damage model using the VUSDFLD and VUHARD subroutines. As it is the first time I am going to write a subroutine and I am not experienced with programming, I do not have idea on how to do it.
Does anyone could share any examples of these two subroutine models (pdfs or a fortran file) from which I can base my work on? It would be a great help!
Thanks
Relevant answer
Answer
It's been a while since I worked on this, but I think the two files here should help you: I used a user-defined boundary condition to store the position of the tool tip so that elements are only deleted there; the deletion is done using VUHARD with a johnson-cook law.
  • asked a question related to Programming in Fortran
Question
7 answers
Hi !
I'm a MSc student working on an annual long term survey of Maldivian coral reefs. I would like to use the Wave Exposure Model (WEMo) for a hydrodynamic impactassessment. I have some problem with the used software... I downloaded and installed the WEMo Version 4, (ArcGis 10.2 is installed) but when I try to open it an error text appeared :
"Run-time error '-2147221002 (800401f6)' :
ArcGIS product not specified.You must first bind to an ArcGIS version prior to using any ArcGIS components"
What I have to do ? Do you have some advices for me ??
Thank you for your help,
Fanny
Relevant answer
Answer
Dear Professor Surender Singh,
Thank you very much for your help.
  • asked a question related to Programming in Fortran
Question
3 answers
The array elements include zeros in the first few rows and standard scientific notation real elements in Fortran format in other rows. The result of the code I wrote does not give me the exact input data. Negative signs are omitted and the values of the exponents are also ignored.
Find below the code written and the attached file containing the array elements in .txt format to serve as the input data
program test_processing
implicit none
integer :: j
integer :: i
integer, parameter :: n=800
integer, parameter :: m=800
real, dimension(m,n) :: g
real, parameter :: out_unit=6
open ( unit=15,file="recvx_4.txt", status='old', &
access='sequential', form='formatted', action='read', RECL= 1200)
call random_number(g)
do i=1, m
do j = 1, n
read (15, 110) g(i,j)
110 format (800(18X,E14.5E3))
write (6, 120) g
120 format (800(18X, E14.5E3))
open (6,file="matrix.txt",action="WRITE",status="replace", RECL = 1200)
write (6,120) g
PRINT *, g
close (6)
end do
end do
end program test_processing
Relevant answer
Answer
There are a few areas where I can see that your code might cause a problem ... you have two WRITES and a PRINT ?? How much output are you trying to generate? Did you notice that your WRITE format statement skips 18 columns (18x), and does this 800 times? If you really have 800 wide array, your RECL is not correct (1200). Are you sure you have the correct syntax for reading scientific notation?
Some basic text on FORTRAN input and output will help. If you are an expert and just having some small problems,the areas I mention above might help.
  • asked a question related to Programming in Fortran
Question
1 answer
Hello, everyone. I'm interested in the CICSAM scheme and HRIC scheme. I have difficulty to apply the CICSAM or HRIC scheme in FORTRAN. Who can send me a simple CICSAM or HRIC scheme code FORTRAN. I appreciate your help.
Relevant answer
Answer
Dear Hamed,
I am pretty sure you can find CICSAM implementation in OpenFOAM. you may have a look at the extended foam project. It would be in C++ but that would probably make it easier to understand what you need to do. You can also find Obbink thesis easily (Numerical prediction of two fluid systems with sharp interfaces) which will provide more details if you don't already have it.
Good luck
Sina
  • asked a question related to Programming in Fortran
Question
2 answers
IFTRAN is a precompiler that produces FORTRAN code. It was developed in the 1970's.
Relevant answer
Answer
Thank you so much, Graeme.
Long time no see!
All the best.
Tony
  • asked a question related to Programming in Fortran
Question
1 answer
We are currently using a FORTRAN-based software developed in my institution, and I would like to compare its performance with other available software.
Relevant answer
Answer
thank you Dr. Scarlato. 
  • asked a question related to Programming in Fortran
Question
22 answers
I would like to learn FORTRAN to build a solver for numerical difference techniques..so I would  be delighted to know where to start with and how to proceed.
Relevant answer
Answer
What is your reason to pick FORTRAN for this task? The major disadvantage I see is that you can either write modern Fortran or fast Fortran. You cannot have both at the same time. (I had this proven to me by someone from the Fortran standardization committee. If you write proper object-oriented code in Fortran it might be slower by a factor of 100.) There are other languages out there that make it a lot more easy to write readable, modern code without any impact on performance. And believe me that readability can save you hours. If you are interested in this discussion I can try to find an old thread here on RG about which language to use for numerical problems.
  • asked a question related to Programming in Fortran
Question
2 answers
.
Relevant answer
Answer
Thank you Sir for your response, I have already written in 2014. 
  • asked a question related to Programming in Fortran
Question
14 answers
Hi
I have wrote a program in FORTRAN 95 but it has an error.I do not  Which part of my program is wrong.
Could you help me? Thanks.
Relevant answer
Answer
You did not ALLOCATE an array that is defined as ALLOCATABLE. You have to introduce a line
ALLOCATE(F(60,60))
before assign any value to the array. Now the program is running.
  • asked a question related to Programming in Fortran
Question
1 answer
I have installed CYGWIN interface with a GNU fortran 77 compiler on my system.
When I want to compile a file with this compiler I have to navigate to the folder that the source file is. The question is that how I can compile an arbitrary Fortran code from any where simply refering to its location. For more details please follow these commands that I quote from my cygwin command windows:
--------------------------------------------------------------------------------------------------
farzi@farzi-PC /cygdrive/c/a
$ dir
mytest1.f
farzi@farzi-PC /cygdrive/c/a
$ g77 mytest1.f -o mytest1
farzi@farzi-PC /cygdrive/c/a
$ ./mytest1
Enter number of equations (up to 1000): 5
exact = 0.0666666667
Max. difference was 0.000000000000% of the exact in eq. No. 1
Solution of the linear system of 5 equations took 0.00 seconds
Want to run again (y/n) ? : n
------------------------------------------------------------------------------------------------
The compile is successful(after navigation to the source folder in c:\a).
However, note the following alternative:
-------------------------------------------------------------------------------------------------
farzi@farzi-PC /cygdrive/c
$ /cygdrive/c/a/g77 mytest1.f
-bash: /cygdrive/c/a/g77: No such file or directory
farzi@farzi-PC /cygdrive/c
$ g77 /cygdrive/c/a/mytest1.f
g77.exe: /cygdrive/c/a/mytest1.f: No such file or directory
-------------------------------------------------------------------------------------------------
This time the g77 fails to compile the sample code.
How I can resolve this problem?
Relevant answer
Answer
  Your example works for me,
$ pwd
/home
jjc@hpc03 /home
$ ls /cygdrive/c/cygwin/home/jjc/hello.f
/cygdrive/c/cygwin/home/jjc/hello.f
jjc@hpc03 /home
$ g77 /cygdrive/c/cygwin/home/jjc/hello.f
jjc@hpc03 /home
$ ./a.exe
hello
The directory structure for cygwin looks
strange, though.  I always see
/cygdrive/c/cygwin/home/
as the directory in which user's home directories are under.
  In your last command, change g77  to ls
My guess is that you still get No such file or directory, since I believe that
this has nothing to do with the compiler, but has something to do with the Cygwin install.
  • asked a question related to Programming in Fortran
Question
2 answers
Hello,
 I am a beginner in Fortran Programing ,
I have conceived a numerical code with Finite Volume Method , in an enclosure
can any one tell me how I can create a solid adiabatic(a blocked_off regions) inside an enclosure
I found in Patankar's book that it mus retain the source terms , Sp=-10e30
But I can't do that with velocity contour.
Relevant answer
Answer
Dear   SOUFYANE BENMENZER 
Please see the attached report, it may help you on how to treat the solid regions.
Please provide more explanantions as I did not understand your question.  
  • asked a question related to Programming in Fortran
Question
2 answers
When the thermal cycles of welded structures are simulated with ANSYS APDL, codes are programmed in Fortran.
My question is whether in the case of ANSYS CFX the same programming language used.
Relevant answer
YES, you can use FORTRAN. You can use the CCL  (CFX Command Language)  through the expressions, or as Arun has written, with Pearl scripts. You can generate  calculations routines, procedures to post processing in the CFD-Post. Some calculation procedure as turbo machines or FFT are native in the software.  
If you need a specific calculation, define source term, a boundary condition, or other expression to be evaluated in execution time by the SOLVER you can use also Fortran user routines  or CCL. In the newer releases, the CCL became more flexible  working with gradient, and IF statement, what avoid the  Fortran coding. But  it depends on the case and the complexity of your problem. 
Attached it has my PhD thesis. Is in portuguese, but does not matter. In the appendix you will find a CCL  example with a a momentum source  with dot product of a Tensor and a gradient Vector. Look  for EXPRESSIONS. In early versions, this procedure   would be made with FORTRAN subroutines. The other  parts of script  regarding to setup. But is also part of CCL . 
  • asked a question related to Programming in Fortran
Question
5 answers
Has anyone worked with grib or netCDF files using Fortran? I want, for instance, to find the min/max values of my table etc. Do I have to use the grib filter each time I want to download the data or is there a way to extract each value I want through the code?
Relevant answer
Answer
wgrib offers the possibility to create readable binary files or a text file (without headers). But if you want to be more flexible, I would also suggest the grib api, which is generally also much faster.
If you have grib2 files, you might want to consider wgrib2, which can put out stats of each message by using the command wgrib2 -stats file_name.
  • asked a question related to Programming in Fortran
Question
16 answers
I have an R package and I want to update it by giving the option to run a pre-compiled .dll made from a Fortran source, since by this way it is very fast.
The problem is that I'd like to have except .dll (Windows executables) the .so files (linux executables) in order for the package to continue be platform-independent.
Is there any way to produce both of them? I have downloaded 'Eclipse' tools - will they help for this reason? (I am working with Windows 7 and GCC GNU compilers for the moment; Cygwin also available).
Any suggestions? Thank you.
Relevant answer
Answer
I agree there are no miracles ! You either choose to make your code portable, in which case you provide the source code and let your IDE do the work, or you optimize/tweak the crap out of it and compile the modules yourself, but in that case you have to stick with the CPU/architecture you are working on.   As they say, "there's no FREE LUNCH".   What a pitty :(
  • asked a question related to Programming in Fortran
Question
9 answers
I would like to know if a function/subroutine/system call exists to output the amount of physical memory used by my Fortran code.
I'm currently facing some memory leaks and I would like to understand exactly where they are coming from.
I am using ifort compiler on windows (Intel Inspector is not an option for the moment).
Relevant answer
Answer
As far as I know there is no function directly available in Fortran. The easiest way to do this is to write a function in C which uses according functions from the operating system and computes the information that you need. Then, you call this C function from within Fortran. For this you need an interface written in Fortran which will fit the interface of the C function (the Fortran keyword BIND(C) is very helpful for this).
What Hamidreza mentioned about unintentional copies being made there is a way to figure out where this occurs. The compiler will not tell you directly. But, when you compile with ifort using the flag '-check all' you will get runtime warnings when copies occur. You should be aware, though, that this compiler flag turns off all optimizations. Because of this your software will run up to 10 or 20 times slower.
  • asked a question related to Programming in Fortran
Question
6 answers
I have a matrix and i have shown the output of matrix one by one element in FortranForm. 
the problem is i want to put "&" continuation charater in output because when I am copying the data into fortran Code, Fortran is showing warning that it exceeds 2048 characters .
So i wanted to put ampersand character in each output of matrix element in FortranForm. please help
Relevant answer
Answer
you could use a format as follows:
100 format(6(1x,f12.6),a1)
do i=1,nrow
write(10,100)(mat(i,j),j=1,6),achar(38)
enddo
**** or
100 format(6(1x,f12.6),'&')
do i=1,nrow
write(10,100)(mat(i,j),j=1,6)
write(10,100)(mat(i,j),j=7,12)
enddo
****
the achar(38) is ampersand... the following program will give you part of the table.
program achartable
do i=1,200 ; write(*,100)i,achar(i) ; enddo
100 format(i3,1x,a1)
end
****
please give your feedback
  • asked a question related to Programming in Fortran
Question
7 answers
Looking for Fortran compiler suitable for TRNSYS 17. Any suggestions and recommendations are welcome.
Hope that there is alternative for Intel Visual Fortran software, which could be used for Type creation and compilation.
Relevant answer
Answer
Personally I cannot advice something, but compilers are widely described in the TRNSYS user community - http://lists.onebuilding.org/pipermail/trnsys-users-onebuilding.org/. Try to search there.
  • asked a question related to Programming in Fortran
Question
16 answers
I mean in the general CAE programs such as ANSYS, ABACUS, Matlab and etc the more cores, the faster computing or the more maximum frequency of each core, the faster computing.
Relevant answer
The clock rate of current CPU cores is not a really important feature nowadays due to parallelization and their current performance. The number of cores is important in this regard, but the efficiency of parallelization mainly comes from the software implementation as well, and will greatly depend on your target application.
If you look closely at the current CPU performances, more time is spent on data access than actual computation for finite element softwares. Critical parameters thus also include the cache sizes and the memory transfer speed of your CPU, (the time needed to tranfer data from different cache levels to the unit). You should also check clock rate of your RAM for the same memory access time reasons.
Depending on your application mutlithreading capabilities (virtual parallelization at one core level), like for recent Intel i7, allows memory sharing that can accelerate some operations such as matrix vector products. Dual RAM channeling capabilities speed up the memory access and can also greatly improve performance in some cases. These capabilities are worth checking.
Commercial codes have made a lot of progress regarding the exploitation of parallelization but their generality make it impossible to provide best performance everywhere. Since every CPU architecture have their pro's an con's regarding final performance it is very difficult to get best performance for several applications.
You will nevertheless get good performance with the most recent workstation hardware setups that usually provide 4 to 8 cores (if you have enough RAM not to swap). Paying attention to the cache memory sizes and transfer speeds will definitively help making a relevant choice.
  • asked a question related to Programming in Fortran
Question
2 answers
I need to run a 3 dimensional DEM simulation by Multiphase Flow with Interphase eXchanges (MFiX) software. So, I need to make a Particle_input.dat file. However, I don't know how can i make this file for 3d simulation. In "tutorials>FluidBed_DES" folder there is the only particle input file that is for a 2d simulation.
Would you please let me know the data structure in a Particle_input.dat file for a 3d simulation?
Relevant answer
Answer
As far as I know, the procedure is exactly the same (of course for a 3D case you should provide the three components of the position and the velocity vectors). In my case I wanted to simulate one single particle falling into a static liquid, and it was simple. For example in one of the cases I simulated, the particle_input file contained just the following line:
5.0000 148.0000 5.0000 0.3625E00 2.164 0 0 0
in which the first three number defined the position, 0.3625 was the particle diameter, 2.164 the particle density and the final three 0 are the velocity components (in my case the particle was at rest).
The use of the particle_input file is convenient if you plan to simulate a case with a limited number of particles, as you should provide particles' infos for every single particle.
In the case of a 3D fluidized bed, for example, you can turn on the automatic particle configuration (GENER_PART_CONFIG = .T.), which, given particle diameters, void fraction and the coordinates of the domain in which the particles are stored initially, generates automatically the particle number and positions (see pag. 91 of the Readme.pdf file).
Cheers
  • asked a question related to Programming in Fortran
Question
11 answers
I may want to modify an existing FORTRAN code that someone else has made, however, I would like to modify the code and see where should I fix when encountering an error after modifications. To put it simple, I want to know where does the calculation stop.
Relevant answer
Answer
Seyed,
Even if the environment doesn't offer any particular tools, the old 'tried and tested' method of liberally sprinkling the code with reporting WRITE statements (indexes of loops, simple line reports to see where the code has got to, etc.) isn't a bad first attempt.
How big is the code and what sort of problems are you encountering?
  • asked a question related to Programming in Fortran
Question
4 answers
A better complex random number generator FORTRAN program, whose order of magnitude ranged from zero to unity.
Relevant answer
Answer
If what you need are complex random numbers with property |z|<=1 and uniformly distributed within this unit circle (not the case of previous comment by Diogenes Alves!) then you can act like this (f90/95, just a sketch, far from being optimal):
subroutine crandom (z)
complex, intent out :: z
real :: x, y, s1, s2
call random_number (s1)
call random_number (s2)
do
call random_number (x)
call random_number (y)
if (x*x + y*y .LE. 1.0) exit
enddo
x = sign (x, s1-0.5)
y = sign (y, s2-0.5)
z = cmplx (x,y)
end subroutine crandom
  • asked a question related to Programming in Fortran
Question
12 answers
I am using GNU gfortran, but I am not always satisfied with compilation. Can you suggest me another open source compiler?
Relevant answer
Answer
gfortran is one of the compilers for which -O0 is the default
this makes for fast compilation, but poor run-time.
This may also be an additional source of frustration.
Being in High Performance Computing, this is not the behavior that I want,
so I always use -O or -O2 with gfortran
You can verify this by comparing the output of
gfortran -Q --help=optimizers -c secondr.f90 | grep enabled > opts_default
and
gfortran -Q -O0 --help=optimizers -c secondr.f90 | grep enabled > opts_O0
and
gfortran -Q -O1 --help=optimizers -c secondr.f90 | grep enabled > opts_O1
Then
diff opts_default opts_O0
returns nothing, (identical)
while
diff opts_default opts_O1
Similarly, just specifying -O appears to mean -O1
at least in my version of gfortran, version 4.4.6
  • asked a question related to Programming in Fortran
Question
9 answers
.
Relevant answer
Answer
1) define compiler flags:
F90FLAG=-fPIC -Wextra -cpp
LIBFLAG=-fPIC -shared -ffree-form
2) create the object file for each source: gfortran -o example.o -c example.f90 $(F90FLAGS)
3) create the shared library against all the objects just created: gfortran -o libuser.so $(F90OBJ) $(LIBFLAG)
Step 2) is equivalent to makefile command:
%.o: %.f90
gfortran -o $@ -c $< $(F90FLAG)
I can send a working example if you need.
  • asked a question related to Programming in Fortran
Question
6 answers
I'm using NetCDF 4.2 with Fortran90 (using intel compiler on a nehalem system) and the memory seems to be related to the buffers of each file. But the memory use keeps growing even when the files are closed and I open new ones
I ended up writing a script around my fortran code to call it several times (only working on 150 files at a time) but this is rather annoying.
Any suggestion ?
Relevant answer
Answer
We found a solution: creating the file with the option NF90_SHARE :
nf90_create(ncfile, NF90_SHARE, ncid)
  • asked a question related to Programming in Fortran
Question
9 answers
I'm looking for a good editor and compiler for fortran in OSX operation system
Relevant answer
Answer
What compiler is best depends on how you use it. From my experience with Fortran under OSX.
Free compilers:
1. G95 - Slow and a little quirky, but great for code development. Your executable will respond to a lot of different environment variables that allows you to tweak the post-compilation behaviour, which can be very useful. Might not work with legacy f77 code, since it is strictly a f90 (and higher) compiler, which does not support all old f77 extensions, like cray pointers.
2. gfortran - Good allround compiler.
This one you have to buy:
3. ifort - Great for speed, and it comes with the very good MKL library for fast maths, so this is probably the best compiler for running your application. BUT: avoid using ifort for code development, as it is (in my opinion) "too good" at interpreting badly written code. Code written with an ifort compiler has a tendency to be very hard to port to other platforms, and I harbour dark suspicions that it sometimes quietly interprets erroneous code.
Apart from that, unless your project is very small, you will need a debugger, preferably gdb which is available anywhere you have gcc, and valgrind which is great for memory debugging.
Links: