Code Comments
Programming Forum and web based access to our favorite programming groups.In IVF compiler "!DEC$ REAL:8" can define all real value having attribute of real(8). SO, you have not to wirte (8) very time in the following. Can gfortran has the same function(to change default kind by one command) and how can I do it?
Post Follow-up to this messageOn 21 aug, 09:56, li.sim...@gmail.com wrote: > In IVF compiler "!DEC$ REAL:8" can define all real value having > attribute of real(8). SO, you have not to wirte (8) very time in the > following. > > Can gfortran has the same function(to change default kind by one > command) and how can I do it? It has that option: -fdefault-real-8 But why would you want to do that? It makes your program rely on parameters outside the source code. While that is almost inevitable, it seems to me very bad style not to be able to see from the source code whether single or double precision is to be used. What if you encounter a compiler that has no such option? I would recommend using a construction like: use precision ... real(wp) :: x ... where the module precision defines the working precision "wp" like: integer, parameter :: wp = kind(1.0d0) or something like that. It then is a matter of redefining wp to switch to another precision. Regards, Arjen
Post Follow-up to this message> But why would you want to do that? It makes your program rely on > parameters outside the source code. While that is almost > inevitable, it seems to me very bad style not to be able > to see from the source code whether single or double precision > is to be used. Thanks! Your method is a good choice. However, you must write a additional "wp" with every real, such as 100.0_wp,25.0wp.....it's a little inconvenient. If you use "!DEC$ REAL:8" or "-fdefault- real-8",you can directly write 100.,25. So, very good! And if you want use real(4),just define it at where you want(it overwrite the "!DEC$ REAL:8) So, I think it is easy of the method which I mentiond (the only problem is perhaps it is not easy for compatible with diffrent operating system. So I ask...).
Post Follow-up to this messageOn 21 aug, 12:11, li.sim...@gmail.com wrote: > > Thanks! Your method is a good choice. However, you must write a > additional "wp" with every real, such as 100.0_wp,25.0wp.....it's a > little inconvenient. If you use "!DEC$ REAL:8" or "-fdefault- > real-8",you can directly write 100.,25. So, very good! And if you want > use real(4),just define it at where you want(it overwrite the "!DEC$ > REAL:8) > > So, I think it is easy of the method which I mentiond (the only > problem is perhaps it is not easy for compatible with diffrent > operating system. So I ask...). Well, real(4) is compiler-dependent too. Not all compilers will use the kind number 4 to indicate ordinary single-precision reals. Which is why it is unwise to rely on this notation. And, yes, it is true that any literal number must be decorated then with _wp. Hm, you _could_ combine Glen's solution and mine: implicit real(wp) a-h,o-z and leave out declarations that would be covered by the above statement. Regards, Arjen
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.