diff --git a/src/eccd.f90 b/src/eccd.f90 index 880a959..930b05c 100644 --- a/src/eccd.f90 +++ b/src/eccd.f90 @@ -140,7 +140,8 @@ contains subroutine setcdcoeff_ncl(zeff,rbx,fc,amu,rhop,cst2,eccdpar) use magsurf_data, only : ch,tjp,tlm,njpt,nlmt - use dierckx, only : profil + use dierckx, only : profil + use logger, only : log_warning implicit none integer, parameter :: ksp=3 real(wp_), intent(in) :: zeff,rbx,fc,amu,rhop @@ -154,7 +155,14 @@ contains call SpitzFuncCoeff(amu,Zeff,fc) nlm=nlmt call profil(0,tjp,njpt,tlm,nlmt,ch,ksp,ksp,rhop,nlm,chlm,ierr) - if(ierr>0) print*,' Hlambda profil =',ierr + if (ierr > 0) then + block + character(256) :: msg + write(msg, '(a, g0)') & + 'when computing H(λ) `profil` returned ier=', ierr + call log_warning(msg, mod='eccd', proc='setcdcoeff_ncl') + end block + end if npar=3+2*nlm allocate(eccdpar(npar)) eccdpar(1)=zeff diff --git a/src/gray_core.f90 b/src/gray_core.f90 index 50da22b..1f00d91 100644 --- a/src/gray_core.f90 +++ b/src/gray_core.f90 @@ -652,7 +652,6 @@ contains ! beam tracing initial conditions igrad=1 ! !!!!!! check ray tracing initial conditions igrad=0 !!!!!! use const_and_precisions, only : zero,one,pi,half,two,degree,ui=>im - use math, only : catand use gray_params, only : gray_parameters use beamdata, only : nray,nrayr,nrayth,rwmax @@ -730,7 +729,7 @@ contains dw = wwcsi - wweta ts = -(dk*sin(2*phirrad) - ui*dw*sin(2*phiwrad)) tc = (dk*cos(2*phirrad) - ui*dw*cos(2*phiwrad)) - phic = half*catand(ts/tc) + phic = half*atan(ts/tc) ddd = dk*cos(2*(phirrad+phic)) - ui*dw*cos(2*(phiwrad+phic)) sss = sk - ui*sw qi1 = half*(sss + ddd) diff --git a/src/magsurf_data.f90 b/src/magsurf_data.f90 index f6febad..6c2662e 100644 --- a/src/magsurf_data.f90 +++ b/src/magsurf_data.f90 @@ -469,6 +469,7 @@ contains subroutine contours_psi(h,rcn,zcn,rup,zup,rlw,zlw) use const_and_precisions, only : wp_,pi use gray_params, only : iequil + use logger, only : log_warning use dierckx, only : profil,sproota use equilibrium, only : rmaxis,zmaxis,aminor,frhotor,tr,nsr,tz,nsz,cceq, & kspl,psiant,psinop,points_tgo @@ -517,7 +518,14 @@ contains zc=zlw+(zup-zlw)*(1.0_wp_-cos(th*(ic-1)))/2.0_wp_ iopt=1 call profil(iopt,tr,nsr,tz,nsz,cceq,kspl,kspl,zc,nsr,czc,ier) - if(ier.gt.0) print*,' profil =',ier + if (ier > 0) then + block + character(256) :: msg + write(msg, '(a, a, g0)') & + 'when computing ψ(R,z) contour `profil` returned ier=', ier + call log_warning(msg, mod='magsurf_data', proc='contours_psi') + end block + end if val=h*psiant+psinop call sproota(val,tr,nsr,czc,zeroc,mest,m,ier) if (zeroc(1).gt.rwallm) then diff --git a/src/math.f90 b/src/math.f90 index 4075194..d2763a0 100644 --- a/src/math.f90 +++ b/src/math.f90 @@ -1,100 +1,20 @@ +! Miscellaneous mathematical functions module math - use const_and_precisions, only : wp_, zero, one - implicit none +implicit none contains - function catand(z) -!***begin prologue catan -!***purpose compute the complex arc tangent. -!***library slatec (fnlib) -!***category c4a -!***type complex (catan-c) -!***keywords arc tangent, elementary functions, fnlib, trigonometric -!***author fullerton, w., (lanl) -!***description -! -! catan(z) calculates the complex trigonometric arc tangent of z. -! the result is in units of radians, and the real part is in the first -! or fourth quadrant. -! -!***references (none) -!***routines called (none) -!***revision history (yymmdd) -! 770801 date written -! 890531 changed all specific intrinsics to generic. (wrb) -! 890531 revision date from version 3.2 -! 891214 prologue converted to version 4.0 format. (bab) -! 900315 calls to xerror changed to calls to xermsg. (thj) -! 900326 removed duplicate information from description section. -! (wrb) -!***end prologue catan - use const_and_precisions, only : comp_eps, pi2=>pihalf, czero, cunit - implicit none - complex(wp_) :: catand - complex(wp_), intent(in) :: z - complex(wp_) :: z2 - real(wp_) :: r,x,y,r2,xans,yans,twoi - integer :: i - logical, save :: first=.true. - integer, save :: nterms - real(wp_), save :: rmin, rmax, sqeps -!***first executable statement catan - if (first) then -! nterms = log(eps)/log(rbnd) where rbnd = 0.1 - nterms = int(-0.4343_wp_*log(0.5_wp_*comp_eps) + 1.0_wp_) - sqeps = sqrt(comp_eps) - rmin = sqrt (1.5_wp_*comp_eps) - rmax = 2.0_wp_/comp_eps - endif - first = .false. -! - r = abs(z) - if (r<=0.1_wp_) then -! - catand = z - if (r