I am facing an issue while compiling WRF-DA code (code is here)
The compilation line which fails -
ftn -c -ip -O3 -w -ftz -fno-alias -align all -FR -convert big_endian -r8 -real-size `expr 8 \* 8` -i4 -I../external/crtm_2.2.3/libsrc -I/opt/cray/pe/hdf5/1.10.0.3/INTEL/16.0/include -L/opt/cray/pe/hdf5/1.10.0.3/INTEL/16.0/lib/ -lhdf5hl_fortran -lhdf5_fortran -lhdf5 da_radiance.f
da_radiance.f(5884): error #6285: There is no matching specific subroutine for this generic subroutine call. [H5DREAD_F]
call H5Dread_f(dhnd1, &
-----------^
I tried searching relevant symbol in library, and as expected the symbol was not present (h5dread_f_c is present instead).
nm /opt/cray/pe/hdf5/1.10.0.3/INTEL/16.0/lib/libhdf5*|grep -i h5dread_f
nm: /opt/cray/pe/hdf5/1.10.0.3/INTEL/16.0/lib/libhdf5.settings: File format not recognized
nm: /opt/cray/pe/hdf5/1.10.0.3/INTEL/16.0/lib/libhdf5_cpp_intel_160.la: File format not recognized
U h5dread_f_c
U h5dread_f_c
0000000000001290 T h5dread_f_c
0000000000035320 T h5dread_f_c
U h5dread_f_c
U h5dread_f_c
0000000000001290 T h5dread_f_c
0000000000035320 T h5dread_f_c
U h5dread_f_c
U h5dread_f_c
0000000000001290 T h5dread_f_c
0000000000035320 T h5dread_f_c
0000000000035320 T h5dread_f_c
0000000000035320 T h5dread_f_c
I tried compiling hdf5-1.10.2. With a quick peek at the code, I saw that the function seems to have been declared (& commented) in fortran/src/H5Dff.F90 as -
! M. Scot Breitenfeld
! September 17, 2011
!
! Fortran2003 Interface:
!! SUBROUTINE h5dread_f(dset_id, mem_type_id, buf, hdferr, &
!! mem_space_id, file_space_id, xfer_prp)
!! INTEGER(HID_T), INTENT(IN) :: dset_id
!! INTEGER(HID_T), INTENT(IN) :: mem_type_id
!! TYPE(C_PTR) , INTENT(INOUT) :: buf
!! INTEGER , INTENT(OUT) :: hdferr
!! INTEGER(HID_T), INTENT(IN) , OPTIONAL :: mem_space_id
!! INTEGER(HID_T), INTENT(IN) , OPTIONAL :: file_space_id
!! INTEGER(HID_T), INTENT(IN) , OPTIONAL :: xfer_prp
!*****
SUBROUTINE h5dread_ptr(dset_id, mem_type_id, buf, hdferr, &
mem_space_id, file_space_id, xfer_prp)
has this function been phased out in latest versions of HDF5?
If yes then please share an appropriate (older) version of library (& relevant compilation flags) for the HDF5 in which i can find this symbol.
Please let me know if i can provide any further information.
h5dread_f is an interface, which maps to one of the following
INTERFACE h5dread_f
MODULE PROCEDURE h5dread_reference_obj
MODULE PROCEDURE h5dread_reference_dsetreg
MODULE PROCEDURE h5dread_char_scalar
MODULE PROCEDURE h5dread_ptr
END INTERFACE
It seems that there are invalid types being passed into the function.
(thanks to Dave Allured from HDF5 group)
Related
My compiler has started giving me a warning on a part of my code I haven't touched while developing code... The zarray is allocated, set to zero, then part of the array is set to rarray that is passed in.
SUBROUTINE advection(rbox0,rfrac,rarray,na)
IMPLICIT NONE
INTEGER, INTENT(IN) :: na
REAL, INTENT(IN) :: rfrac
REAL, INTENT(IN) :: rbox0
REAL, INTENT(INOUT) :: rarray(0:na)
! local arrays
REAL, ALLOCATABLE :: zarray1(:),zarray2(:)
ALLOCATE(zarray1(-4:2*na))
zarray1(:)=0.0
zarray1(0:na)=rarray ! zarray stores the original array
rarray(:)=0.0
rarray(0)=(1.0-rbox0)*zarray1(0)
! etc etc
Now with gfortran on a mac I'm getting this compile warning:
vectri.f90:1101:38:
1101 | rarray(0)=(1.0-rbox0)*zarray1(0)
| ^
Warning: 'MEM <real(kind=4)[0:]> [(real(kind=4)[0:] *)_77][4]' may be used uninitialized [-Wmaybe-uninitialized]
In my experience, warnings such as these are ignored at your peril, but I can't for the life of me understand why the compiler is getting upset here... I'm using
GNU Fortran (Homebrew GCC 11.3.0_1) 11.3.0
EDIT: in reply to the comments below, the code was originally
zarray1=0.0
and
rarray=0.0
when the warning arose, I changed to insert (:) to see if it would help (it didn't :-( )
I was watching a video made by Richard Cook on SafariBookOnline. He builds a command line app with Haskell. In this video, he explains some basic concepts while writing a program to parse command lines arguments.
I am quite new to Haskell, and I can't figure out why this code does not work:
dataPathParser :: Parser FilePath
dataPathParser = strOption $
value defaultDataPath
<> long "data-path"
<> short 'p'
<> metavar "DATAPATH"
<> help ("path to data file (default " ++ defaultDataPath ++ ")")
This code does not work at well:
itemDescriptionValueParser :: Parser String
itemDescriptionValueParser =
strOption (long "desc" <> short 'd' <> metavar "DESCRIPTION" <> help "description")
And actually, everywhere I wrote "<>", I got an error where the compiler tells me that:
• Variable not in scope:
(<>) :: Mod f5 a5 -> Mod f4 a4 -> Mod ArgumentFields ItemIndex
• Perhaps you meant one of these:
‘<$>’ (imported from Options.Applicative),
‘<*>’ (imported from Options.Applicative),
‘<|>’ (imported from Options.Applicative)
The problem I got is most probably due to the difference of versions of GHC and Optparse-applicative. I use the latest ones.
LTS Haskell 9.12: 0.13.2.0.
But since I am quite new, I can't figure out how to rewrite the code of Richard Cook.
I would appreciate any help.
Thanks in advance,
Alex
http://hackage.haskell.org/package/optparse-applicative-0.14.0.0/docs/Options-Applicative.html#t:Parser:
A modifier can be created by composing the basic modifiers provided by here using the Monoid operations mempty and mappend, or their aliases idm and <>.
It looks like it doesn't export <>, though, so you need to get it from Data.Monoid:
import Data.Monoid
... or just:
import Data.Monoid ((<>))
I learned how to use C global variables in Fortran code, as given in the example below. But how to do it in a reverse direction, i.e., define (and initialize) a variable in Fortran and make it accessible to C?
/* C global variables */
int c_extern;
long myVariable;
!Fortran binding code
MODULE LINK_TO_C_VARS
USE ISO_C_BINDING
!Implicit label binding
!Bind variable C_EXTERN to c_extern
INTEGER(C_INT), BIND(C) :: C_EXTERN
!Explicit label binding
!Bind C2 to myVariable
INTEGER(C_LONG) :: C2
BIND(C, NAME='myVariable') :: C2
END MODULE LINK_TO_C_VARS
Follow-up:
Thanks to M.S.B.
I did some experiments. I put the C code in vars.c, the Fortran code in mod.f90.
gcc -c vars.c
nm vars.o
0000000000000004 C c_extern
0000000000000008 C myVariable
gfortran -c mod.f90
nm mod.o
0000000000000004 C c_extern
0000000000000008 C myVariable
'man nm' says: "C" -- The symbol is common. Common symbols are uninitialized data. When linking, multiple common symbols may appear with the same name. If the symbol is defined anywhere, the common symbols are treated as undefined references.
Then, I changed variables in vars.c to extern
<<vars-ext.c>>
extern int c_extern;
extern long myVariable;
gcc -c vars-ext.c and nm vars-ext.o
U c_extern
U myVariable
gfortran can successfully link mod.o with vars.o or vars-ext.o. It looks that the magic lies in the "C" kind symbols.
This is a continuation of my older thread.
I have a file from different code, that I should parse to use as my input.
A snippet from it looks like:
GLOBAL SYSTEM PARAMETER
NQ 2
NT 2
NM 2
IREL 3
*************************************
BEXT 0.00000000000000E+00
SEMICORE F
LLOYD F
NE 32 0
IBZINT 2
NKTAB 936
XC-POT VWN
SCF-ALG BROYDEN2
SCF-ITER 29
SCF-MIX 2.00000000000000E-01
SCF-TOL 1.00000000000000E-05
RMSAVV 2.11362995016878E-06
RMSAVB 1.25411205586140E-06
EF 7.27534671479201E-01
VMTZ -7.72451391270293E-01
*************************************
And so on.
Currently I am reading it line by line, as:
Program readpot
use iso_fortran_env
Implicit None
integer ::i,filestat,nq
character(len=120):: rdline
character(10)::key!,dimension(:),allocatable ::key
real,dimension(:),allocatable ::val
i=0
open(12,file="FeRh.pot_new",status="old")
readline:do
i=i+1
read(12,'(A)',iostat=filestat) rdline!(i)
if (filestat /= 0) then
if (filestat == iostat_end ) then
exit readline
else
write ( *, '( / "Error reading file: ", I0 )' ) filestat
stop
endif
end if
if (rdline(1:2)=="NQ") then
read(rdline(19:20),'(i)'),nq
write(*,*)nq
end if
end do readline
End Program readpot
So, I have to read every line, manually find the value column corresponding to the key, and write that(For brevity, I have shown for one value only).
My question is, is this the proper way of doing this? or there is other simpler way? Kindly let me know.
If the file has no variability you scarcely need to parse it at all. Let's suppose that you have declared variables for all the interesting data items in the file and that those variables have the names shown on the lines of the file. For example
INTEGER :: nq , nt, nm, irel
REAL:: scf_mix, scf_tol ! '-' not allowed in Fortran names
CHARACTER(len=48) :: label, text
LOGICAL :: semicore, lloyd
! Complete this as you wish
Then write a block of code like this
OPEN(12,file="FeRh.pot_new",status="old")
READ(12,*) ! Not interested in the 1st line
READ(12,*) label, nq
READ(12,*) label, nt
READ(12,*) label, nm
READ(12,*) label, irel
READ(12,*) ! Not interested in this line
READ(12,*) label, bext
READ(12,*) label, semicore
! Other lines to write
CLOSE(12)
Fortran's list-directed input understands blanks in lines to separate values. It will not read those blanks as part of a character variable. That behaviour can be changed but in your case you don't need to. Note that it will also understand the character F to mean .false. when read into a logical variable.
My code snippet just ignores the labels and lines of explanation. If you are of a nervous disposition you could process them, perhaps
IF (label/='NE') STOP
or whatever you wish.
my working in file parsing using Haskell, and I'm using both Data.Attoparsec.Char8 and Data.ByteString.Char8. I want to parse an expression which can contains symbols like : - / [ ] _ . (minus, slashes, braquets and underscore).
I've write the following parser
import qualified Data.ByteString.Char8 as B
import qualified Data.Attoparsec.Char8 as A
identifier' :: Parser B.ByteString
identifier' = A.takeWhile $ A.inClass "A-Za-z0-9_//- /[/]"
... but it's not works like expected.
ghc> A.parse identifier' (B.pack "EMBXSHM-PortClo")
Done "-PortClo" "EMBXSHM"
ghc> A.parse identifier' (B.pack "AU_D[1].PCMPTask")
Done ".PCMPTask" "AU_D[1]"
can someone help me.
Thanks for your time.
Take a look at the documentation: http://hackage.haskell.org/packages/archive/attoparsec/0.10.1.0/doc/html/Data-Attoparsec-ByteString-Char8.html#g:9
To add a "-" to a set, place it a the beginning or end of a string.
The latter doesn't parse because you don't have dots in your class listing.
You want to allow '-' characters in identifiers, but A.inClass uses '-' for ranges. You have to put it at the start or end of the range string:
To add a literal '-' to a set, place it at the beginning or end of the string.
— attoparsec documentation