(→2) factorial_100) |
|||
(51 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
+ | {{Template:CCDelete}} | ||
+ | {{Template:LegacyPage}} | ||
{{Software | {{Software | ||
|package_name=MPFUN90 | |package_name=MPFUN90 | ||
Line 9: | Line 11: | ||
MPFUN90 is a Fortran-90 arbitrary precision package (i.e. user specifies the desired precision)written by David H. Bailey et. al from the Lawrence Berkeley National Laboratory. If 64 digits of precision are sufficient for an application then users should use QD instead of MPFUN which would run much faster. | MPFUN90 is a Fortran-90 arbitrary precision package (i.e. user specifies the desired precision)written by David H. Bailey et. al from the Lawrence Berkeley National Laboratory. If 64 digits of precision are sufficient for an application then users should use QD instead of MPFUN which would run much faster. | ||
− | = | + | =Versions= |
==20060123== | ==20060123== | ||
<pre> | <pre> | ||
− | + | module load intel/12.1.3 | |
+ | module load mpfun90/20060123 | ||
</pre> | </pre> | ||
Line 20: | Line 23: | ||
<pre> | <pre> | ||
− | + | module load intel/15.0.3 | |
+ | module load mpfun90/intel1503/20100825 | ||
</pre> | </pre> | ||
− | = | + | =Usage= |
+ | ==Cluster== | ||
To submit a job to the serial queue use: | To submit a job to the serial queue use: | ||
sqsub -r 10m --mpp=2G -o ofile.%J ./a.out | sqsub -r 10m --mpp=2G -o ofile.%J ./a.out | ||
− | = | + | ==Interactive== |
− | == | + | ===testmp90=== |
This example shows how to compile and run <i>testmp90.f90</i> and <i>testmp90.f</i> using the 2006 and 2010 sharcnet mpfun90 modules: | This example shows how to compile and run <i>testmp90.f90</i> and <i>testmp90.f</i> using the 2006 and 2010 sharcnet mpfun90 modules: | ||
− | ===20060123=== | + | ====20060123==== |
− | [roberpj@orc-login2:~] | + | [roberpj@orc-login2:~] module load intel/12.1.3; module load mpfun90/20060123 |
[roberpj@orc-login2:~/samples/mpfun90/20060123] cp /opt/sharcnet/mpfun90/20060123/f90/src/testmp90.f90 . | [roberpj@orc-login2:~/samples/mpfun90/20060123] cp /opt/sharcnet/mpfun90/20060123/f90/src/testmp90.f90 . | ||
[roberpj@orc-login2:~/samples/mpfun90/20060123] ifort testmp90.f90 $CPPFLAGS $LDFLAGS -lmp | [roberpj@orc-login2:~/samples/mpfun90/20060123] ifort testmp90.f90 $CPPFLAGS $LDFLAGS -lmp | ||
Line 47: | Line 52: | ||
Completed Test 62 | Completed Test 62 | ||
− | ===20100825=== | + | ====20100825==== |
− | [roberpj@orc-login2:~] module | + | [roberpj@orc-login2:~] module unload intel mkl mpfun90 |
+ | [roberpj@orc-login2:~] module load intel/15.0.3; module load mpfun90/intel1503/20100825 | ||
[roberpj@orc-login2:~/samples/mpfun90/20100825] cp $MPFUN90_ROOT/f90/testmp90.f . | [roberpj@orc-login2:~/samples/mpfun90/20100825] cp $MPFUN90_ROOT/f90/testmp90.f . | ||
[roberpj@orc-login2:~/samples/mpfun90/20100825] ifort -free testmp90.f $MPFUN90_ROOT/toolkit/mpfun90.o -I$MPFUN90_ROOT/toolkit | [roberpj@orc-login2:~/samples/mpfun90/20100825] ifort -free testmp90.f $MPFUN90_ROOT/toolkit/mpfun90.o -I$MPFUN90_ROOT/toolkit | ||
Line 59: | Line 65: | ||
Completed Test 62 | Completed Test 62 | ||
− | == | + | o Note that when using the mpfun90/20100825 (or newer sharcnet modules) when the main program contains "use mpmodule" its necessary to include "$MPFUN90_ROOT/toolkit/mpmod90.o" when compiling otherwise error messages such as <i>"undefined reference to mpdefmod_mp_mpinit_"</i> will occur. Also note this is not required with the legacy mpfun90/20060123 module since the custom built static mp library (which is no longer being provided by sharcnet) contains all mpfun objects. |
+ | |||
+ | ===factorial_100.f90=== | ||
This example shows how to compile and run the program <i>factorial_100.f90</i> using the 2010 sharcnet mpfun90 module only: | This example shows how to compile and run the program <i>factorial_100.f90</i> using the 2010 sharcnet mpfun90 module only: | ||
Line 93: | Line 101: | ||
end | end | ||
− | ===Compile=== | + | ====Compile==== |
− | [roberpj@orc-login2:~/samples/mpfun90/factorial_100_pgm] ifort factorial_100.f90 $MPFUN90_ROOT/toolkit/mpmod90.o $MPFUN90_ROOT/toolkit/mpfun90.o -I$MPFUN90_ROOT/toolkit | + | [roberpj@orc-login2:~/samples/mpfun90/factorial_100_pgm] ifort factorial_100.f90 \ |
+ | $MPFUN90_ROOT/toolkit/mpmod90.o $MPFUN90_ROOT/toolkit/mpfun90.o -I$MPFUN90_ROOT/toolkit | ||
− | ===Execute=== | + | ====Execute==== |
[roberpj@orc-login2:~/samples/mpfun90/factorial_100_pgm] ./a.out | [roberpj@orc-login2:~/samples/mpfun90/factorial_100_pgm] ./a.out | ||
Line 105: | Line 114: | ||
DONE | DONE | ||
− | = | + | ==Graphical== |
+ | |||
+ | There is no graphical usage component for this software package. | ||
+ | |||
+ | =Notes= | ||
− | ==OpenMP | + | ==OpenMP== |
− | The Multi Precision packages MPFUN90 and QD use "user defined data type" for their variables. | + | The Multi Precision packages MPFUN90 (and QD) use "user defined data type" for their variables. |
Since the OpenMP reduction clause cannot be used for "user defined data types" to run MPFUN90 or QD | Since the OpenMP reduction clause cannot be used for "user defined data types" to run MPFUN90 or QD | ||
with OpenMP the reduction must be done manually in a PARALLEL OpenMP region. | with OpenMP the reduction must be done manually in a PARALLEL OpenMP region. | ||
Line 118: | Line 131: | ||
https://www.sharcnet.ca/help/index.php/OpenMP_Reduction_for_User_Defined_Data_Types | https://www.sharcnet.ca/help/index.php/OpenMP_Reduction_for_User_Defined_Data_Types | ||
− | == | + | ==Large Arrays== |
Declaring large arrays in an MPFUN program often leads to compile | Declaring large arrays in an MPFUN program often leads to compile | ||
Line 161: | Line 174: | ||
jobs: | jobs: | ||
− | === | + | ===betax.f90=== |
<pre> | <pre> | ||
Line 214: | Line 227: | ||
</pre> | </pre> | ||
− | ==== | + | ====Nsz=12 (works)==== |
<pre> | <pre> | ||
Line 266: | Line 279: | ||
</pre> | </pre> | ||
− | ==== | + | ====Nsz=37 (fails)==== |
<pre> | <pre> | ||
Line 291: | Line 304: | ||
</pre> | </pre> | ||
− | === | + | ===betay.f90=== |
Copy betay.f90 from betax.f90 and modify as follows: | Copy betay.f90 from betax.f90 and modify as follows: | ||
Line 375: | Line 388: | ||
</pre> | </pre> | ||
− | ==== | + | ====Run Interactive==== |
<pre> | <pre> | ||
Line 428: | Line 441: | ||
</pre> | </pre> | ||
− | ====Run | + | ====Run In Queue==== |
− | + | The executable requires 4G or more. Setting mpp=8G should work (logout then in again to reset to default environment): | |
− | <pre> | + | <pre> |
− | + | sqsub -r 5m --mpp=8.0G -o ofile.%J ./a.out | |
</pre> | </pre> | ||
− | == | + | ==Math Toolkit== |
+ | ===Running Mathinit=== | ||
This toolkit provides and extensive example of how the mpfun package can be used. Read the header of files | This toolkit provides and extensive example of how the mpfun package can be used. Read the header of files | ||
mathinit.f90 | mathinit.f90 | ||
Line 446: | Line 460: | ||
for an explanation what the package does. The Makefile in this directory shows how the mpfun libraries were linked to compile this sample program pair. The following steps shows the first initialization step followed by actually running the mathtool program to perform some examples such as performing an integration and displaying the value of pie. Note that the displayed zero cputimes are due to a bug in the mpfun current build which will be fixed in future updates on the clusters. | for an explanation what the package does. The Makefile in this directory shows how the mpfun libraries were linked to compile this sample program pair. The following steps shows the first initialization step followed by actually running the mathtool program to perform some examples such as performing an integration and displaying the value of pie. Note that the displayed zero cputimes are due to a bug in the mpfun current build which will be fixed in future updates on the clusters. | ||
− | |||
To run Mathtool you must first generate following two input files | To run Mathtool you must first generate following two input files | ||
const.dat | const.dat | ||
Line 455: | Line 468: | ||
<pre> | <pre> | ||
− | [roberpj@ | + | [roberpj@orc-login1:~/samples/mpfun90/math] cp /opt/sharcnet/mpfun90/20100825/intel1503/toolkit/mathinit . |
+ | [roberpj@orc-login1:~/samples/mpfun90/math] chmod 700 mathinit | ||
+ | [roberpj@orc-login1:~/samples/mpfun90/math] ./mathinit | ||
mathinit: start | mathinit: start | ||
const complete | const complete | ||
file const.dat written | file const.dat written | ||
− | cpu time = | + | cpu time = 2.57360911369324 |
initqts: Tanh-sinh quadrature initialization | initqts: Tanh-sinh quadrature initialization | ||
− | + | 0 18632 | |
− | + | 1000 18632 | |
− | + | 2000 18632 | |
− | + | 3000 18632 | |
− | + | 4000 18632 | |
− | + | 5000 18632 | |
− | + | 6000 18632 | |
− | + | 7000 18632 | |
− | + | 8000 18632 | |
initqts: Table spaced used = 8177 | initqts: Table spaced used = 8177 | ||
initqts complete | initqts complete | ||
file quadts.dat written | file quadts.dat written | ||
− | cpu time = | + | cpu time = 90.4362528324127 |
− | total cpu time = | + | total cpu time = 93.0098619461060 |
− | + | [roberpj@orc-login1:~/samples/mpfun90/mathinit] ls | |
− | [roberpj@ | + | const.dat mathinit quadts.dat |
− | const.dat quadts.dat | + | |
</pre> | </pre> | ||
− | + | ===Running Mathtool=== | |
Use the files created in the previous section to run mathtool as follows: | Use the files created in the previous section to run mathtool as follows: | ||
<pre> | <pre> | ||
− | [roberpj@ | + | [roberpj@orc-login1:~/samples/mpfun90/math] cp /opt/sharcnet/mpfun90/20100825/intel1503/toolkit/mathtool . |
+ | [roberpj@orc-login1:~/samples/mpfun90/math] chmod 700 mathtool | ||
+ | [roberpj@orc-login1:~/samples/mpfun90/math] ./mathtool | ||
Welcome to the Experimental Mathematician's Toolkit | Welcome to the Experimental Mathematician's Toolkit | ||
Initializing... | Initializing... | ||
Line 498: | Line 514: | ||
Quadrature level = 6 | Quadrature level = 6 | ||
Quadrature type = 3 (Tanh-Sinh) | Quadrature type = 3 (Tanh-Sinh) | ||
− | |||
− | + | Sample expressions (case insensitive): | |
+ | e + pi + log2 + log10 + catalan Adds these pre-defined constants. | ||
+ | result[1] + result[2] Adds result #1 to result #2. | ||
+ | alpha = arctan[3] - 3*log[2] Defines or sets user variable alpha. | ||
+ | fun1[x,y] = 2*sqrt[x]*erf[y] Defines user function fun1. | ||
+ | clear[nam1] Clears definition of variable or function. | ||
+ | integrate[1/(1+x^2), {x, 0, 1}] Integrates 1/(1+x^2) from x=0 to 1. | ||
+ | sum[1/2^k, {k, 0, infinity}] Sums 1/2^k from k=0 to infinity. | ||
+ | binomial[20,10]*factorial[10] Evaluates binomial coeff and factorial. | ||
+ | zeta[3] + zetaz[1,1,2] Evaluates zeta and multi-zeta functions. | ||
+ | table[x^k, {k, 1, 4}] Forms the list [x^1, x^2, x^3, x^4]. | ||
+ | pslq[table[x^k, {k, 0, n}]] Finds coeffs of degree-n poly for x. | ||
+ | polyroot[1,-1,-1,{0.618}] Finds real root of 1-x-x^2=0 near 0.618. | ||
+ | polyroot[1,2,3,{-0.33, 0.47}] Complex root of 1+2x+3x^2 near -0.33+0.47i. | ||
+ | digits = 200 Sets working precision to 200 digits. | ||
+ | epsilon = -190 Sets epsilon level to 10^(-190). | ||
+ | eformat[190,180] Display using E format with 180 digits. | ||
+ | fformat[60,50] Display using F format with 50 digits. | ||
+ | input file.dat Inputs commands from file file.dat. | ||
+ | output file.dat Outputs user vars and funs to file.dat. | ||
+ | help polyroot Displays a brief explanation of polyroot. | ||
+ | functions Displays a list of all defined functions. | ||
+ | variables Displays a list of all defined variables. | ||
+ | prompt Displays this message. | ||
+ | exit Exits this program. | ||
+ | Expressions may be continued on next line by typing \ at end of line. | ||
+ | |||
+ | integrate[1/(1+x^2), {x, 0, 1}] (hit enter) | ||
quadts: Iteration 1 of 6; est error = 10^ 0; approx value = | quadts: Iteration 1 of 6; est error = 10^ 0; approx value = | ||
7.853157298876894309110693190063938396203990510665917998384243e-1 | 7.853157298876894309110693190063938396203990510665917998384243e-1 | ||
Line 515: | Line 557: | ||
Result[ 1] = | Result[ 1] = | ||
7.85398163397448309615660845819875721049292349843776455243736148076954e-1 | 7.85398163397448309615660845819875721049292349843776455243736148076954e-1 | ||
− | CPU time = 0. | + | CPU time = 0.1730 |
− | + | functions (hit enter) | |
Abs Arccos Arcsin Arctan | Abs Arccos Arcsin Arctan | ||
Arctan2 Bessel Besselexp Binomial | Arctan2 Bessel Besselexp Binomial | ||
Line 526: | Line 568: | ||
Tan Zeta Zetap Zetaz | Tan Zeta Zetap Zetaz | ||
− | + | variables (hit enter) | |
E Log2 Log10 Pi | E Log2 Log10 Pi | ||
Catalan Eulergamma Infinity Arg1 | Catalan Eulergamma Infinity Arg1 | ||
Line 535: | Line 577: | ||
Quadtype x | Quadtype x | ||
− | + | Pi (hit enter) | |
Result[ 2] = | Result[ 2] = | ||
3.14159265358979323846264338327950288419716939937510582097494459230781e0 | 3.14159265358979323846264338327950288419716939937510582097494459230781e0 | ||
CPU time = 0.0000 | CPU time = 0.0000 | ||
− | |||
− | + | sqrt[1600] (hit enter) | |
− | + | Result[ 1] = | |
− | + | 4.00000000000000000000000000000000000000000000000000000000000000000000e1 | |
− | + | CPU time = 0.0000 | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | help Binomial (hit enter) | |
− | + | Binomial[m,n] computes the binomial coefficient of integers (m,n). | |
− | + | ||
− | + | ||
− | + | Binomial[3,2] (hit enter) | |
− | + | Result[ 2] = | |
− | + | ||
− | + | ||
− | + | ||
3.00000000000000000000000000000000000000000000000000000000000000000000e0 | 3.00000000000000000000000000000000000000000000000000000000000000000000e0 | ||
− | + | CPU time = 0.0000 | |
− | + | hypo[x,y] = sqrt[x^2+y^2] (hit enter) | |
− | parse: new function name = hypo | + | parse: new function name = hypo |
− | + | CPU time = 0.0000 | |
− | + | z=hypo[3,4] (hit enter) | |
− | + | parse: new variable name = z | |
− | + | CPU time = 0.0000 | |
− | + | z (hit enter) | |
− | + | Result[ 3] = | |
− | + | 5.00000000000000000000000000000000000000000000000000000000000000000000e0 | |
− | + | CPU time = 0.0000 | |
− | + | </pre> | |
− | + | ||
=References= | =References= |
Latest revision as of 09:30, 6 June 2019
This page is scheduled for deletion because it is either redundant with information available on the CC wiki, or the software is no longer supported. |
Contents
Note: This page's content only applies to the SHARCNET's legacy systems; it does not apply to Graham. |
MPFUN90 |
---|
Description: A Fortran-90 arbitrary precision package |
SHARCNET Package information: see MPFUN90 software page in web portal |
Full list of SHARCNET supported software |
Introduction
MPFUN90 is a Fortran-90 arbitrary precision package (i.e. user specifies the desired precision)written by David H. Bailey et. al from the Lawrence Berkeley National Laboratory. If 64 digits of precision are sufficient for an application then users should use QD instead of MPFUN which would run much faster.
Versions
20060123
module load intel/12.1.3 module load mpfun90/20060123
20100825
module load intel/15.0.3 module load mpfun90/intel1503/20100825
Usage
Cluster
To submit a job to the serial queue use:
sqsub -r 10m --mpp=2G -o ofile.%J ./a.out
Interactive
testmp90
This example shows how to compile and run testmp90.f90 and testmp90.f using the 2006 and 2010 sharcnet mpfun90 modules:
20060123
[roberpj@orc-login2:~] module load intel/12.1.3; module load mpfun90/20060123 [roberpj@orc-login2:~/samples/mpfun90/20060123] cp /opt/sharcnet/mpfun90/20060123/f90/src/testmp90.f90 . [roberpj@orc-login2:~/samples/mpfun90/20060123] ifort testmp90.f90 $CPPFLAGS $LDFLAGS -lmp [roberpj@orc-login2:~/samples/mpfun90/20060123] ./a.out Completed Test 1 Completed Test 2 Completed Test 3 ................. Completed Test 62
20100825
[roberpj@orc-login2:~] module unload intel mkl mpfun90 [roberpj@orc-login2:~] module load intel/15.0.3; module load mpfun90/intel1503/20100825 [roberpj@orc-login2:~/samples/mpfun90/20100825] cp $MPFUN90_ROOT/f90/testmp90.f . [roberpj@orc-login2:~/samples/mpfun90/20100825] ifort -free testmp90.f $MPFUN90_ROOT/toolkit/mpfun90.o -I$MPFUN90_ROOT/toolkit [roberpj@orc-login2:~/samples/mpfun90/20100825] ./a.out Completed Test 1 Completed Test 2 Completed Test 3 ................. Completed Test 62
o Note that when using the mpfun90/20100825 (or newer sharcnet modules) when the main program contains "use mpmodule" its necessary to include "$MPFUN90_ROOT/toolkit/mpmod90.o" when compiling otherwise error messages such as "undefined reference to mpdefmod_mp_mpinit_" will occur. Also note this is not required with the legacy mpfun90/20060123 module since the custom built static mp library (which is no longer being provided by sharcnet) contains all mpfun objects.
factorial_100.f90
This example shows how to compile and run the program factorial_100.f90 using the 2010 sharcnet mpfun90 module only:
program factorial_100_pgm use mpmodule implicit none integer, parameter :: Nmx = 100 integer :: AllocateStatus integer :: J type(mp_real) zero, one type(mp_real), dimension (:), allocatable :: fac call mpinit(800) call mpsetprec(800) call mpsetoutputprec(700) zero='0.' one ='1.' allocate(fac(0:Nmx),STAT=AllocateStatus) IF (AllocateStatus /= 0) STOP "Not enough memory for fac " fac(0)=one do J=1,Nmx fac(J)=fac(J-1)*J end do J=4 write(6,1001) J 1001 format(/"fac(",i3.3,") =",$) call mpwrite(6,fac(J)) J=100 write(6,1001) J call mpwrite(6,fac(J)) write(6,1005) 1005 format(/"DONE"//) end
Compile
[roberpj@orc-login2:~/samples/mpfun90/factorial_100_pgm] ifort factorial_100.f90 \ $MPFUN90_ROOT/toolkit/mpmod90.o $MPFUN90_ROOT/toolkit/mpfun90.o -I$MPFUN90_ROOT/toolkit
Execute
[roberpj@orc-login2:~/samples/mpfun90/factorial_100_pgm] ./a.out fac(004) =10 ^ 1 x 2.4, fac(100) =10 ^ 157 x 9.3326215443944152681699238856266700490715968264381621468592 963895217599993229915608941463976156518286253697920827223758251185210916864, DONE
Graphical
There is no graphical usage component for this software package.
Notes
OpenMP
The Multi Precision packages MPFUN90 (and QD) use "user defined data type" for their variables. Since the OpenMP reduction clause cannot be used for "user defined data types" to run MPFUN90 or QD with OpenMP the reduction must be done manually in a PARALLEL OpenMP region.
Detailed documentation on how to use OpenMP with MPFUN90 and QD are presented in the following document:
https://www.sharcnet.ca/help/index.php/OpenMP_Reduction_for_User_Defined_Data_Types
Large Arrays
Declaring large arrays in an MPFUN program often leads to compile errors like:
"relocation truncated to fit r_x86_64_pc32 against .bss"
Even with the flag '-mcmodel large' in the compile command the error will persist, because there is a limit to the amount of data you can have allocated in static arrays for x86_64 architecture. This data segment is limited to 2GB. The data in COMMON plus any other statically declared arrays PLUS your code must fit in 2GB.
In order to overcome this problem use allocatable arrays declared in a module together with a short subroutine which allocates the arrays.
We illustrate these concepts by starting with a program 'betax.f90' which work fine for values of parameter 'Nsz' less than 37. Thus, if you compile it with
integer, parameter :: Nsz=36
it works, but for any higher values it fails with error message:
"relocation truncated to fit: R_X86_64_PC32 against symbol '...'"
To overcome this problem, we first copy program betax.f90 into a new file, say, betay.f90, and write a module called 'mp_data' and a subroutine called 'allocate_arrays' at the top of the new file. We move all the declarations of large arrays into the module, and declare them as 'allocatable'.
In the subroutine 'allocate_arrays' we do the allocations and in the main program we add the statements:
USE mp_data ... call allocate_arrays ...
Below you will find the listings for the files 'betax.f90', 'betay.f90' and the 'HIST' file containing the commands to compile these files and submit jobs:
betax.f90
program BETAX use mpmodule implicit none ! integer, parameter :: Nsz=12 ! compilation fails for 37 integer, parameter :: Nsz=37 INTEGER :: I,J,K,L type(mp_real) zero, one type(mp_real) fac(0:Nsz),fci(0:Nsz) type(mp_real) BETA2(Nsz,Nsz) type(mp_real) BETA3(Nsz,Nsz,Nsz) type(mp_real) BETA4(Nsz,Nsz,Nsz,Nsz) call mpinit(800) call mpsetprec(800) call mpsetoutputprec(700) zero='0.' one ='1.' fac(0)=one fci(0)=one do j=1,Nsz fac(j)=fac(j-1)*j fci(j)=one/fac(j) end do I=Nsz/2 J=I-1 K=J-1 L=K-1 write(6,1000) I,J,K,L 1000 format(/"I,J,K,L = ",4i3) write(6,1001) I 1001 format(/"fac(",i3.3,") =",$) call mpwrite(6,fac(I)) BETA2(I,J) =fac(I)*fac(J)*fci(I+J) BETA3(I,J,K) =fac(I)*fac(J)*fac(K)*fci(I+J)*fci(J+K) BETA4(I,J,K,L) =fac(I)*fac(J)*fac(K)*fac(L)* & & fci(I+J)*fci(J+K)*fci(K+L) write(6,1002) I,J 1002 format(/"BETA2(",i3.3,",",i3.3,") =") call mpwrite(6,BETA2(I,J)) write(6,1003) I,J,K 1003 format(/"BETA3(",i3.3,",",i3.3,",",i3.3,") =") call mpwrite(6,BETA3(I,J,K)) write(6,1004) I,J,K,L 1004 format(/"BETA4(",i3.3,",",i3.3,",",i3.3,",",i3.3,") =") call mpwrite(6,BETA4(I,J,K,L)) write(6,1005) 1005 format(/"DONE"//) stop end
Nsz=12 (works)
[roberpj@orc-login2:~] ssh orc-dev1 [roberpj@orc129:~] module purge; module load ldwrapper; module load intel/15.0.3; module load mpfun90/intel1503/20100825 [roberpj@orc129:~] cd ~/samples/mpfun90/betax [roberpj@orc129:~/samples/mpfun90/betax] ifort betax.f90 $MPFUN90_ROOT/toolkit/mpmod90.o $MPFUN90_ROOT/toolkit/mpfun90.o -I$MPFUN90_ROOT/toolkit [roberpj@orc129:~/samples/mpfun90/betax] ./a.out I,J,K,L = 6 5 4 3 fac(006) =10 ^ 2 x 7.2, BETA2(006,005) = 10 ^ -3 x 2.1645021645021645021645021645021645021645021645021645021645 021645021645021645021645021645021645021645021645021645021645021645021645021645 021645021645021645021645021645021645021645021645021645021645021645021645021645 021645021645021645021645021645021645021645021645021645021645021645021645021645 021645021645021645021645021645021645021645021645021645021645021645021645021645 021645021645021645021645021645021645021645021645021645021645021645021645021645 021645021645021645021645021645021645021645021645021645021645021645021645021645 021645021645021645021645021645021645021645021645021645021645021645021645021645 021645021645021645021645021645021645021645021645021645021645021645021645021645 021645021645021645, BETA3(006,005,004) = 10 ^ -7 x 1.4315490505966696442886919077395267871458347648823839300029 776220252410728601204791680982157172633363109553585744061934538125014315490505 966696442886919077395267871458347648823839300029776220252410728601204791680982 157172633363109553585744061934538125014315490505966696442886919077395267871458 347648823839300029776220252410728601204791680982157172633363109553585744061934 538125014315490505966696442886919077395267871458347648823839300029776220252410 728601204791680982157172633363109553585744061934538125014315490505966696442886 919077395267871458347648823839300029776220252410728601204791680982157172633363 109553585744061934538125014315490505966696442886919077395267871458347648823839 300029776220252410, BETA4(006,005,004,003) = 10 ^ -10 x 1.7042250602341305289151094139756271275545651962885522976225 924071729060391191910466286883520443611146558992363981026112545386921804155364 246067193912998901661033180307556724790284880987828833633822295953815228191645 425205515908463754268742930874450148826566060126150829098674903663565795085069 461486695046785749733595538584200715719990096407329967420670368516173504835636 354910731327964888055591003436808425470556989831366248599808690511638357443346 105477624752001169234729325432273278078266740398259672636089869649960352908198 713187375318894593271010504570595273543119348108010239529513905931139491230194 178039983028645160164434540851774411865114812960617949280080799355175772409332 500035447881252869, DONE
Nsz=37 (fails)
[roberpj@orc-login2:~/samples/mpfun90/betax] ssh orc-dev1 [roberpj@orc129:~] module purge; module load ldwrapper; module load intel/15.0.3; module load mpfun90/intel1503/20100825 [roberpj@orc129:~] cd ~/samples/mpfun90/betax [roberpj@orc129:~/samples/mpfun90/betax] ifort betax.f90 $MPFUN90_ROOT/toolkit/mpmod90.o $MPFUN90_ROOT/toolkit/mpfun90.o -I$MPFUN90_ROOT/toolkit /opt/sharcnet/mpfun90/20100825/intel1503/toolkit/mpmod90.o: In function `mpdefmod_mp_mpsetprec_': mpmod90.f:(.text+0x1b): relocation truncated to fit: R_X86_64_PC32 against symbol `mpdefmod_mp_new_mpipl_' defined in COMMON section in /opt/sharcnet/mpfun90/20100825/intel1503/toolkit/mpmod90.o mpmod90.f:(.text+0xa0): relocation truncated to fit: R_X86_64_PC32 against symbol `mpdefmod_mp_new_mpwds_' defined in COMMON section in /opt/sharcnet/mpfun90/20100825/intel1503/toolkit/mpmod90.o mpmod90.f:(.text+0xa6): relocation truncated to fit: R_X86_64_PC32 against symbol `mpdefmod_mp_mpnwx_' defined in COMMON section in /opt/sharcnet/mpfun90/20100825/intel1503/toolkit/mpmod90.o mpmod90.f:(.text+0xcf): relocation truncated to fit: R_X86_64_PC32 against symbol `mpdefmod_mp_mpnwx_' defined in COMMON section in /opt/sharcnet/mpfun90/20100825/intel1503/toolkit/mpmod90.o /opt/sharcnet/mpfun90/20100825/intel1503/toolkit/mpmod90.o: In function `mpdefmod_mp_mpgetprec_': mpmod90.f:(.text+0xe6): relocation truncated to fit: R_X86_64_PC32 against symbol `mpdefmod_mp_mpnwx_' defined in COMMON section in /opt/sharcnet/mpfun90/20100825/intel1503/toolkit/mpmod90.o /opt/sharcnet/mpfun90/20100825/intel1503/toolkit/mpmod90.o: In function `mpdefmod_mp_mpsetprecwords_': mpmod90.f:(.text+0x109): relocation truncated to fit: R_X86_64_PC32 against symbol `mpdefmod_mp_new_mpwds_' defined in COMMON section in /opt/sharcnet/mpfun90/20100825/intel1503/toolkit/mpmod90.o mpmod90.f:(.text+0x18c): relocation truncated to fit: R_X86_64_PC32 against symbol `mpdefmod_mp_mpnwx_' defined in COMMON section in /opt/sharcnet/mpfun90/20100825/intel1503/toolkit/mpmod90.o mpmod90.f:(.text+0x198): relocation truncated to fit: R_X86_64_PC32 against symbol `mpdefmod_mp_mpnwx_' defined in COMMON section in /opt/sharcnet/mpfun90/20100825/intel1503/toolkit/mpmod90.o /opt/sharcnet/mpfun90/20100825/intel1503/toolkit/mpmod90.o: In function `mpdefmod_mp_mpgetprecwords_': mpmod90.f:(.text+0x1b2): relocation truncated to fit: R_X86_64_PC32 against symbol `mpdefmod_mp_mpnwx_' defined in COMMON section in /opt/sharcnet/mpfun90/20100825/intel1503/toolkit/mpmod90.o /opt/sharcnet/mpfun90/20100825/intel1503/toolkit/mpmod90.o: In function `mpdefmod_mp_mpsetoutputprec_': mpmod90.f:(.text+0x1c9): relocation truncated to fit: R_X86_64_PC32 against symbol `mpdefmod_mp_new_mpipl_' defined in COMMON section in /opt/sharcnet/mpfun90/20100825/intel1503/toolkit/mpmod90.o mpmod90.f:(.text+0x24c): additional relocation overflows omitted from the output
betay.f90
Copy betay.f90 from betax.f90 and modify as follows:
module mp_data use mpmodule use mpfunmod implicit none integer, parameter :: Nsz =48 integer :: AllocateStatus ! type(mp_real) zero, one ! ! type(mp_real) fac(0:Nsz),fci(0:Nsz) ! type(mp_real) BETA2(Nsz,Nsz) ! type(mp_real) BETA3(Nsz,Nsz,Nsz) ! type(mp_real) BETA4(Nsz,Nsz,Nsz,Nsz) type(mp_real) zero, one type(mp_real), dimension (:), allocatable :: fac,fci type(mp_real), dimension (:,:), allocatable :: BETA2 type(mp_real), dimension (:,:,:), allocatable :: BETA3 type(mp_real), dimension (:,:,:,:), allocatable :: BETA4 end module mp_data subroutine allocate_arrays USE mp_data implicit none allocate(fac(0:Nsz),STAT=AllocateStatus) IF (AllocateStatus /= 0) STOP "Not enough memory for fac " allocate(fci(0:Nsz),STAT=AllocateStatus) IF (AllocateStatus /= 0) STOP "Not enough memory for fci " allocate(BETA2(Nsz,Nsz),STAT=AllocateStatus) IF (AllocateStatus /= 0) STOP "Not enough memory for BETA2" allocate(BETA3(Nsz,Nsz,Nsz),STAT=AllocateStatus) IF (AllocateStatus /= 0) STOP "Not enough memory for BETA3" allocate(BETA4(Nsz,Nsz,Nsz,Nsz),STAT=AllocateStatus) IF (AllocateStatus /= 0) STOP "Not enough memory for BETA4" print *,"Done with allocations" return END program BETAY USE mp_data implicit none INTEGER :: I,J,K,L call mpinit(800) call mpsetprec(800) call mpsetoutputprec(700) zero='0.' one ='1.' call allocate_arrays fac(0)=one fci(0)=one do j=1,Nsz fac(j)=fac(j-1)*j fci(j)=one/fac(j) end do I=Nsz/2 J=I-1 K=J-1 L=K-1 write(6,1000) I,J,K,L 1000 format(/"I,J,K,L = ",4i3) write(6,1001) I 1001 format(/"fac(",i3.3,") =",$) call mpwrite(6,fac(I)) BETA2(I,J) =fac(I)*fac(J)*fci(I+J) BETA3(I,J,K) =fac(I)*fac(J)*fac(K)*fci(I+J)*fci(J+K) BETA4(I,J,K,L) =fac(I)*fac(J)*fac(K)*fac(L)* & & fci(I+J)*fci(J+K)*fci(K+L) write(6,1002) I,J 1002 format(/"BETA2(",i3.3,",",i3.3,") =") call mpwrite(6,BETA2(I,J)) write(6,1003) I,J,K 1003 format(/"BETA3(",i3.3,",",i3.3,",",i3.3,") =") call mpwrite(6,BETA3(I,J,K)) write(6,1004) I,J,K,L 1004 format(/"BETA4(",i3.3,",",i3.3,",",i3.3,",",i3.3,") =") call mpwrite(6,BETA4(I,J,K,L)) write(6,1005) 1005 format(/"DONE"//) stop end
Run Interactive
[roberpj@orc-login2:~/samples/mpfun90/betax] ssh orc-dev1 [roberpj@orc129:~] module purge; module load ldwrapper; module load intel/15.0.3; module load mpfun90/intel1503/20100825 [roberpj@orc129:~] cd ~/samples/mpfun90/betax [roberpj@orc129:~/samples/mpfun90/betay] ifort betay.f90 -mcmodel medium -shared-intel $MPFUN90_ROOT/toolkit/mpmod90.o $MPFUN90_ROOT/toolkit/mpfun90.o -I$MPFUN90_ROOT/toolkit [roberpj@orc129:~/samples/mpfun90/betay] ./a.out Done with allocations I,J,K,L = 24 23 22 21 fac(024) =10 ^ 23 x 6.2044840173323943936, BETA2(024,023) = 10 ^ -14 x 6.2020112243197155666795543346647015590753323586760996092750 322219057797634187521971369584938063040803657153278083912027225083805532623694 253019502124309149392729129350380917947755526197968886374824625487894350759012 041810328483619840297565282378760232413828873982152911730876431238573292437598 662321548481235961397432074855738879756265023434311148398287293760405994587153 193913843867324131168164219803469468792765957446870530750541069496092327458240 264036867349068267612059922537556261610989123549224099029159406148147186635876 682339231176161254018298581141061530140422181489818261044243997939224351270878 819950204611859530447542248373743937988058087925403948261102164487732977810152 365677688323239749, BETA3(024,023,022) = 10 ^ -49 x 5.8275670518268372535457693390802431850085211093628371195552 665374004872800254829089878748169551314149473682136937787061527746060528126189 766201816798822863047397630953393452298952922317427385387709426414471466082503 710520168054747139227447182197529542668023453841447481072362595230792080104688 990118018686670752770192225324208683555045454680275731685429800649187636704457 682218863512356150460390146982645823361128943131689947031597399022247950302452 330798644776819869632357497968409458052013048605853804143958746701285425073948 635138571530969417104049554300550153503104110125327389142504664160736472211972 376564769573352356164657421339817982321431569247028739128974299782191260982443 302487480103263037, BETA4(024,023,022,021) = 10 ^ -82 x 4.9281568290835382164029311372592682488032902612395816340121 089418282192742634150386978468714226783345875673304699950206823277002261928996 900244023525594363488176338336719985617691508208486288075631383295355204178844 640181812076780791059441681639997667611161419120033906970044689546074997396047 324233844363558571961437990937177293607133483649131082039969185440365241880338 469876039008981574675398716901015661349359043742699044662693828465598208328182 649393881845546476915223922569122221086448855100004979240419350679011848465439 752707160104858505636971713317247147406784939008134376861978582533070195429961 381129842064351212761591279694768634684602143478580742025860111467351736320562 750016997598905712, DONE
Run In Queue
The executable requires 4G or more. Setting mpp=8G should work (logout then in again to reset to default environment):
sqsub -r 5m --mpp=8.0G -o ofile.%J ./a.out
Math Toolkit
Running Mathinit
This toolkit provides and extensive example of how the mpfun package can be used. Read the header of files
mathinit.f90 and mathtool.f90
found under
/opt/sharcnet/mpfun90/version/[flavor]/toolkit
for an explanation what the package does. The Makefile in this directory shows how the mpfun libraries were linked to compile this sample program pair. The following steps shows the first initialization step followed by actually running the mathtool program to perform some examples such as performing an integration and displaying the value of pie. Note that the displayed zero cputimes are due to a bug in the mpfun current build which will be fixed in future updates on the clusters.
To run Mathtool you must first generate following two input files
const.dat and quadts.dat
which can be accomplished by running following command:
[roberpj@orc-login1:~/samples/mpfun90/math] cp /opt/sharcnet/mpfun90/20100825/intel1503/toolkit/mathinit . [roberpj@orc-login1:~/samples/mpfun90/math] chmod 700 mathinit [roberpj@orc-login1:~/samples/mpfun90/math] ./mathinit mathinit: start const complete file const.dat written cpu time = 2.57360911369324 initqts: Tanh-sinh quadrature initialization 0 18632 1000 18632 2000 18632 3000 18632 4000 18632 5000 18632 6000 18632 7000 18632 8000 18632 initqts: Table spaced used = 8177 initqts complete file quadts.dat written cpu time = 90.4362528324127 total cpu time = 93.0098619461060 [roberpj@orc-login1:~/samples/mpfun90/mathinit] ls const.dat mathinit quadts.dat
Running Mathtool
Use the files created in the previous section to run mathtool as follows:
[roberpj@orc-login1:~/samples/mpfun90/math] cp /opt/sharcnet/mpfun90/20100825/intel1503/toolkit/mathtool . [roberpj@orc-login1:~/samples/mpfun90/math] chmod 700 mathtool [roberpj@orc-login1:~/samples/mpfun90/math] ./mathtool Welcome to the Experimental Mathematician's Toolkit Initializing... Current settings: Debug level = 2 Primary precision level = 100 digits Secondary precision level = 200 digits Primary epsilon = 10^ -100 Secondary epsilon = 10^ -200 PSLQ bound = 100 PSLQ level = 1 Quadrature level = 6 Quadrature type = 3 (Tanh-Sinh) Sample expressions (case insensitive): e + pi + log2 + log10 + catalan Adds these pre-defined constants. result[1] + result[2] Adds result #1 to result #2. alpha = arctan[3] - 3*log[2] Defines or sets user variable alpha. fun1[x,y] = 2*sqrt[x]*erf[y] Defines user function fun1. clear[nam1] Clears definition of variable or function. integrate[1/(1+x^2), {x, 0, 1}] Integrates 1/(1+x^2) from x=0 to 1. sum[1/2^k, {k, 0, infinity}] Sums 1/2^k from k=0 to infinity. binomial[20,10]*factorial[10] Evaluates binomial coeff and factorial. zeta[3] + zetaz[1,1,2] Evaluates zeta and multi-zeta functions. table[x^k, {k, 1, 4}] Forms the list [x^1, x^2, x^3, x^4]. pslq[table[x^k, {k, 0, n}]] Finds coeffs of degree-n poly for x. polyroot[1,-1,-1,{0.618}] Finds real root of 1-x-x^2=0 near 0.618. polyroot[1,2,3,{-0.33, 0.47}] Complex root of 1+2x+3x^2 near -0.33+0.47i. digits = 200 Sets working precision to 200 digits. epsilon = -190 Sets epsilon level to 10^(-190). eformat[190,180] Display using E format with 180 digits. fformat[60,50] Display using F format with 50 digits. input file.dat Inputs commands from file file.dat. output file.dat Outputs user vars and funs to file.dat. help polyroot Displays a brief explanation of polyroot. functions Displays a list of all defined functions. variables Displays a list of all defined variables. prompt Displays this message. exit Exits this program. Expressions may be continued on next line by typing \ at end of line. integrate[1/(1+x^2), {x, 0, 1}] (hit enter) quadts: Iteration 1 of 6; est error = 10^ 0; approx value = 7.853157298876894309110693190063938396203990510665917998384243e-1 quadts: Iteration 2 of 6; est error = 10^ 0; approx value = 7.853981605125528448099840689980111720633592558858121242731082e-1 quadts: Iteration 3 of 6; est error = 10^ -17; approx value = 7.853981633974483082028533923930157568609007576776270726821597e-1 quadts: Iteration 4 of 6; est error = 10^ -36; approx value = 7.853981633974483096156608458198757190586422063114153956005278e-1 quadts: Iteration 5 of 6; est error = 10^ -71; approx value = 7.853981633974483096156608458198757210492923498437764552437361e-1 quadts: Iteration 6 of 6; est error = 10^ -101; approx value = 7.853981633974483096156608458198757210492923498437764552437361e-1 Result[ 1] = 7.85398163397448309615660845819875721049292349843776455243736148076954e-1 CPU time = 0.1730 functions (hit enter) Abs Arccos Arcsin Arctan Arctan2 Bessel Besselexp Binomial Cos Erf Exp Factorial Gamma Integrate Log Max Min Polyroot Pslq Result Sin Sqrt Sum Table Tan Zeta Zetap Zetaz variables (hit enter) E Log2 Log10 Pi Catalan Eulergamma Infinity Arg1 Arg2 Arg3 Arg4 Arg5 Arg6 Arg7 Arg8 Arg9 Debug Digits Digits2 Epsilon Epsilon2 Pslqbound Pslqlevel Quadlevel Quadtype x Pi (hit enter) Result[ 2] = 3.14159265358979323846264338327950288419716939937510582097494459230781e0 CPU time = 0.0000 sqrt[1600] (hit enter) Result[ 1] = 4.00000000000000000000000000000000000000000000000000000000000000000000e1 CPU time = 0.0000 help Binomial (hit enter) Binomial[m,n] computes the binomial coefficient of integers (m,n). Binomial[3,2] (hit enter) Result[ 2] = 3.00000000000000000000000000000000000000000000000000000000000000000000e0 CPU time = 0.0000 hypo[x,y] = sqrt[x^2+y^2] (hit enter) parse: new function name = hypo CPU time = 0.0000 z=hypo[3,4] (hit enter) parse: new variable name = z CPU time = 0.0000 z (hit enter) Result[ 3] = 5.00000000000000000000000000000000000000000000000000000000000000000000e0 CPU time = 0.0000
References
o High-Precision Software Directory
http://crd.lbl.gov/~dhbailey/mpdist/index.html