F77_LOCK

Prevents code from being run simultaneously in two separate threads

Description:

Any C code that may need to be used in a threaded context should use this macro should to prevent Fortran code being run simultaneously in two separate threads, with consequent danger of unsynchronised memory access. The macro locks the global CNF mutex, then executes the code specified in the argument, and then unlocks the mutex. If the mutex is currently locked by another thread (e.g. due to the use of F77_LOCK in the other thread), then the calling thread blocks until the other thread releases the mutex.

Invocation

F77_LOCK(code)

Arguments

code
Any arbitrary C code. Typically, this will be an invocation of a Fortran subroutine.

Examples:

F77_LOCK( result = F77_CALL(sim)( nel, data, status ); )

Notes:

This macro invokes the cnfLock and cnfUnlock functions to lock and unlock the global mutex.