Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29273 Discussions

appropriate location for insert "if" statement

hamid_mosaddeghi
Beginner
878 Views
Dears

I used "gofr" for get some properties from output of Molecular dynamic simualtion

this code do caculation in 3D, in my system existed some layers of molecule that located in z direction

I need ddefine this code for peroperties for each layers.

I need insert "if" statement same :

"if(zzz.ge.1.and.zzz.le.3)then "that calculation foratoms that have zcoordinate between 1 to 3

this comanad is correct? do I use "zzz" for zcoordinate of atoms? or other parameter?

which line is appropriate for insert "if" and which line is appropriate for insert "endif"?

Thanks
0 Kudos
6 Replies
mecej4
Honored Contributor III
878 Views
If you phrase your question in terms of some application area, such as molecular dynamics or options pricing or drug assimilation, you will drastically reduce the number of people who are able to help you.

What are the units of 'zzz'? Angstroms? Nanometers? ...? Or are you confusing the array elements and their integer indices, as in 'zzz=xyz(3,i)'. Since zzz is declared real, what prevents it from have non-integral values? Are 1,2 and 3 possible values for zzz?

In terms of Fortran, perhaps this is what you seek:

if(zzz.ge.1d0.and.zzz.le.3d0)then
...
<= zzz <= 3
...
endif

0 Kudos
hamid_mosaddeghi
Beginner
878 Views
Dear Mecej4

thanks for reply,

in this code unit of zzz as angstroms. and I have one layer between 1 to 3 angestrom (location need to analyzed).

are you agreement with "zzz" parameter for limtation calculation in z direction? or other parameter az xyz need be define for this purpose?


thanks
0 Kudos
mecej4
Honored Contributor III
878 Views
> are you agreement with "zzz" parameter for limtation calculation in z direction?

Sorry, that is not a programming question, but one for an atomic physicist -- which I am not!
0 Kudos
hamid_mosaddeghi
Beginner
878 Views
Ok Thanks,

I found manual that introduce "zzz" is z component of position atoms, then "zzz" s correct.

now , where lines(line number) are suitable for insert "if" and "endif"????


what difference between these two commands?

if(zzz.ge.1.and.zzz.le.3)then and if(zzz.ge.1d0.and.zzz.le.3d0)then
0 Kudos
mecej4
Honored Contributor III
878 Views
>what difference between these two commands?

Neither is a command -- these are lines of source code in a compiled language.

The difference is that the first version involves mixed mode (real and integer). It would be erroneous to compare the memory locations directly. The rules of the language provide that the integers 1 and 3 be converted to the same type as zzz before the comparisons are made. In the second version, the items compared are already of the same type.

Try this example

[fxfortran]      real*8 z
      z=4
      if(z/3.eq.1.3333333)write(*,*)'z/3 = 1.3333333 is true'
      if(z/3.eq.4d0/3)write(*,*)'z/3 = 4d0/3 is true'
      if(z/3.eq.4.0/3)write(*,*)'z/3 = 4.0/3 is true'
      end
[/fxfortran]
0 Kudos
hamid_mosaddeghi
Beginner
878 Views
Hi

what's your idea about line that insert 'if" statement.??

0 Kudos
Reply